title: method as goal function in Microsoft Solver Foundation?
body: <p>Here is a typical optimization formulation with MSF:</p>
  
  <pre><code>using Microsoft.SolverFoundation.Services;
  
  SolverContext context = SolverContext.GetContext();
  Model model = context.CreateModel();
  
  //decisions
  Decision xs = new Decision(Domain.Real, "Number_of_small_chess_boards");
  Decision xl = new Decision(Domain.Real, "Number_of_large_chess_boards");
  
  model.AddDecisions(xs, xl);
  
  //constraints
  model.AddConstraints("limits", 0 &lt;= xs, 0 &lt;= xl);
  model.AddConstraint("BoxWood", 1 * xs + 3 * xl &lt;= 200);
  model.AddConstraint("Lathe", 3 * xs + 2 * xl &lt;= 160);
  
  //Goals
  model.AddGoal("Profit", GoalKind.Maximize, 5 * xs + 20 * xl);
  
  // This doesn't work!
  // model.AddGoal("Profit", GoalKind.Maximize, objfunc(xs, xl));
  
  
  Solution sol = context.Solve(new SimplexDirective());
  Report report = sol.GetReport();
  Console.WriteLine(report);
  </code></pre>
  
  <p>Is it possible to use a separate method instead of a statement like "5 * xs + 20 * xl" as goal function? For example, a method like the following? How?</p>
  
  <pre><code>// this method doesn't work!
  static double objfunc(Decision x, Decision y)
  {
      return 5 * x.ToDouble() + 20 * y.ToDouble();
  }
  </code></pre>