Decision Optimization

Decision Optimization

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


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

How should I get different solutions to one problem?

  • 1.  How should I get different solutions to one problem?

    Posted 12/12/08 07:29 PM

    Originally posted by: SystemAdmin


    [cplex_ma said:]

    Hi all,
    I am using Binary Integer programming to solve my problem  in CPLEX.  Consider that I have two components:
    P={p1,p2,p3,…,pm}
    R={r1,r2,r3,….,rn}
    According to the constraints I have,  the program should assign three from R set to assign to each of the components in P in order to maximize my objective function, i.e.:
    P1: r1,r2,r4
    P2: r4,r5,r7
    ….
    There might be multiple solutions to one problem.  For example, the following assignment might lead to the maximization of the objective function:
    P1: r3,r4,r7
    P2: r5,r6,r8
    …

    I am wondering how I can get different solutions to one problem (e.g. in my case different assignments for each component in P set) . Is there any way to get it from the CPLEX code (I am using CPLEX 11.1 with Java) if not, is there any other way to get different solutions with the same value for objective function?
    Thanks,


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: How should I get different solutions to one problem?

    Posted 12/12/08 08:21 PM

    Originally posted by: SystemAdmin


    [jfk said:]

    hello there,
    it's a pity that you are not using OPL... In OPL you have access to CPO by which you could get the perfect solution for your problem without much work
    1. since your problem is a pure integer one you can switch to CPO (at the beginning of your OPL code you have to put "using CP") - CPO stands for Constraint Programing Optimizer
    you can write script code like

    main {
      var model = new IloOplRunConfiguration("mySRQ-prb1.mod");
      model.oplModel.generate();
      model.cp.startNewSearch();

      var k=1;
      while (model.cp.next()) { //this will return false when there is no more solution
          writeln(k,"th solution", ...); //you may want to print an individual solution
          k++;             
      };
      model.cp.endSearch();
      model.end();
    }

    which actually print all the solution. You could have a first run in OPL to optimize with a given goal function, then take that value, fix it, and then count down all the possible solutions.

    2. OK, then let's see the CPLEX solution but still with OPL: the solution pool feature
    create a .ops (setting) file
    attach it to your run-config
    open the .ops and find the solution pool tab Mathematical Programming>Mixed Integer Programming>Solution Pool and check the "populate solution pool" box, and run...

    3. without OPL, you have to code by yourself, but still the CPLEX solution pool feature is available. Take a look at
    User's Manual > ILOG CPLEX User's Manual > Discrete optimization  > Solution pool: generating and keeping multiple solutions > Enumerating all solutions > How to enumerate all solutions
    it takes you fairly straightforwardly through how to enumerate all the solutions

    Sorry, no.1-2 probably sounded like I teased you, but since you posted your question at ILOG OPL(CPLEX) you have to endure stuff about OPL... :-)
    well, good luck with no.3!
    cheers

    #DecisionOptimization
    #OPLusingCPLEXOptimizer