Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Remote API Matlab CPLEX

    Posted Thu May 14, 2020 03:50 AM
    Hi,

    I would like to create an exe app with Matlab that call CPLEX remotely thanks to the Distributed Optimization.


    I have just achieve the connection via TCP/IP between two windows computers inside the Studio IDE configuring a process.vmc file.

    I also know that there are some examples (distmipex1 and distmipex2) to do the same from Matlab environment. I am not using a Parallel Matlab but a standalone version. In the end, each exe application should call the server independently to complete a calculation.

    Anyway, inside distmipex1 the required code is Cplex.readVMConginf("filename.vmc") but I cannot understand why Matlab seems to do not use this command and require the calculation to the local CPLEX and not from the distributed nodes.

    I just read more times the online guide in IBM website but I cannot find if it is possible with TCP/IP (should I use process transport, MIP trasnport?). Do you know if there is a video tutorial that focus on this problem?

    Thank you for your reply.

    ------------------------------
    Riccardo Barilli
    Product Owner Software
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Remote API Matlab CPLEX

    Posted Thu May 14, 2020 04:58 AM
    This should work, provided your VMC file is correct. Can you show it here?
    Also, what is the output you get from CPLEX when it solves your model? Can you paste here as well? Could it be that your problem is so simple that it already solves in presolve? In that case distributed MIP is not started.

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 3.  RE: Remote API Matlab CPLEX

    Posted Sat May 16, 2020 04:42 AM
    Hi Daniel,

    First of all, thank you for your help. I try to explain what I have done, please ask me anything I may miss in the report.

    I started the worker process on the worker machine with the following command cplex -worker=tcpip -address=10.0.023:9987 inside the bin/x64_win64.

    From the client machine, I tried the default sample distMIP inside CPLEX Studio using the following process.vmc

    <?xml version="1.0" encoding="US-ASCII"?>
    <vmc>
    <machine name="host2">
    <transport type="TCP/IP">
    <address host="10.0.0.23" port="9987"/>
    </transport>
    </machine>
    </vmc>

    Then, we I asked a calculation and the engine log of the client reported this ...
    ______________________________________________________

    Tried aggregator 2 times.

    MIP Presolve eliminated 456 rows and 16 columns.

    MIP Presolve modified 8 coefficients.

    Aggregator did 1 substitutions.

    Reduced MIP has 100 rows, 9 columns, and 686 nonzeros.

    Reduced MIP has 9 binaries, 0 generals, 0 SOSs, and 0 indicators.

    Presolve time = 0,00 sec. (1,54 ticks)

    Running distributed MIP on 1 solver.

    Setting up 1 distributed solver.

    Setup time = 0,02 sec. (0,00 ticks)

    Starting ramp-up.

    ...
    ______________________________________________________

    On the other hand, in the command prompt of the worker I receive a message for each call like this
    [       13348:0001] read( ): No error [errno=0], last=09, was=109

    This far it seems to work fine.


    Now Matlab. I preload a model abc.lp that works fine with the local Cplex (the Cplex in the client machine). To try the distributed calculation, I recall Cplex() and readVMConfig(). The model is solved but I do not have any evidence of the fact that it was solved by the worker machine neither in the Matlab nor in the remote worker (I mean from the previous test, I received a log line in the worker command prompt).

    The client machine from which I run Cplex Studio and Matlab is the same, then I don't think it is a port/connection issue.

    This is the code.

    model='abc.lp';

    vmconfig='process1.vmc'; 

    % Initialize the CPLEX object [comment]

    cpx = Cplex();

    cpx.DisplayFunc = @redirect;

    % Now read the file and copy the data into cpx.Model [comment]

    cpx.readModel(model);

    % Now read and setup the virtual machine configuration [comment]

    cpx.readVMConfig(vmconfig);

    % Optimize the problem [comment]

    cpx.solve();


    This is the log from Matlab
    ______________________________________________________
    CPXPARAM_Output_CloneLog 1 Tried aggregator 1 time.
    LP Presolve eliminated 46 rows and 4 columns.
    Reduced LP has 522 rows, 236 columns, and 1474 nonzeros.
    Presolve time = 0.02 sec. (0.51 ticks)
    Iteration log . . .
    Iteration: 1 Dual objective = 18954.816764
    Iteration: 105 Dual objective = 200628.185847
    REMOTE: Solution status = optimal
    REMOTE: Solution value = 201149.920334
    ______________________________________________________

    Again feel free to ask me anything I may miss in this report.

    Thank you

    Riccardo




    ------------------------------
    Riccardo Barilli
    Product Owner Software
    ------------------------------



  • 4.  RE: Remote API Matlab CPLEX

    Posted Mon May 25, 2020 01:22 AM
    First of all, this line
    [       13348:0001] read( ): No error [errno=0], last=09, was=109
    should not happen, I think. Does it happen only at the end of optimization? Or only if you shut down the worker process?


    Then the problem with matlab is that you are not solving a MIP, so the configuration for distributed MIP is not applied. As you can see in the output
    LP Presolve eliminated 46 rows and 4 columns.
    The model you are solving is an LP, not a MIP. Please check the file you are reading into matlab. It seems this is not a MIP.

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 5.  RE: Remote API Matlab CPLEX

    Posted Tue May 26, 2020 01:27 PM
    Hi Daniel,

    the line [       13348:0001] read( ): No error [errno=0], last=09, was=109  appears each time I call the remote worker.

    The second one is the problem ... I did not see that my sample wasn't a MIP problem. Now it is working.

    Thank you very much.

    However, a doubt has risen ... I have just noticed that I need cplexlink1290.mexw64 and file.p (hidden Matlab) in order to use Cplex() and all the other functions. But is it ok to have those files in a client machine with Matlab and without Cplex in order to call the distributed MIP? I mean is it compliant with IBM ILOG?


    ------------------------------
    Riccardo Barilli
    Product Owner Software
    ------------------------------



  • 6.  RE: Remote API Matlab CPLEX

    Posted Wed May 27, 2020 04:34 AM
    The only way for us to know with certainty what exactly you can and can't do would be to read the contract between your company and IBM.  So please consider the following as an educated guess, and not as an official statement.

    The standard license for CPLEX Optimization Studio is located in the license sub-directory of the software installation.  For example, on MacOS, this would default to /Applications/CPLEX_Studio1210/license. Generally speaking, our licenses don't contain restrictions on how many copies of the software you can install.  Note, however, that depending on the type of license (Development, Deployment, etc), there may be restrictions on how many machines you can use the software on.

    As you noticed, the machine that acts as the master, on which you have MATLAB, must also have at least some parts of CPLEX.  So technically you are using CPLEX on that machine.  And of course also on the worker machines in your Distributed MIP setting.  So the issue is not so much of whether it is ok to have some but not all files on a given machine, because this is irrelevant.  It is much more of understanding whether your license allows using CPLEX on multiple machines at once. 

    I hope this helps. If you can tell me more about how you purchased CPLEX, I may be able to help further.

    ------------------------------
    Xavier
    ------------------------------