Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-299

SimplexSolver returns no feasible solution

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0
    • 2.1
    • None
    • None
    • Windows XP commons Math 2.0 jre 1.6.0.16

    Description

      I am trying to optimize this:

      maximize: v

      v <= a1*p1 + a2*p2 + a3*p3 + a4*p4
      v <= b1*p1 + b2*p2 + b3*p3 + b4*p4
      v <= c1*p1 + c2*p2 + c3*p3 + c4*p4
      v <= d1*p1 + d2*p2 + d3*p3 + d4*p4

      p1 + p2 + p3 + p4 = 1

      where a1-d4 are constant specified below by the code (i didn't want to copy and paste them up here. you can look below to see what they are in the objective function).

      LinearObjectiveFunction f = new LinearObjectiveFunction(
      new double[]

      { 1, 0, 0, 0, 0}

      , 0 );
      Collection<LinearConstraint> constraints = new ArrayList<LinearConstraint> ();

      constraints.add(new LinearConstraint(new double[]

      { -1, 1.7316145027890766, 1.3584341412980305, 0.9305633063383639, 1.687117394945513 }

      ,
      Relationship.GEQ, 0));

      constraints.add(new LinearConstraint(new double[]

      { -1, 0.6617060079461883, 1.4862459822191323, 0.7692647272328988, 0.7329140944025636 }

      ,
      Relationship.GEQ, 0));

      constraints.add(new LinearConstraint(new double[]

      { -1, 1.3255966888982322, 286.21607948837584, 1.135907611434458, 0.9803367440299271 }

      ,
      Relationship.GEQ, 0));

      constraints.add(new LinearConstraint(new double[]

      { -1, 0.5428682596573682, 1.5745685116536952, 1.4834419186882808, 1.2884923232048968 }

      ,
      Relationship.GEQ, 0));

      constraints.add(new LinearConstraint(new double[]

      {0, 1, 1, 1, 1}

      ,
      Relationship.EQ, 1));
      RealPointValuePair solution = null;
      try

      { solution = new SimplexSolver().optimize(f, constraints, GoalType.MAXIMIZE, true); }

      catch (OptimizationException e)

      { e.printStackTrace(); }

      I get this error back from the SimplexSolver.

      org.apache.commons.math.optimization.linear.NoFeasibleSolutionException: no feasible solution
      at org.apache.commons.math.optimization.linear.SimplexSolver.solvePhase1(SimplexSolver.java:177)
      at org.apache.commons.math.optimization.linear.SimplexSolver.doOptimize(SimplexSolver.java:187)
      at org.apache.commons.math.optimization.linear.AbstractLinearOptimizer.optimize(AbstractLinearOptimizer.java:106)
      at Runner.main(Runner.java:101)

      One interesting thing to note is that if you round all the numbers to the nearest 100's place, it works. If you keep it with the floating point precision shown here, it doesn't.

      Attachments

        Activity

          People

            Unassigned Unassigned
            davidwilcox David
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 8h
                8h
                Remaining:
                Remaining Estimate - 8h
                8h
                Logged:
                Time Spent - Not Specified
                Not Specified