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

[docs] add warning to docs about tolerances in Bin and Int variables #3794

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/src/manual/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,14 @@ julia> @variable(model, x, Bin)
x
```

!!! warning
Solvers use tolerances to decide whether a variable satisfies the binary
constraint. Thus, the true feasible region is
$[-\varepsilon, \varepsilon] \cup [1 - \varepsilon, 1 + \varepsilon]$,
where $\varepsilon$ is solver-specific, but typically `1e-6`. As a result,
you should expect the `value(x)` of a `Bin` variable to sometimes take a
value like `-0.0`, `1e-8`, or `0.999999`.

Check if a variable is binary using [`is_binary`](@ref):
```jldoctest variables_binary
julia> is_binary(x)
Expand Down Expand Up @@ -604,6 +612,14 @@ julia> @variable(model, x, Int)
x
```

!!! warning
Solvers use tolerances to decide whether a variable satisfies the integer
constraint. Thus, the true feasible region is
$\cup_{z \in \mathbb{Z}}[z - \varepsilon, z + \varepsilon]$,
where $\varepsilon$ is solver-specific, but typically `1e-6`. As a result,
you should expect the `value(x)` of an `Int` variable to sometimes take a
value like `1e-8`, or `2.999999`.

Check if a variable is integer using [`is_integer`](@ref):
```jldoctest variables_integer
julia> is_integer(x)
Expand Down
Loading