Skip to content

floating point equality check #6

Description

@johnkolen

In Simplex#update_solution, there is a float/integer equality check that fails occasionally:

  def update_solution
    0.upto(@num_vars - 1) {|i| @x[i] = 0 }

    @basic_vars.each do |basic_var|
      row_with_1 = row_indices.detect do |row_ix|
        @a[row_ix][basic_var] == 1
      end
      @x[basic_var] = @b[row_with_1]
    end
  end

The failure occurs when the coefficient for a basic variable is very close to 1 (e.g. 0.9999999999999). I've monkey patched mine with an epsilon check and it works as expected.
Note, it will still throw an error if it can't find any rows. I haven't dug into the code to see if it's possible.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions