Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Remote object of Cplex in C++

    Posted 11/24/18 09:20 AM

    Originally posted by: Yamaz


    hi, I am trying parallel MIP with Cplex. 

    Recently I was learning how to make the remote object from the source code file "iloparmipopt.cpp".

    I realized that the function IloCplex::userfunction can invoke a designated function in the remote object and also transport some data.

    It exchanges the information between "Master" and "Worker". In the example of "iloparmipopt.cpp", the function is used like:

             
             ...
             double objdiff;
             ...
             IloCplex::Serializer s;
             s.add(objdiff);
             status = cplex.userfunction (USERACTION_CHANGEOBJDIFF,s.getRawLength(), s.getRawData(),0, 0, NULL);
             ...
    

    However, when I modified the example and trying to transport an array, error happens. The code is something like:

            ...
            double *x;
            for (int i=0;i<10;i++)
                x[i]=i;
    
            double const *b;
            b=static_cast<double const*>(x)
    
            IloCplex::Serializer s1;
            s1.add(b,10);
            int status = cplex.userfunction (TRANSPORT_ARRAY,s1.getRawLength(), s1.getRawData(),0, 0, NULL);
            ...
    

    Such code did not work and return the status with 1426.

    I am doing this in three computers with Centos 7.4, two of which are workers. But I am sure the code above can work in Mac OS.

    Does anyone can tell me what is the problem and how can I solve it to make it right in Linux?

    Thank you very much.

     

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Remote object of Cplex in C++

    Posted 11/26/18 02:20 AM

    I have applied the attached diff to the iloparmipopt example and this works without any problem.

    What transport do you use? process, mpi, tcpip? In case you use the process transport, do you use the -stdio option (which is the default in the example)? If you use the process transport and -stdio, do you by any chance print anything to stdout or std::cout from your userfunction? If so, do things work better if you print to stderr/std::cerr instead?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Remote object of Cplex in C++

    Posted 11/26/18 06:55 AM

    Originally posted by: Yamaz


    Hi Daniel,

    Thank you so much for your help.

    I applied your code to mine, the problem is solved.

    I think I had made some mistakes in allocating the space of arrays on the remote object.

     

     


    #CPLEXOptimizers
    #DecisionOptimization