Yuan
Yuan

Reputation: 49

CPLEX using if then constraints with CP optimizer in C#

Please help me if anyone can solve this problem, and I would be so appreciated. If there is a vehicle which can transport the material from machine 1 to machine 2 or from machine 4 to machine 3, which means there are two optional intervals (named V12 and V43) for this interval(named V) to choose. However, if the preceding operation interval was operated on machine 1 and the following operation interval was operated on machine 2, only V12 can be chosen as the alternative interval. That means, I need to make a constraint like

if (presenceOf(V12)) =>
   presenceOf(operation[x][1].machine==1) && presenceOf(operation[x][2].machine == 2)

Upvotes: 0

Views: 278

Answers (1)

Alex Fleischer
Alex Fleischer

Reputation: 10059

in C# you do not have operator overloading so you should rely on

  • cplex.IfThen for =>
  • cplex.Ge for >=
  • cplex.Eq for ==

and so on

See example foodmanufact.cs in CPLEX_Studio1210\cplex\examples\src\cs

FoodManufact.cs implements a solution to the food production planning problem, well known from the modeling textbook of H. P. Williams.

If you want to call OPL from C# you may have a look at the examples in

CPLEX_Studio1210\opl\examples\opl_interfaces\dotnet

Upvotes: 1

Related Questions