Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Mixed integer linear programming in matlab and cplex as solver

    Posted 05/09/16 05:25 PM

    Originally posted by: Samira Fazel


    Hello,

    I wrote MILP code in MATLAB by making coefficient matrix using example cplexmilpex. It was very hard for me because one of my decision variable has 6 index (subscripts). Then I call cplex to solve my problem which is fine but my objective value is zero all the time which I guess I might made some mistakes in my matrix multiplication...

    I was wondering is there any method/ example for MILP in  Matlab and call cplex as solver which has decision variables with 6 subscripts, I meant more than 3 subscripts at least? 

    Thank you!

    Samira


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Mixed integer linear programming in matlab and cplex as solver

    Posted 05/11/16 10:38 AM

    Hi,

    about examples, have you had a look at C:\ILOG\CPLEX_Studio1263\cplex\examples\src\matlab ?

    At https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=86414

    you may vote for a Request For Enhancement about having an API to call OPL from MATLAB

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Mixed integer linear programming in matlab and cplex as solver

    Posted 05/11/16 02:24 PM

    Originally posted by: Samira Fazel


    Thank you.

    Yes, I saw the examples and used them to set up my problem. But, it took lots of time and seems it is not efficient enough for my case.....

    However, if it is possible to call OPL from MATLAB that would be awesome. I did vote for a Request for Enhancement about having an API to call OPL from MATLAB. Do I need to wait for the reply now? Because the previous request sent on April 5th and still not delivered. 

    Thank you!

    Samira


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Mixed integer linear programming in matlab and cplex as solver

    Posted 05/11/16 02:55 PM

    Hi,

    in the meantime, you could use system http://fr.mathworks.com/help/matlab/ref/system.html?searchHighlight=system

    to call oplrun (OPL in command line) from your m code

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Mixed integer linear programming in matlab and cplex as solver

    Posted 05/11/16 04:20 PM

    Originally posted by: Samira Fazel


    Thank you. I need more clarification as I have no experience for that. For example, I have a written "MILP" in OPL. Now, I have some part of my code in MATLAB as the following order:

    .m code:

    1. Some simulation in MATLAB.

    2. I want to call the written "MILP" from OPL to see the result. 

    Is it the way I can use OPL in MATLAB? and, if I am right would you please give me an example how I can call my OPL code in .m code?

    Moreover, after solving my MILP in OPL, can I see the result in MATLAB as well to use it in the rest of my code in .m file?

    Thank you!

    Samira

     

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Mixed integer linear programming in matlab and cplex as solver

    Posted 05/12/16 03:44 AM

    Hi,

    you can read a similar discussion at https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014868161#repliesPg=0

    Especially let me quote @KhalidAbdulla

    In case others with similar requirements to me end up reading this post what I ended up doing was simply calling the oplrun binary as an operating system command from Matlab. Along the lines of:

    >> command = 'oplrun myModel.mod myData.dat';

    >> [status, cmdout] = system(command);

    It is fairly straight-forward to then use MATLAB to make modifications to (or new versions of) 'myData.dat' to run mutliple instances of a problem, carry out sensitivity studies etc. To get the results back from the model you can either get the model to directly print output files which can then be read into MATLAB or you could parse the 'cmdout' variable assigned above which will contain the solution values for the decision variables (assuming it solved).

    This may not be the most efficient/effective way of working but it is serving my purposes for now. If anyone has suggestions for a better way of doing this please post a reply.

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Mixed integer linear programming in matlab and cplex as solver

    Posted 05/12/16 10:35 AM

    Originally posted by: Samira Fazel


    Many thanks for the help and comments! It is very useful.

    Best Regards,

    Samira 

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer