Skip to content

Commit

Permalink
Update expressions.md
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Oct 23, 2024
1 parent ca0afb8 commit 755e513
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions docs/src/manual/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,8 @@ julia> add_to_expression!(ex, 1.0, y)
2 x + y - 1
```

In the next example, we present an efficient way to combine
previously created expressions.
As highlighted above, the first expression is modified in-place
while the second expression remains the same.
[`add_to_expression!`](@ref) can also be used to sum expressions
in-place:

```jldoctest
julia> model = Model();
Expand All @@ -139,10 +137,10 @@ julia> @variable(model, x[1:2])
x[1]
x[2]
julia> ex1 = @expression(model, sum(x[1:2]))
julia> @expression(model, ex1, sum(x))
x[1] + x[2]
julia> ex2 = @expression(model, 2 * sum(x[1:2]))
julia> @expression(model, ex2, 2 * sum(x))
2 x[1] + 2 x[2]
julia> add_to_expression!(ex1, ex2)
Expand Down

0 comments on commit 755e513

Please sign in to comment.