Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  C# indicators Cplex

    Posted 05/06/10 05:10 PM

    Originally posted by: Bo7


    Hello,
    I'm working with c# and i use indicators but i can't find how to write the formulation below with c# because it uses the indicators implicitly( with the methods like ifThen Or And)

    Here is the example that i want to write in LP format file:
    alph10 = 1 -> d8 - d5 + 0P <= 3
    d8 - d5 + 0P >= 1
    alph11 = 1 -> d8 - d6 + 0P <= 5
    d8 - d6 + 0P >= 3
    alph12 = 1 -> d8 - d7 + 0P <= 3
    d8 - d7 + 0P >= 1
    alph10 + alph11 + alph12 = 1
    what instruction and methods with c# should i use to have the same formulation.

    Thank you very much in advance
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: C# indicators Cplex

    Posted 05/07/10 07:09 AM

    Originally posted by: SystemAdmin


    As in other flavors (C++, Java) of Concert you create this kind of constraint using the IfThen, Or and And member functions of class Cplex.
    Unfortunately, it seems that IfThen is not documented in the reference documentation (but And and Or are).
    However, IfThen works exactly like in the other Concert APIs, so you may check there. For your first constraint the code would look like this
    using ILOG.Concert;
    using ILOG.CPLEX;
     
    public class Indicator {
       public static void Main(string[] args) {
          try {
             Cplex cplex = new Cplex();
     
             INumVar alph10 = cplex.NumVar(0, 1, "alph10");
             INumVar d5     = cplex.NumVar(0, 1, "d5");
             INumVar d8     = cplex.NumVar(0, 1, "d8");
             INumVar OP     = cplex.NumVar(0, 1, "OP");
     
             cplex.Add(cplex.IfThen(cplex.Eq(alph10, 1.0),
                                    cplex.Le(cplex.Sum(cplex.Diff(d8, d5), OP), 3)));
     
             cplex.ExportModel("indicator.lp");
             cplex.End();
          }
          catch (ILOG.Concert.Exception e) {
             System.Console.WriteLine("Concert exception caught '" + e + "' caught");
          }
       }
    }
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: C# indicators Cplex

    Posted 05/07/10 08:42 AM

    Originally posted by: Bo7


    ok thank you i will try this
    #CPLEXOptimizers
    #DecisionOptimization