Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  callback to get elpased time

    Posted 07/23/15 01:19 PM

    Originally posted by: prashanw


    I am using the following code to query the best objective of the cplex solver using the python API . How do I also get the elapsed time for each specific data point? Because if I have elapsed time i can do a subtraction and get the time to solve. 

    My intention is to plot the Objective vs elapsed time.

    reference to code : https://www.ibm.com/developerworks/community/wikis/form/api/wiki/de368162-e90b-432c-a4e9-795cc51440dd/page/8eb84825-f653-4714-a85e-43e14e08136a/attachment/7411090d-db2b-431d-8243-5f4be8117586/media/BestPracticesUsingCPLEXPython3API.pdf

    class MyCallback(cplex.callbacks.MIPInfoCallback):    
        
        def __call__(self):
            if self.has_incumbent():
                self.incobjval.append(self.get_incumbent_objective_value())
                self.bestobjval.append(self.get_best_objective_value())
       
    

    Thanks!


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: callback to get elpased time

    Posted 07/23/15 01:42 PM

    You can use the get_time method which is inherited from the top-level Callback class.  See the documentation here.

    For example:

    class MyCallback(cplex.callbacks.MIPInfoCallback):    
        
        def __call__(self):
            if self.has_incumbent():
                self.incobjval.append(self.get_incumbent_objective_value())
                self.bestobjval.append(self.get_best_objective_value())
                self.times.append(self.get_time())
    

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: callback to get elpased time

    Posted 07/24/15 09:40 AM

    Originally posted by: prashanw


    Thanks!..hmm I can't spot the "accept answer button"


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: callback to get elpased time

    Posted 07/24/15 10:57 AM

    Glad that helped.  When you start a topic, you have to select the "Mark this topic as a question" checkbox, in order to have an accept button.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: callback to get elpased time

    Posted 07/24/15 10:59 AM

    Originally posted by: prashanw


    done. Thanks!


    #CPLEXOptimizers
    #DecisionOptimization