Decision Optimization

 View Only
Expand all | Collapse all

Division not possible?

  • 1.  Division not possible?

    Posted Fri December 09, 2016 07:38 AM

    Originally posted by: Dunc


    Hi

    I am learning Cplex and I have two problems with division. I want to create an expression for doing a simple division like

            IloModel model(env);
            IloIntVar x(env, 7, 9, "x");
            IloExpr sss(env);
            sss=x/10000000;
            model.add(IloMaximize(env, sss));

    (skip)

            cplex.solve();

            std::cout<<"result cplex.getObjValue() "<<cplex.getObjValue()<<" and x is "<<cplex.getValue(x)<<std::endl;

     

    The result is "result cplex.getObjValue() 7e-07 and x is 7". However I was expecting x to be 9, because I wanted to find the x value maximizing the objective. Why?

     

    The second question is that if I change "sss=x/10000000; " to "sss=10000000/x;", Cplex is crashing with the exception: "Concert exception caught: IloAlgorithm 0x5605be684a10 cannot change extractables 0 and 42263065" . Why? How can I solve it?

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Division not possible?

    Posted Fri December 09, 2016 08:08 AM

    The behavior you observe is expected.

    In the first case CPLEX finds a solution of objective value 1e-7. That has an absolute gap of 2e-07. The default value for the absolute gap tolerance is 1e-6. Since CPLEX has found a solution with a smaller gap it is allowed to stop. If you query the status you will see that it is OptimalTolerance, not Optimal. Try setting the AbsMIPGap parameter to 0.

    For the second case: division by decision variables is not supported. You will have to reformulate your objective so that there are no decision variables in denominators.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Division not possible?

    Posted Fri December 09, 2016 08:50 AM

    Originally posted by: Dunc


    Thank you


    #CPLEXOptimizers
    #DecisionOptimization