Decision Optimization

Decision Optimization

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

 View Only
  • 1.  cplex c++ concert technology

    Posted Tue January 05, 2016 01:04 AM

    Originally posted by: Girish Dey


    I am solving one problem iteratively in cplex c++ concert technology. One of my constaints set is

    
    
    for(int j = 0; j <6; j++){
               model.add(Interdicted[j] <= 1 - Fortified[j]);
     }
    
    

    In every iteration, the binary array Fortified is input and Interdicted is binary array decision variable. The constraints ensure that the facility which is fortified can not be interdicted. After some iteration, I make my fortified to initial value to resolve the problem with different input. But it is not interdicting those facilities which is earlier fortified.How to overcome this problem.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: cplex c++ concert technology

    Posted Tue January 05, 2016 02:57 AM

    Are you saying that you get a solution with Interdicted[j]=1 although Fortified[j]=1 (for a j in [0,6[)? That should of course not happen.

    Or is the problem that your Fortified[] array is not setup correctly? Could it be that once Fortified[j]=1 in any iteration you just have to set the upper bound of Interdicted[j] to 0?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: cplex c++ concert technology

    Posted Tue January 05, 2016 07:46 AM

    Originally posted by: Girish Dey


    please tell me how to clear the solution of one iteration (Interdicted[j]), before going to the next iteration. I think this solution of  one iteration is preventing it to become the solution of another iteration. thanks 


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: cplex c++ concert technology

    Posted Tue January 05, 2016 10:43 AM

    What do you mean by "clear the solution of one iteration"? If you change the model (by adding constraints for example) then CPLEX will automatically drop the current solution and resolve the model from scratch if you invoke solve() again. If you want to remove the constraints that you added after a previous iteration then IloModel::remove() is what you need to invoke for the constraints you want to remove.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: cplex c++ concert technology

    Posted Wed January 06, 2016 12:08 AM

    Originally posted by: Girish Dey


    Dear  Sir,

                     I am aware of what you are telling. Please have a look on the attached image.  At the root  node the problem is  solved without any fortification(protection) and the solution is Interdiction set (I) .Basing on the solution of root node facility is fortified and the aforementioned constraint tells that facility which is fortified can not be interdicted for child node. I am doing this with recursion and backtracking.  I am getting correct result while moving in the right direction and left direction separately. but  if I move left first and than backtrack to right  than result of corresponding node is not matching(some become infeasible). One thing I observed that  the facility which is fortified in the left is not coming in the solution of right side. But by backtracking  the input fortification what i am giving at every node is correct. I am not understanding where is the problem.      Thanks

                  

         

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: cplex c++ concert technology

    Posted Wed January 06, 2016 03:02 AM

    I'm afraid that you have to debug that on your own. I can only guess what may be wrong in your code.

    My wild guess is that something is wrong with your backtracking. Maybe you are not correctly undoing the effect of fortification. I suggest you dump the model (IloCplex::exportModel) to an LP file at each node and double check that it looks as expected. If it does not look as expected then you should immediately see what is wrong and should be able to adapt your code appropriately.


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: cplex c++ concert technology

    Posted Wed January 06, 2016 07:18 AM

    Originally posted by: Girish Dey


    Thanks for your help sir.  I am able to get the error. Trying to rectify it . If you  give some suggestions , I will be grateful to you. To do recursion, I have written a separate recursive function. The modification to the model I have made and add that constraint  in that recursive function only. So in every  iteration that constraints  set is replicating. I am facing difficulty to do recursion within main().


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: cplex c++ concert technology

    Posted Wed January 06, 2016 09:35 AM

    Can you please describe in much more detail what your actual problem is? "difficulty to do recursion within main()" is very vague and is not clear what is causing trouble.


    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: cplex c++ concert technology

    Posted Wed January 06, 2016 10:45 PM

    Originally posted by: Girish Dey


     Sir,  I apologise for my wrong questions. For recursion, I have written a separate function. In that function first I have to remove that constraint  which I have written

             for (int j =0; j < NbLocations; j++){
                      model.remove(Interdicted[j] <= 1 - Fortified[j]);} 

    After that I made change to my Fortified array and again add the same set of constraints by model.add().  The problem is this model.remove() is not working. So in every itearation the the constraints due to model.add() is multiplying. I have also tried this  by IloRangeArray protection(env). In this case model.remove(protection) is working but after modification to Fortified array model.add(protection) is not taking the modification made to fortified array. Thanks


                    


    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: cplex c++ concert technology

    Posted Thu January 07, 2016 03:59 AM

    model.remove(Interdicted[j] <= 1 - Fortified[j]);

    does not achieve what you intend to do. It will first create a new constraint and then attempt to remove that constraint from the model. Since the newly created constraint was never added to the model this is just a nop.

    Your recursive function should look something like this:

    void recursive_function(...) {
       IloConstraintArray tmp(env);
       for (int j = 0; j < NbLocations; j++)
          tmp.add(Interdiced[j] <= 1 - Fortified[j]);
       model.add(tmp);
       ... // solve (and potentially recurse
       // Remove the constraints after recursion
       model.remove(tmp);
       tmp.endElements();
       tmp.end();

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: cplex c++ concert technology

    Posted Thu January 07, 2016 11:46 AM

    Originally posted by: Girish Dey


    Thanks a lot sir. it  works


    #CPLEXOptimizers
    #DecisionOptimization