Java Tutorial Code 5: Computing Value of Information

From DSL

Jump to: navigation, search
public void ComputeValueOfInformation() {
 try {
   Network net = new Network();
   net.readFile("tutorial_b.xdsl");
   
   ValueOfInfo voi = new ValueOfInfo(net);
   
   // Getting the handles of nodes "Forecast" and "Invest":
   net.getNode("Forecast");
   net.getNode("Invest");
   
   voi.addNode("Forecast");
   voi.setDecision("Invest");
   voi.update();
   
   double[] results = voi.getValues();
   double EVIForecast = results[0];
   
   System.out.println("Expected Value of Information (\"Forecast\") = " + EVIForecast);
 }
 catch (SMILEException e) {
   System.out.println(e.getMessage());
 }
}
Personal tools