0

Given two decision variable d1,d2 that take in only number 0 and 1 if the objective function is the sum of them we can express it by

Term t1=d1 + d2;
 model.AddGoal("goal", GoalKind.Maximize,t1);

Now I wish to take the smaller of them, i.e. Term

I want to write an objective function where

Math.min(d1,d2)

How to express the Math.min here?

william007
  • 17,375
  • 25
  • 118
  • 194

1 Answers1

1

The Model class contains a substantial set of relevant mathematical operations in the form of static methods, for example Min.

You could simply write:

Term t1 = Model.Min(d1, d2);

and you are good to go :-)

Anders Gustafsson
  • 15,837
  • 8
  • 56
  • 114
  • Hi I got the problem "Microsoft.SolverFoundation.Services.SimplexDirective cannot solve MINLP models. Remove this directive and use a directive that supports the MINLP capability." When using Model.Min, I am using context.Solve(new SimplexDirective()); – william007 Sep 18 '12 at 12:56
  • If you are really aiming to solve this objective function using (Mixed Integer) Linear Programming you should consider reformulating it as a _maximin_ problem. In [this](http://www.aimms.com/aimms/download/manuals/aimms3om_linearprogrammingtricks.pdf) document you can find some tricks on how to do this for the analogous _minimax_ problem. Otherwise, direct optimization of objective functions incorporating _Min_ require nonlinear methods, such as Nelder-Mead. – Anders Gustafsson Sep 18 '12 at 13:40
  • Hi, I guess I got the transform the formula as you said. I have some questions regarding transforming objective function here, see if you know:http://stackoverflow.com/questions/12482414/convert-multiplication-and-minimum-operation-for-linear-programming – william007 Sep 18 '12 at 17:58