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

SimplexSolver not working as expected 2

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.1
    • Labels:
      None
    • Environment:

      Java 1.6.0_13 on Windows XP 32-bit

      Description

      SimplexSolver didn't find the optimal solution.

      Program for Lpsolve:
      =====================
      /* Objective function */
      max: 7 a 3 b;

      /* Constraints */
      R1: +3 a -5 c <= 0;
      R2: +2 a -5 d <= 0;
      R3: +2 b -5 c <= 0;
      R4: +3 b -5 d <= 0;
      R5: +3 a +2 b <= 5;
      R6: +2 a +3 b <= 5;

      /* Variable bounds */
      a <= 1;
      b <= 1;
      =====================
      Results(correct): a = 1, b = 1, value = 10

      Program for SimplexSolve:
      =====================
      LinearObjectiveFunction kritFcia = new LinearObjectiveFunction(new double[]

      {7, 3, 0, 0}

      , 0);
      Collection<LinearConstraint> podmienky = new ArrayList<LinearConstraint>();
      podmienky.add(new LinearConstraint(new double[]

      {1, 0, 0, 0}

      , Relationship.LEQ, 1));
      podmienky.add(new LinearConstraint(new double[]

      {0, 1, 0, 0}

      , Relationship.LEQ, 1));
      podmienky.add(new LinearConstraint(new double[]

      {3, 0, -5, 0}

      , Relationship.LEQ, 0));
      podmienky.add(new LinearConstraint(new double[]

      {2, 0, 0, -5}

      , Relationship.LEQ, 0));
      podmienky.add(new LinearConstraint(new double[]

      {0, 2, -5, 0}

      , Relationship.LEQ, 0));
      podmienky.add(new LinearConstraint(new double[]

      {0, 3, 0, -5}

      , Relationship.LEQ, 0));
      podmienky.add(new LinearConstraint(new double[]

      {3, 2, 0, 0}

      , Relationship.LEQ, 5));
      podmienky.add(new LinearConstraint(new double[]

      {2, 3, 0, 0}

      , Relationship.LEQ, 5));
      SimplexSolver solver = new SimplexSolver();
      RealPointValuePair result = solver.optimize(kritFcia, podmienky, GoalType.MAXIMIZE, true);
      =====================
      Results(incorrect): a = 1, b = 0.5, value = 8.5

      P.S. I used the latest software from the repository (including MATH-286 fix).

        Attachments

        1. SimplexTableau.patch
          2 kB
          Benjamin McCann
        2. SimplexSolverTest.patch
          3 kB
          Benjamin McCann
        3. SimplexSolver.patch
          0.8 kB
          Benjamin McCann

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              kefa Stefan Radacovsky
            • Votes:
              0 Vote for this issue
              Watchers:
              1 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