Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

no solution returned when change the objective but same constraints

  • 1.  no solution returned when change the objective but same constraints

    Posted 02/23/17 12:20 PM

    Originally posted by: Jamie1993


    Hello,

    I am using CPLEX in python. I have two different objectives, say total cost and total time, but under same set of constraints. When I input same problem instance, the CPLEX can return a solution when the objective is total cost but no solution found when objective is total time. It looks very strange to me since if the constraints are the same, the feasible solution space should be same. CPLEX returning a solution for total cost means that there is feasible solution existing in this space. So even if i changed the objective, CPLEX should still return a solution right? Could anyone help me on this?

     

    Thank you very much!

    Jamie


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: no solution returned when change the objective but same constraints

    Posted 02/23/17 12:43 PM

    What is the return value of cplex.solution.get_status() in the two cases? It could be that the model is unbounded for one of the two objectives.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: no solution returned when change the objective but same constraints

    Posted 02/23/17 03:06 PM

    Originally posted by: Jamie1993


    I am using docplex in python and could you let me know how to get the return value of cplex.solution.get_status()? what do yo mean by unbounded for certain objective? thank you


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: no solution returned when change the objective but same constraints

    Posted 02/23/17 03:47 PM

    It looks like you have crossposted this question here (which is the right place for docplex questions).

    However, it looks like you should call call get_solve_details() and then get_status() on the SolveDetails object that is returned.

    It will probably be easier for people to help you here if you export your model in SAV format and share it here (via the export_as_sav method).


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: no solution returned when change the objective but same constraints

    Posted 02/23/17 04:55 PM

    Originally posted by: Jamie1993


    Thank you for your guide. Unfortunately, the CPLEX i am using seems not installed in local since I get error

    SAV requires CPLEX, but a local CPLEX installation could not be found
    

    and also I could not call get_solve_details() and get_status() functions. In the project, the docplex.mp.model is wrapped up and the solution is warped in this (pic attached). And the "log" is basically got form "local_log_file" here:

    os.system("%s -c 'read %s' 'set timelimit %d' 'opt' 'set logfile %s' 'display solution variables -' 'quit'" % (cplex_conf.PATH, local_file, self.get_timeout(logger), local_log_file))

    So it is not a SolveDetails and i am not sure how to call those two functions. (And I have not idea how it get the solution from the log).

    Really sorry for my dump questions since I am new to all of this and thank you for your reply.


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: no solution returned when change the objective but same constraints

    Posted 02/23/17 05:23 PM

    Sorry, my bad.  I should have asked whether you were solving on the cloud or not.  I think you can still use export_as_lp (even without a local CPLEX installation), if you want to try to share your model here.  It would probably be most helpful if you share both models (with the objective that works and the one that does not).  Exporting to LP format is a good debugging technique in general as you can look at the two models and easily detect differences (I mentioned SAV format above because it provides a greater degree of precision in data).  For future reference, you can get the community edition for free if you want a local CPLEX installation.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: no solution returned when change the objective but same constraints

    Posted 02/23/17 05:49 PM

    Originally posted by: Jamie1993


    Thank you so much. It works. But it is really a complicated model and to me it is really hard to see the issue through this file. And seems that the variables are assigned different names in different runs. The files are attached.


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: no solution returned when change the objective but same constraints

    Posted 02/24/17 02:25 AM

    From the LP files it is hard to tell whether the constraints in the two models are equivalent. The variables have different names and are in a different order. Any chance you can name the variables in your model so that both files have variables with the same names?

    In any case, are you sure the constraints are the exact same? I am asking because on work.lp CPLEX quickly finds a feasible solution while not-work.lp is proven infeasible by feasopt! This may be a numerical issue but it may also be that the two models are not the same.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: no solution returned when change the objective but same constraints

    Posted 02/24/17 07:41 AM

    OK, by now I have found a feasible solution to not-work.lp, so the model is feasible.

    I think your issue is the following: For work.lp CPLEX finds a feasible solution relatively quickly, so eventually there will be a feasible solution that you can query. For not-work.lp CPLEX has a hard time finding a feasible solution, so you probably hit a time limit or another resource limit before CPLEX can find a first feasible solution. If you check the status in each of the two solves you should see different statuses.

    I did not (yet) figure out why CPLEX has such a hard time finding a feasible solution for not-work.lp. Is it easy for you to come up with a feasible solution for your model, even if that solution has a bad objective function value? If that is the case then providing such a solution as MIP start could help CPLEX a lot.

     

    EDIT: You may also want to try setting the MIP emphasis to 1 (emphasis on integer feasibility). I did some experiments here and it seemed to help.


    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: no solution returned when change the objective but same constraints

    Posted 02/24/17 10:30 AM

    Originally posted by: Jamie1993


    I see. Thank you for your suggestions. Could you kindly tell me how long does it take cplex to find a solution for not-work in your experiment? Right after I got lp file yesterday, i also run it in the terminal but it showed me no feasible solution found even after running for 10 min.

     

    It is not very easy to guess a feasible solution for this model unfortunately because of too many variables in most cases. But I definitely will look into MIP emphasis and try it.

     

    Thank you so much.


    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: no solution returned when change the objective but same constraints

    Posted 02/24/17 12:22 PM

    With MIP emphasis set to 1 it took 10 seconds to find a feasible solution. However, this may heavily depend on the machine and CPLEX version used.


    #CPLEXOptimizers
    #DecisionOptimization


  • 12.  Re: no solution returned when change the objective but same constraints

    Posted 02/24/17 12:35 PM

    Originally posted by: Jamie1993


    Thanks. How should I set parameters.emphasis.mip = 1 if the cplex is running on another sever? and is there any way to check whether it has been set to 1 successfully?


    #CPLEXOptimizers
    #DecisionOptimization


  • 13.  Re: no solution returned when change the objective but same constraints

    Posted 02/24/17 12:53 PM

    If m is an instance of the Model class then you set the parameter via

    m.parameters.emphasis.mip = 1

    If you look at the engine log returned by DOcplexcloud then in the beginning you should see a list of parameters that are set to non-default values. This list should contain CPX_PARAM_MIPEMPHASIS and indicate that it is set to 1.


    #CPLEXOptimizers
    #DecisionOptimization


  • 14.  Re: no solution returned when change the objective but same constraints

    Posted 02/24/17 01:13 PM

    Originally posted by: Jamie1993


    It does work now for most of the runs when CPX_PARAM_MIPEMPHASIS is set to 1. Is there possibly any randomness in different runs for the same lp?


    #CPLEXOptimizers
    #DecisionOptimization


  • 15.  Re: no solution returned when change the objective but same constraints

    Posted 02/27/17 08:48 AM

    Sorry, I'm confused. This looks like a CPLEX log file but from a local solve. Did you obtain this file by solving locally or by solving on the cloud?

    In fact, how exactly did you obtain this log file? It does not even look like the Python API would create, it looks more like something from the interactive optimizer?


    #CPLEXOptimizers
    #DecisionOptimization


  • 16.  Re: no solution returned when change the objective but same constraints

    Posted 02/27/17 12:29 PM

    Originally posted by: Jamie1993


    aw. I am sorry. I finally figured out that how they embed cplex in the project this weekend. The program launches a cplex process using os.system() inside which lauches a interactive optimizer and execute the pre-exported lp file. So yes i do not use cplex on the cloud. Sorry I did not figure this out earlier. I think the problem is solved when i set emphasis.mip to 1 so thank you so much for your help!


    #CPLEXOptimizers
    #DecisionOptimization