SMILE Tutorial Code 5: Computing Value of Information

From DSL

Jump to: navigation, search
  void ComputeValueOfInformation(void) {
    DSL_network theNet;
    theNet.ReadFile("tutorial.dsl");
    DSL_valueOfInformation theValue(&theNet);
    
    // get the handle of nodes "Forecast" and "Invest"
    int forecast = theNet.FindNode("Forecast");
    int invest = theNet.FindNode("Invest");
   theValue.AddNode(forecast);
    theValue.SetDecision(invest);
    theNet.ValueOfInformation(theValue);
    DSL_Dmatrix &theResult = theValue.GetValues();
   double EVIForecast = theResult[0];
    printf("Expected Value of Information(\"Forecast\") = %f\n",EVIForecast);
    theNet.WriteFile("tutorial.dsl");
  };
Personal tools