Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Matlab and ifThen

    Posted 03/11/12 05:57 AM

    Originally posted by: baatezu


    Hello, everyone!

    I have the following question:
    let's assume a have some LP problem and I have several constraints of type:
    x1 = 1 and x2 > 0 or
    x1 = 0 and x2 = 0

    To include such constraint in .net one can simply use IfThen constraints.

    Is there any way to incapsulate such constraint in Matlab?
    Or, rephrasing the question: is there any analogue for ifThen if you use Matlab interface?

    Thanks in advance.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Matlab and ifThen

    Posted 03/11/12 10:32 PM

    Originally posted by: John Cui


    You can use "cplex.addIndicators" method to add logic constraints in MATLAB.

    addpath('/opt/CPLEX_Studio/cplex/matlab');
    cplex=Cplex();
    cplex.addCols([1;2]);
    cplex.Model.ctype = 'BB';
    cplex.addIndicators(1,1,[0,1]','E',0);
    cplex.addIndicators(1,0,[0,1]','E',0);
    cplex.writeModel('test.lp') ;


    The matlab code with addIndicators:

    \ENCODING=ISO-8859-1
    \Problem name: CPLEX

    Minimize
     obj: x1 + 2 x2
    Subject To
     i1: x1 = 0 -> x2  = 0
     i2: x1 = 1 -> x2  = 0
    Bounds
     0 <= x1 <= Inf
     0 <= x2 <= Inf
    Binaries
     x1  x2
    End

    John Cui


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Matlab and ifThen

    Posted 03/14/12 06:50 AM

    Originally posted by: baatezu


    Thanks!
    #CPLEXOptimizers
    #DecisionOptimization