Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Counting all LP feasible solutions

    Posted Sun July 19, 2020 07:58 AM
    Dear community team, 

    I am trying to count all feasible (basic) solutions of a specific system of equations which describes in this link. Also, I saw this question and its answers related to my subject. 
    Let's say, there is a convex polyhedron as a system of equations. I have tried to use SCIP for that but in the case of the LP, it cannot enumerate multiple solutions. I know that there is a specific cutting plane method to do that but, in this case, and what mentioned in this link, the problems have an objective function. 
    I was wondering if, how can we count all feasible (basic) solutions of such system by CPLEX? (Java or OPL would be preferred)


    ------------------------------
    Regards
    A.Omidi
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Counting all LP feasible solutions

    Posted Mon July 20, 2020 12:19 AM
    Would a software like polymake do you what you want to do?

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 3.  RE: Counting all LP feasible solutions

    Posted Mon July 20, 2020 01:19 AM
    Dear Daniel,

    Many thanks for your response. It is so interesting.
    I would like to know, is there any way to get such information from CPLEX?

    ------------------------------
    Abbas Omidi
    ------------------------------



  • 4.  RE: Counting all LP feasible solutions

    Posted Mon July 20, 2020 02:39 AM
    Hi,

    through flow control you could enumerate solutions and make sure solutions are not too close from each other.

    sub.mod

    float dist=1;
    
    dvar float x in 0..2;
    dvar float y in 0..2;
    
    tuple point
    {
      float x;
      float y;
    }
    
    {point} solutions=...;
    
    subject to
    {
      forall(s in solutions) abs(x-s.x)+abs(y-s.y)>=dist;
    }
    
    execute
    {
      writeln("x,y = ",x,",",y);
    }​


    and then main.mod

    tuple point
    {
      float x;
      float y;
    }
    
    {point} solutions={};
    
    
        main {
          
          var nbsol=0;
          var source = new IloOplModelSource("sub.mod");
          var cplex = new IloCplex();
          var def = new IloOplModelDefinition(source);
         
         var stop=0;
          while (stop==0)
          {
          var opl = new IloOplModel(def,cplex);
            
          var data2= new IloOplDataElements();
         
        data2.solutions=thisOplModel.solutions;
        
          opl.addDataSource(data2);
          opl.generate();
    
          if (cplex.solve()) {
             opl.postProcess();
             nbsol++;
             thisOplModel.solutions.add(opl.x.solutionValue,opl.y.solutionValue);
          } else {
             writeln("No more solution");
             writeln("nb solutions = ",nbsol);
             stop=1;
          }
        data2.end();
         opl.end();
         
         
        }  
         
        }
    


    then if you run main.mod you ll get

    x,y = 0,0
    x,y = 2,2
    x,y = 1,0
    x,y = 1,1
    x,y = 2,1
    x,y = 1.5,1.5
    x,y = 0.5,0.5
    x,y = 2.000000165e-09,0.999999998
    x,y = 1.5,0.5
    x,y = 1.000000004,1.999999996
    x,y = 0.5,1.500000008
    x,y = 2,0
    x,y = 0,2
    No more solution
    nb solutions = 13


    regards



    ------------------------------
    ALEX FLEISCHER
    ------------------------------



  • 5.  RE: Counting all LP feasible solutions

    Posted Mon July 20, 2020 07:20 AM
    Dear Alex,

    Thanks so much for your reply.
    Would you sure this method can enumerate all basic feasible solution (BSF)? it seems to enumerate all feasible solutions.

    ------------------------------
    Abbas Omidi
    ------------------------------



  • 6.  RE: Counting all LP feasible solutions

    Posted Mon July 20, 2020 07:59 AM
    Edited by System Admin Fri January 20, 2023 04:33 PM
    Indeed, I addressed the question that was in the title:

    Counting all LP feasible solutions



    ------------------------------
    ALEX FLEISCHER
    ------------------------------



  • 7.  RE: Counting all LP feasible solutions

    Posted Tue July 21, 2020 12:30 AM
    Edited by System Admin Fri January 20, 2023 04:14 PM
    Dear Alex,
    Thanks so much. It seems I shall define the title better. Sorry about that.  
    AFAIK, finding all feasible solution of an LP is a bit complicated and may not be possible using an LP solver. Would you say please, is there the same way to get these results using CP optimizer? if so, is it possible for medium or large scale LP model?

    ------------------------------
    Regards
    Abbas Omidi
    ------------------------------



  • 8.  RE: Counting all LP feasible solutions

    Posted Tue July 21, 2020 02:43 AM
    Hi,

    dvar float x in 0..2;
    dvar float y in 0..2;
    
    subject to
    {
    }​

    can give infinity of solutions and that s why I added a distance constraint like do not give me a solution too close from a previous solution.

    With MIP you can enumerate with solution pools.

    With CP, you could have a look at Get several solutions with Constraint Programming

    in https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/

    regards



    ------------------------------
    ALEX FLEISCHER
    ------------------------------



  • 9.  RE: Counting all LP feasible solutions

    Posted Tue July 21, 2020 03:58 PM
    Dear Alex,
    Thanks so much for your useful links. 

    Regards

    ------------------------------
    Abbas Omidi
    ------------------------------