Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

floating point equality check #6

Open
johnkolen opened this issue Jan 21, 2022 · 0 comments
Open

floating point equality check #6

johnkolen opened this issue Jan 21, 2022 · 0 comments

Comments

@johnkolen
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant