Interface IOptQuestEvaluator


public interface IOptQuestEvaluator
Defines the callback that evaluates each solution in a managed run, such as OptQuestModel.Optimize(int, IOptQuestEvaluator). The callback runs your simulation or other computation.

This callback is a different operation from OptQuestSolution.Evaluate(). That method computes the expressions, constraints and objectives of a solution whose values you supply, and it does not give the solution to the engine.

For a stochastic model with replications, the engine calls the evaluator once for each replication of each trial solution. The decision-variable values are the same in each replication, and the engine draws the random variables again for each call. The engine does not call the evaluator for a solution that you supplied with results through OptQuestSolution.AddEvaluated(). In a run with more than one thread, the engine calls the evaluator on several threads at once, so the evaluator must synchronize any shared state.

OptQuestSolution.GetValue(String) and OptQuestSolution.SetValue(String, double) declare COptQuestException, and Evaluate does not, so an evaluator catches that exception:


 class SquareEvaluator implements IOptQuestEvaluator {
     public boolean Evaluate(OptQuestSolution sol) {
         try {
             double x = sol.GetValue("x");
             sol.SetValue("y", x * x);
             return true;
         } catch (COptQuestException e) {
             return false;
         }
     }
 }
 
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Computes the output values of a solution.
  • Method Details

    • Evaluate

      boolean Evaluate(OptQuestSolution sol)
      Computes the output values of a solution. The engine has set the values of the input variables. Read them with OptQuestSolution.GetValue(String), run the simulation, and write each output with OptQuestSolution.SetValue(String, double). Each output is NaN until the evaluator sets it. If the evaluator does not set an output, each objective and constraint that uses the output is NaN, and the solution is infeasible.
      Parameters:
      sol - - the solution to evaluate.
      Returns:
      - true to submit the solution, as OptQuestSolution.Submit() does; false to reject it, as OptQuestSolution.Reject() does. The engine does not use a rejected solution to guide the solutions that it generates next.