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

Confusion between values and indices #56

Closed
matbesancon opened this issue Jan 12, 2020 · 5 comments
Closed

Confusion between values and indices #56

matbesancon opened this issue Jan 12, 2020 · 5 comments

Comments

@matbesancon
Copy link
Contributor

It might be due to the solver being tested first on Sudoku instances. When testing the solver on problems with non-integer coefficients, some errors occur, which can be fixed by widening the types.

However, in some places of the code, the value and index spaces are mixed up. An example with the has function:

function has(v::CS.Variable, x::Int)
    if x > v.max || x < v.min
        return false
    end
    ind = v.indices[x + v.offset]
    return v.first_ptr <= ind <= v.last_ptr
end

In the first part, x is used as a value, checking if the variable is between min and max. But in the second part, it is used as an index as x + v.offset. Using values and indices interchangeably will lead to bugs later (what if you have infinite, if you have float coefficients, etc).

@Wikunia
Copy link
Owner

Wikunia commented Jan 12, 2020

Floating coefficients shouldn't affect the discrete variables, right? I think for non discrete or unbounded variables (which don't exist yet) a different variable type might need to exist.
Not sure how to rewrite it otherwise without loosing performance on these operations.

@matbesancon
Copy link
Contributor Author

matbesancon commented Jan 12, 2020 via email

@matbesancon
Copy link
Contributor Author

The problem is explained in more detail in https://en.wikipedia.org/wiki/Independent_set_(graph_theory)

@Wikunia
Copy link
Owner

Wikunia commented Jan 16, 2020

I think this can be closed if I take care that only discrete variables get checked here, right?

@matbesancon
Copy link
Contributor Author

matbesancon commented Jan 16, 2020 via email

@Wikunia Wikunia closed this as completed Jan 16, 2020
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

2 participants