Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Cplex Matlab interface suggestion

    Posted 09/13/11 12:06 PM

    Originally posted by: CplexUser1453


    I have a suggestion as a fairly long time cplex user in different settings (academic and commercial).

    It is really nice that cplex can be called from matlab now without dealing with cplexint and the like. I can imagine that there are good reasons why ILOG went ahead with an official matlab interface. However working with cplex from matlab is still not as convenient as it could be, especially when working with large problems and for beginners in the field. As far as I am concerned there is already a convenient way to build models in matlab and solve them using cplex :
    YALMIP (http://users.isy.liu.se/johanl/yalmip/)

    YALMIP does more than just call cplex and does not exploit all the features of the cplex matlab interface - sos1 for example (it would be really nice if it did one day...). However, I think that people who are interested in calling cplex from matlab may appreciate a link to yalmip the cplex-matlab documentation.

    (I figure that the easier cplex is to use the more people will use it)
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Cplex Matlab interface suggestion

    Posted 09/13/11 12:22 PM

    Originally posted by: John Cui


    Thanks for your suggestion and glad to know you like our matlab connector!

    So far, you can use both Cplex class and toolbox functions in matlab to call cplex.
    1. Cplex class:
    cplex=Cplex();
    cplex.addCols();
    cplex.addRows();
    cplex.addSOS();
    cplex.addIndicator();
    cplex.addQC();
    ...
    cplex.solve(); // or cplex.refineConflict(); cplex.feasopt(); cplex.tuneParam(); ...
    


    2. functions:
    prob.A = ...;
    prob.f = ...;
    prob.lb = ...;
    prob.ub = ...;
    ...
    cplexmilp(prob) % or other functions to solve different problems
    Because Cplex have more features than functions, such as conflict refine, feasopt, tuneParam...
    so we provided below way:
    cplex=Cplex(prob)
    then you can switch from functions to Cplex class to try more features of cplex.
    


    Improve the modeling feature to make modeling easier is a topic I thought before, I will discuss it with our team members, if we have any improvement, I will tell you, thanks!

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Cplex Matlab interface suggestion

    Posted 09/13/11 12:49 PM

    Originally posted by: CplexUser1453


    I understand that there may be commercial reasons why don't want to advertise the existence of tools like yalmip. My point is only that using YALMIP is more convenient when building large models. In any case when the issue of the ease of modelling in MATLAB comes up, definitely have a look at YALMIP
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Cplex Matlab interface suggestion

    Posted 09/13/11 12:52 PM

    Originally posted by: SystemAdmin


    Could you describe what features you are missing in the CPLEX/MATLAB connector? As John said, we are always looking for improvements, and your feedback would be very valuable for us.

    Thanks,

    Tobias
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Cplex Matlab interface suggestion

    Posted 09/14/11 04:06 AM

    Originally posted by: CplexUser1453


    I think that the connector is just fine - I have not found anything that would be missing and that I would absolutely need so far. My point was more about the convenience of model building in Matlab.

    Naturally, it is possible to build a model by adding rows or columns using the methods you provided in the connector. However, some people prefer to write constraints in a more human readable form and that is one of the reasons I guess why you have put so much work into OPL.

    So I was just thinking, you have saved a lot of trouble for people who want to call cplex from matlab by developping the connector. You could go just a little further by giving a pointer to matlab users about the existence of a modelling toolbox that is quite convenient. I figure that the more convenient a given interface is the more people will use it.

    I understand that there may be commercial reasons to consider. But frankly, OPL being a great tool for business settings, I would not choose it for a research/academic environment...
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Cplex Matlab interface suggestion

    Posted 09/14/11 10:10 AM

    Originally posted by: John Cui


    No, not only commercial reason, for academic is also enough for us to provide new features.

    If you tell us which kind modeling feature you want most, and which kind modeling feature you like, it will be a good start for us. :-)

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Cplex Matlab interface suggestion

    Posted 09/15/11 01:56 PM

    Originally posted by: SystemAdmin


    I agree with Tomas that a modeling language for Matlab based on Cplex would be useful. It may have similar features as OPL and Concert for fast model prototyping in Matlab. Below I post a simple comparative example of how modeling is done in Cplex and Yalmip.

    First step (get data):
    n = 10;
    Q = randn(n); Q = Q*Q'/1000;
    mu  = rand(1,n)/100;
    


    Model and solve with Yalmip (given the data):
    x = sdpvar(n,1);
    F = [sum(x) == 1, x >= 0, mu*x == 0.05];
    optimizer(F, x'*Q*x);
    


    Model and solve with Cplex (given the data):
    cplex = Cplex('Var_min');
    cplex.addCols(zeros(n,1), [], zeros(n,1), Inf*ones(n,1));
    cplex.addRows([1; 0.05], [ones(1,n); mu], [1; 0.05]);
    cplex.Model.Q = Q;
    cplex.solve();
    


    With Cplex API, a user has to think how to construct a matrix of constraints, RHS, LHS, etc. Modeling with Yalmip can be done in natural form. Of course, the example above is simple. Where the real power comes is the ability to specify constraints of the type:
    a' * abs(x) <= 10
    card(x) <= 10
    norm(D*x,2) <= 10
    if (x >= y && x >= z) then ~(x <= 300 || y >= 700))
    

    instead of figuring out how to
    split variables to define absolute value constraint
    construct MIP problem to restrict cardinality
    construct quadratic constraint
    define indicator variables/constraints
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Cplex Matlab interface suggestion

    Posted 09/22/11 03:44 AM

    Originally posted by: SystemAdmin


    BTW, the if-then thing you attribute to YALMIP does not look correct. Such support is not available (implies operator exist though...)
    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Cplex Matlab interface suggestion

    Posted 09/22/11 03:42 AM

    Originally posted by: SystemAdmin


    CplexUser1453: SOS1+SOS2 are fully supported in the next version of YALMIP. You are welcome to contact me for a beta (the relase has unfortunately been delayed)
    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: Cplex Matlab interface suggestion

    Posted 09/22/11 05:34 AM

    Originally posted by: CplexUser1453


    That's great, SOS1 will be useful.

    However it seems to me that there are other useful features that the CPLEX Matlab interface has that may not be so easy to include in yalmip, like automatic tuning or the feasopt function (changes in yalmip architecture?). I made my suggestion on this forum only because I think that, YALMIP being a great tool, Johan has other things to do than adding features he does not necessairily use but that would make it even easier for people to use an IBM product (nice example here http://sedumi.ie.lehigh.edu/index.php?option=com_kunena&func=view&Itemid=78&catid=19&id=5300).

    It seems to me that instead of developing a stand alone ILOG modeling language for MATLAB it would be much easier for ILOG to give a hand to Johan to add the few features of the cplex matlab interface that YALMIP does not currently support...
    #CPLEXOptimizers
    #DecisionOptimization