Skip to content

Commit ce402d6

Browse files
authored
[docs] better clarify variable bound on LHS error (#2747)
1 parent d418555 commit ce402d6

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

docs/src/manual/variables.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,20 @@ x_fixed
126126
In the above examples, `x_free` represents an unbounded optimization variable,
127127
`x_lower` represents an optimization variable with a lower bound and so forth.
128128

129-
!!! note
129+
!!! warning
130130
When creating a variable with only a lower-bound or an upper-bound, and the
131-
value of the bound is not a numeric literal, the name of the variable must appear on the
132-
left-hand side. Putting the name on the right-hand side will result in an
133-
error. For example:
131+
value of the bound is not a numeric literal (e.g., `1` or `1.0`), the name
132+
of the variable must appear on the left-hand side. Putting the name on the
133+
right-hand side will result in an error. For example to create a variable
134+
`x`:
134135
```julia
135-
@variable(model, 1 <= x) # works
136136
a = 1
137-
@variable(model, a <= x) # errors
138-
@variable(model, x >= a) # works
137+
@variable(model, x >= 1) # ✓ Okay
138+
@variable(model, 1.0 <= x) # ✓ Okay
139+
@variable(model, x >= a) # ✓ Okay
140+
@variable(model, a <= x) # × Not okay
141+
@variable(model, x >= 1 / 2) # ✓ Okay
142+
@variable(model, 1 / 2 <= x) # × Not okay
139143
```
140144

141145
### Check if a variable bound exists

0 commit comments

Comments
 (0)