Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  IloSolution::getValue - saved domain not bound

    Posted 08/14/18 09:56 AM

    Originally posted by: DeFersen


    Hi,

    i wished to used abortSearch from a Main Thread to stop execution of an other Thread executing a model of an optimization problem. That is the structure of my application :

    • Model.class : this class extends IloCP and implements Runnable. The constructor create the model with decision variables and constraint and a solve function is used by the override method run.
    • ThreadModel.class which extends Thread and have only one field : the model which is passed in parameters to the superclass constructor (super) and which has so the functions start and interrupt of Thread. I called 't' the instance of these class.
    • Main.class : contains the main method which create an instance m of the model and an other one (t) of the ThreadModel(m) and which tries to create and Instance s of IloSolution. It is probably there that there is a problem because i create this instance there with 's = m.solution()', i add variables that i want to save from the model (maybe it's a dirty way but i just would like to experiment abortSearch and Ilo Solution for the moment) and i interrupt (after 20sc) the model searching and the Thread execution with the triptych : m.abortSearch(); m.store(s) and t.interrupt();

    When i want to displayed the values of the variables added to IloSolution in the Main method (withs.getValue(v)), i get this exception message :

    Exception in thread "main" ilog.concert.IloException: IloSolution::getValue - saved domain not bound
            at ilog.concert.cppimpl.concert_wrapJNI.IloSolution_getValue__SWIG_2(Native Method)
            at ilog.concert.cppimpl.IloSolution.getValue(IloSolution.java:311)
            at ilog.concert.cppimpl.IloSolution.getValue(IloSolution.java:64)
            at Main.main(Main.java:106)
    

    There is probably a big mistake in structure from my part but i have tried many ways and none works... Could someone help me ?

    DeFersen.

    PS : i attached a file resuming the structure of the three classes with keys instructions if you need to display it.


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: IloSolution::getValue - saved domain not bound

    Posted 08/15/18 12:37 PM

    Originally posted by: rdumeur


    Dear DeFersen,

     

    Could it be that the solver hasn't found a solution before the search was aborted?

    A minimal code that reproduces the error would help us identify the origin of your problem.

    Cheers,

     

    Edit: if you have a log output, it might help us too.


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: IloSolution::getValue - saved domain not bound

    Posted 08/16/18 11:07 AM

    Originally posted by: DeFersen


    Hi,

    Thanks for your answer,

    I give you my three classes without the content of the model but i can tell you that it is an not-optimized model of a optimization problem which take a lot of time to find an optimal solution (that is exactly what i wanted to test the abortSearch functionality)

    I let 20 sc before aborting the search so it is sure that the model has found a solution (but not the optimal one), as you can observe on this output :

     ! ----------------------------------------------------------------------------
     ! Search terminated by abort, 4 solutions found.
     ! Best objective         : 4
     ! Number of branches     : 72 962
     ! Number of fails        : 24 184
     ! Total memory usage     : 391,9 MB (352,1 MB CP Optimizer + 39,9 MB Concert)
     ! Time spent in solve    : 20,83s (15,50s engine + 5,33s extraction)
     ! Search speed (br. / s) : 4 706,3
     ! ----------------------------------------------------------------------------
    On retourne vraie
    Solution(MAIN) :ilog.concert.cppimpl.IloSolution@33e5ccce
    ilog.concert.IloException: IloSolution::getValue - saved domain not bound
            at ilog.concert.cppimpl.concert_wrapJNI.IloSolution_getValue__SWIG_2(Native Method)
            at ilog.concert.cppimpl.IloSolution.getValue(IloSolution.java:311)
            at ilog.concert.cppimpl.IloSolution.getValue(IloSolution.java:64)
            at Main.main(Main.java:57)
    

    An interesting thing is that for only one execution, i could see the value of the variables i had in the IloSolution without any errors...

    It seems that i made mistakes with the order of the instruction so, even if you can't execute my code, could you give me the good structure (or a page which to talk about this) to make an abortSearch with a Thread an to store the solution into an IloSolution object (to display the value after) ?

    Best regards,

     

    DeFersen.


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: IloSolution::getValue - saved domain not bound

    Posted 08/17/18 03:13 AM

    Originally posted by: rdumeur


    Dear DeFersen,

     

    Thank you. I'll try reproduce your problem with another model.

    In the meantime, why the solution is not printed in the log snippet you gave in your last message? It would be very interesting to have it to see which variable is actually unfixed.

    Cheers,

     

    Renaud


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: IloSolution::getValue - saved domain not bound

    Posted 08/17/18 04:28 AM

    Originally posted by: rdumeur


    Dear DeFearsen,

    I tried to replicate the problem using your code and importing a model, and I have no trouble dumping all the variables.

    I have attached the code of the Bug.java program that you can launch with an CPO file path as first argument.

    It'll start the thread, abort it, store a solution and display the variables in both the solver and solution.

    Could you please try it with the .cpo file that you can create by calling exportModel on the CP solver, once your model is created?

    I hope this helps.

     

    Cheers

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 6.  Re: IloSolution::getValue - saved domain not bound

    Posted 08/17/18 05:55 AM

    Originally posted by: rdumeur


    Dear DeFersen,

    I was thinking about something. It might be better to invoke Thread.join() instead of interrupt(). 

    This will wait until the thread exits after the abort.

    Cheers,

     

    Edit: and you should try invoking join() before invoking 'store' on the solution.

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 7.  Re: IloSolution::getValue - saved domain not bound

    Posted 08/17/18 06:46 AM

    Originally posted by: DeFersen


    Hi,

     

    It was indeed that ! So i'll now use Thread.join() instead of Thread.interrupt(), and i'll going back to the Thread...

    Thanks a lot for the time spent to my problem !

    Best regards,

     

    DeFersen.


    #DecisionOptimization
    #OPLusingCPOptimizer