From b1c835d5845a2ab701b5aadf070c9296fde755b5 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 26 May 2023 05:16:40 +1200 Subject: [PATCH] Fix printing in JuMP v1.11.1 (#314) * Fix printing in JuMP v1.11.1 * Fix for Julia v1.9 by adding check_belongs_to_model * Generalize tests * Update doc tests * more doc test fixes --------- Co-authored-by: pulsipher --- docs/Project.toml | 4 +- docs/src/guide/constraint.md | 40 +++++++------- docs/src/guide/derivative.md | 14 ++--- docs/src/guide/expression.md | 10 ++-- docs/src/guide/optimize.md | 30 +++++------ docs/src/guide/transcribe.md | 80 +++++++++++++-------------- docs/src/guide/variable.md | 2 +- docs/src/tutorials/quick_start.md | 26 ++++----- test/show.jl | 90 +++++++++++++++---------------- 9 files changed, 149 insertions(+), 147 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index f13d1f53..36ec0eba 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -3,6 +3,7 @@ HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" InfiniteOpt = "20393b10-9daf-11e9-18c9-8db751c92c57" +JuMP = "4076af6c-e467-56ae-b986-b466b2749572" Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9" Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" @@ -15,8 +16,9 @@ HiGHS = "1" Distributions = "0.25" Documenter = "0.27" InfiniteOpt = "0.5" +JuMP = "^1.11.1" Ipopt = "1" -Literate = "2.9" +Literate = "2.14" Plots = "1" julia = "1.6" SpecialFunctions = "2" diff --git a/docs/src/guide/constraint.md b/docs/src/guide/constraint.md index fe5d4391..08aa9834 100644 --- a/docs/src/guide/constraint.md +++ b/docs/src/guide/constraint.md @@ -55,7 +55,7 @@ the constraint using `@constraint`: ```jldoctest constrs julia> @constraint(model, c1, sum(z[i]^2 for i = 1:2) + 2ya <= 0) -c1 : z[1]² + z[2]² + 2 ya(t, x) ≤ 0.0, ∀ t ∈ [0, 10], x[1] ∈ [-2, 2], x[2] ∈ [-2, 2] +c1 : z[1]² + z[2]² + 2 ya(t, x) ≤ 0, ∀ t ∈ [0, 10], x[1] ∈ [-2, 2], x[2] ∈ [-2, 2] ``` Thus, we added an infinite constraint (which infinite with respect to `t` and `x`) to `model` and stored the corresponding constraint reference to `c1`. Note that @@ -75,8 +75,8 @@ let's define ``3z_i - 14 = 0, \ \forall i \in \{1,2\}``: ```jldoctest constrs julia> @constraint(model, c2[i = 1:2], 3z[i] - 14 == 0) 2-element Vector{InfOptConstraintRef}: - c2[1] : 3 z[1] = 14.0 - c2[2] : 3 z[2] = 14.0 + c2[1] : 3 z[1] = 14 + c2[2] : 3 z[2] = 14 ``` Thus, we added two constraints to `model` and stored a vector of the corresponding constraint references to the `Julia` variable `c2`. To learn more about building @@ -113,7 +113,7 @@ These types of constraints are defined adding [`DomainRestrictions`](@ref). For example, let's add the initial condition ``y_b(0) = 0``: ```jldoctest constrs julia> @constraint(model, initial, yb == 0, DomainRestrictions(t => 0)) -initial : yb(t) = 0.0, ∀ t = 0 +initial : yb(t) = 0, ∀ t = 0 ``` Thus, we have added a constraint to `model` defined over the sub-domain ``t = 0`` in accordance with the initial condition. @@ -124,7 +124,7 @@ in accordance with the initial condition. can be expressed: ```jldoctest constrs julia> @constraint(model, yb(0) == 0) - yb(0) = 0.0 + yb(0) = 0 ``` More complex sub-domains can be specified by simply adding more restrictions. To @@ -132,7 +132,7 @@ illustrate this, let's define the constraint ``2y_b^2(t, x) + z_1 \geq 3, \ \forall t = 0, \ x \in [-1, 1]^2``: ```jldoctest constrs julia> @constraint(model, 2ya^2 + z[1] >= 3, DomainRestrictions(t => 0, x => [-1, 1])) -2 ya(t, x)² + z[1] ≥ 3.0, ∀ t = 0, x[1] ∈ [-1, 1], x[2] ∈ [-1, 1] +2 ya(t, x)² + z[1] ≥ 3, ∀ t = 0, x[1] ∈ [-1, 1], x[2] ∈ [-1, 1] ``` Now we have added constraints to our model, and it is ready to be solved! @@ -190,7 +190,7 @@ Now the built constraint object can be added to the infinite model via `c3` (note that adding a name is optional): ```jldoctest constrs julia> cref = add_constraint(model, constr, "c3") -c3 : -yb(t)² + 3 ya(t, x) ≤ 0.0, ∀ t ∈ [0, 10], x[1] ∈ [-2, 2], x[2] ∈ [-2, 2] +c3 : -yb(t)² + 3 ya(t, x) ≤ 0, ∀ t ∈ [0, 10], x[1] ∈ [-2, 2], x[2] ∈ [-2, 2] ``` Thus, we have made our constraint and added it `model` and now have a constraint @@ -213,8 +213,8 @@ below (notice this is equivalent to looping over individual `@constraint` calls) ```jldoctest constrs julia> crefs = @constraint(model, [i = 1:2], 2z[i] - yb == 0) 2-element Vector{InfOptConstraintRef}: - 2 z[1] - yb(t) = 0.0, ∀ t ∈ [0, 10] - 2 z[2] - yb(t) = 0.0, ∀ t ∈ [0, 10] + 2 z[1] - yb(t) = 0, ∀ t ∈ [0, 10] + 2 z[2] - yb(t) = 0, ∀ t ∈ [0, 10] julia> crefs = Vector{InfOptConstraintRef}(undef, 2); @@ -224,8 +224,8 @@ julia> for i = 1:2 julia> crefs 2-element Vector{InfOptConstraintRef}: - 2 z[1] - yb(t) = 0.0, ∀ t ∈ [0, 10] - 2 z[2] - yb(t) = 0.0, ∀ t ∈ [0, 10] + 2 z[1] - yb(t) = 0, ∀ t ∈ [0, 10] + 2 z[2] - yb(t) = 0, ∀ t ∈ [0, 10] ``` Please refer to [`JuMP`'s constraint container documentation](https://jump.dev/JuMP.jl/v1/manual/constraints/#Constraint-containers) @@ -265,8 +265,8 @@ restrict the infinite domain of ``x_i`` to be ``[0, 1]``: ```jldoctest constrs julia> @constraint(model, [i = 1:2], ya^2 + z[i] <= 1, DomainRestrictions(x[i] => [0, 1])) 2-element Vector{InfOptConstraintRef}: - ya(t, x)² + z[1] ≤ 1.0, ∀ t ∈ [0, 10], x[1] ∈ [0, 1], x[2] ∈ [-2, 2] - ya(t, x)² + z[2] ≤ 1.0, ∀ t ∈ [0, 10], x[1] ∈ [-2, 2], x[2] ∈ [0, 1] + ya(t, x)² + z[1] ≤ 1, ∀ t ∈ [0, 10], x[1] ∈ [0, 1], x[2] ∈ [-2, 2] + ya(t, x)² + z[2] ≤ 1, ∀ t ∈ [0, 10], x[1] ∈ [-2, 2], x[2] ∈ [0, 1] ``` !!! tip @@ -307,7 +307,7 @@ if only the name is known and its name is unique. For example, let's extract the reference for `"c1"`: ```jldoctest constrs julia> cref = constraint_by_name(model, "c1") -c1 : z[1]² + z[2]² + 2 ya(t, x) ≤ 0.0, ∀ t ∈ [0, 10], x[1] ∈ [-2, 2], x[2] ∈ [-2, 2] +c1 : z[1]² + z[2]² + 2 ya(t, x) ≤ 0, ∀ t ∈ [0, 10], x[1] ∈ [-2, 2], x[2] ∈ [-2, 2] ``` ### Domain Restrictions @@ -340,7 +340,7 @@ particular variable reference, respectively. Let's employ the above example to illustrate this: ```jldoctest constrs julia> @constraint(model, constr, 2yb + 3yb - 2 <= 1 + z[1]) -constr : 5 yb(t) - z[1] ≤ 3.0, ∀ t ∈ [0, 10] +constr : 5 yb(t) - z[1] ≤ 3, ∀ t ∈ [0, 10] julia> normalized_rhs(constr) 3.0 @@ -412,7 +412,7 @@ let's update the name of `initial` to `"init_cond"`: julia> set_name(initial, "init_cond") julia> initial -init_cond : yb(t) = 0.0, ∀ t = 0 +init_cond : yb(t) = 0, ∀ t = 0 ``` We can also update the normalized right hand side constant value or normalized @@ -426,7 +426,7 @@ julia> set_normalized_rhs(constr, -1) julia> set_normalized_coefficient(constr, yb, 2.5) julia> constr -constr : 2.5 yb(t) - z[1] ≤ -1.0, ∀ t ∈ [0, 10] +constr : 2.5 yb(t) - z[1] ≤ -1, ∀ t ∈ [0, 10] ``` !!! note @@ -453,7 +453,7 @@ First, domain restrictions can be added to a constraint via julia> add_domain_restrictions(constr, DomainRestrictions(t => [0, 1])) julia> constr -constr : 2.5 yb(t) - z[1] ≤ -1.0, ∀ t ∈ [0, 1] +constr : 2.5 yb(t) - z[1] ≤ -1, ∀ t ∈ [0, 1] ``` In similar manner, [`set_domain_restrictions`](@ref) can be employed to specify @@ -463,7 +463,7 @@ follows the same syntax, so let's use it to change the bounds on `t` to ``t = 0` julia> set_domain_restrictions(constr, DomainRestrictions(t => 0), force = true) julia> constr -constr : 2.5 yb(t) - z[1] ≤ -1.0, ∀ t = 0 +constr : 2.5 yb(t) - z[1] ≤ -1, ∀ t = 0 ``` Finally, constraint restrictions can be deleted via @@ -473,5 +473,5 @@ associated with our example: julia> delete_domain_restrictions(constr) julia> constr -constr : 2.5 yb(t) - z[1] ≤ -1.0, ∀ t ∈ [0, 10] +constr : 2.5 yb(t) - z[1] ≤ -1, ∀ t ∈ [0, 10] ``` diff --git a/docs/src/guide/derivative.md b/docs/src/guide/derivative.md index 58c51674..f89bb22c 100644 --- a/docs/src/guide/derivative.md +++ b/docs/src/guide/derivative.md @@ -412,8 +412,8 @@ julia> evaluate(d1) julia> derivative_constraints(d1) 2-element Vector{InfOptConstraintRef}: - 5 ∂/∂t[y(t, ξ)](5, ξ) - y(10, ξ) + y(5, ξ) = 0.0, ∀ ξ ~ Uniform - 5 ∂/∂t[y(t, ξ)](0, ξ) - y(5, ξ) + y(0, ξ) = 0.0, ∀ ξ ~ Uniform + 5 ∂/∂t[y(t, ξ)](5, ξ) - y(10, ξ) + y(5, ξ) = 0, ∀ ξ ~ Uniform + 5 ∂/∂t[y(t, ξ)](0, ξ) - y(5, ξ) + y(0, ξ) = 0, ∀ ξ ~ Uniform ``` Note that we made sure `t` had supports first over which we could carry out the evaluation, otherwise an error would have been thrown. Moreover, once the @@ -429,8 +429,8 @@ julia> evaluate_all_derivatives!(model) julia> derivative_constraints(dydt2) 2-element Vector{InfOptConstraintRef}: - 5 dydt2(5, ξ) - ∂/∂t[y(t, ξ)](10, ξ) + ∂/∂t[y(t, ξ)](5, ξ) = 0.0, ∀ ξ ~ Uniform - 5 dydt2(0, ξ) - ∂/∂t[y(t, ξ)](5, ξ) + ∂/∂t[y(t, ξ)](0, ξ) = 0.0, ∀ ξ ~ Uniform + 5 dydt2(5, ξ) - ∂/∂t[y(t, ξ)](10, ξ) + ∂/∂t[y(t, ξ)](5, ξ) = 0, ∀ ξ ~ Uniform + 5 dydt2(0, ξ) - ∂/∂t[y(t, ξ)](5, ξ) + ∂/∂t[y(t, ξ)](0, ξ) = 0, ∀ ξ ~ Uniform ``` Finally, we note that once derivative constraints have been added to the @@ -440,8 +440,8 @@ and a warning will be thrown to indicate such: ```jldoctest deriv_basic julia> derivative_constraints(d1) 2-element Vector{InfOptConstraintRef}: - 5 ∂/∂t[y(t, ξ)](5, ξ) - y(10, ξ) + y(5, ξ) = 0.0, ∀ ξ ~ Uniform - 5 ∂/∂t[y(t, ξ)](0, ξ) - y(5, ξ) + y(0, ξ) = 0.0, ∀ ξ ~ Uniform + 5 ∂/∂t[y(t, ξ)](5, ξ) - y(10, ξ) + y(5, ξ) = 0, ∀ ξ ~ Uniform + 5 ∂/∂t[y(t, ξ)](0, ξ) - y(5, ξ) + y(0, ξ) = 0, ∀ ξ ~ Uniform julia> add_supports(t, 0.2) ┌ Warning: Support/method changes will invalidate existing derivative evaluation constraints that have been added to the InfiniteModel. Thus, these are being deleted. @@ -512,7 +512,7 @@ julia> lower_bound(dydt2) 1.0 julia> LowerBoundRef(dydt2) -dydt2(t, ξ) ≥ 1.0, ∀ t ∈ [0, 10], ξ ~ Uniform +dydt2(t, ξ) ≥ 1, ∀ t ∈ [0, 10], ξ ~ Uniform julia> has_upper_bound(dydt2) false diff --git a/docs/src/guide/expression.md b/docs/src/guide/expression.md index 14bca948..ae1dbdb5 100644 --- a/docs/src/guide/expression.md +++ b/docs/src/guide/expression.md @@ -55,7 +55,7 @@ julia> meas = integral(y - f, t) ∫{t ∈ [0, 10]}[y(t) - f(t)] julia> @constraint(model, y - f <= 0) -y(t) - f(t) ≤ 0.0, ∀ t ∈ [0, 10] +y(t) - f(t) ≤ 0, ∀ t ∈ [0, 10] ``` We can also define parameter functions that depend on multiple infinite parameters even use an anonymous function if preferred: @@ -246,7 +246,7 @@ Notice again that the ordered dictionary preserves the order. x julia> @constraint(model, x == z^2) - -z² + x = 0.0 + -z² + x = 0 julia> expr = @expression(model, z * x + 2) z*x + 2 @@ -316,7 +316,7 @@ julia> @objective(model, Min, ∫(0.3^cos(y^2), t)) ∫{t ∈ [0, 1]}[0.3^cos(y(t)²)] julia> @constraint(model, constr, y^y * sin(y) + sum(y^i for i in 3:4) == 3) -constr : (y(t)^y(t) * sin(y(t)) + y(t)^3 + y(t)^4) - 3 = 0.0, ∀ t ∈ [0, 1] +constr : (y(t)^y(t) * sin(y(t)) + y(t)^3 + y(t)^4) - 3 = 0, ∀ t ∈ [0, 1] ``` !!! note @@ -442,8 +442,8 @@ julia> @variable(model, W[1:2, 1:2]); julia> @constraint(model, W * Q * v .== 0) 2-element Vector{InfOptConstraintRef}: - (0 + (W[1,1]*Q[1,1] + W[1,2]*Q[2,1]) * v[1] + (W[1,1]*Q[1,2] + W[1,2]*Q[2,2]) * v[2]) - 0 == 0.0 - (0 + (W[2,1]*Q[1,1] + W[2,2]*Q[2,1]) * v[1] + (W[2,1]*Q[1,2] + W[2,2]*Q[2,2]) * v[2]) - 0 == 0.0 + (0 + (W[1,1]*Q[1,1] + W[1,2]*Q[2,1]) * v[1] + (W[1,1]*Q[1,2] + W[1,2]*Q[2,2]) * v[2]) - 0 = 0 + (0 + (W[2,1]*Q[1,1] + W[2,2]*Q[2,1]) * v[1] + (W[2,1]*Q[1,2] + W[2,2]*Q[2,2]) * v[2]) - 0 = 0 ``` However, it is important to note that although vector constraints can be diff --git a/docs/src/guide/optimize.md b/docs/src/guide/optimize.md index 45924ecc..f8abeb64 100644 --- a/docs/src/guide/optimize.md +++ b/docs/src/guide/optimize.md @@ -44,11 +44,11 @@ julia> @constraint(model, c2, y(0) == 42); julia> print(model) Min 2 z Subject to - y(t) ≥ 0.0, ∀ t ∈ [0, 10] - z ≥ 0.0 - c1 : z - y(t) ≥ 0.0, ∀ t ∈ [0, 10] - y(0) ≥ 0.0 - c2 : y(0) = 42.0 + y(t) ≥ 0, ∀ t ∈ [0, 10] + z ≥ 0 + c1 : z - y(t) ≥ 0, ∀ t ∈ [0, 10] + y(0) ≥ 0 + c2 : y(0) = 42 ``` Now we optimize the model using `optimize!`: ```jldoctest optimize @@ -141,16 +141,16 @@ Using a `TranscriptionModel` this equivalent to calling ```jldoctest optimize julia> optimizer_model_constraint(c1) # infinite constraint 10-element Vector{ConstraintRef}: - c1(support: 1) : z - y(support: 1) ≥ 0.0 - c1(support: 2) : z - y(support: 2) ≥ 0.0 - c1(support: 3) : z - y(support: 3) ≥ 0.0 - c1(support: 4) : z - y(support: 4) ≥ 0.0 - c1(support: 5) : z - y(support: 5) ≥ 0.0 - c1(support: 6) : z - y(support: 6) ≥ 0.0 - c1(support: 7) : z - y(support: 7) ≥ 0.0 - c1(support: 8) : z - y(support: 8) ≥ 0.0 - c1(support: 9) : z - y(support: 9) ≥ 0.0 - c1(support: 10) : z - y(support: 10) ≥ 0.0 + c1(support: 1) : z - y(support: 1) ≥ 0 + c1(support: 2) : z - y(support: 2) ≥ 0 + c1(support: 3) : z - y(support: 3) ≥ 0 + c1(support: 4) : z - y(support: 4) ≥ 0 + c1(support: 5) : z - y(support: 5) ≥ 0 + c1(support: 6) : z - y(support: 6) ≥ 0 + c1(support: 7) : z - y(support: 7) ≥ 0 + c1(support: 8) : z - y(support: 8) ≥ 0 + c1(support: 9) : z - y(support: 9) ≥ 0 + c1(support: 10) : z - y(support: 10) ≥ 0 ``` We can also query the expressions via [`optimizer_model_expression`](@ref optimizer_model_expression(::JuMP.AbstractJuMPScalar)): diff --git a/docs/src/guide/transcribe.md b/docs/src/guide/transcribe.md index ff2aba85..55c52042 100644 --- a/docs/src/guide/transcribe.md +++ b/docs/src/guide/transcribe.md @@ -50,19 +50,19 @@ julia> @objective(inf_model, Min, 2z + support_sum(y, t)) 2 z + support_sum{t}[y(t)] julia> @constraint(inf_model, initial, y(0) == 1) -initial : y(0) = 1.0 +initial : y(0) = 1 julia> @constraint(inf_model, constr, y^2 - z <= 42) -constr : y(t)² - z ≤ 42.0, ∀ t ∈ [0, 10] +constr : y(t)² - z ≤ 42, ∀ t ∈ [0, 10] julia> print(inf_model) Min 2 z + support_sum{t}[y(t)] Subject to - y(t) ≥ 0.0, ∀ t ∈ [0, 10] + y(t) ≥ 0, ∀ t ∈ [0, 10] z binary - y(0) ≥ 0.0 - initial : y(0) = 1.0 - constr : y(t)² - z ≤ 42.0, ∀ t ∈ [0, 10] + y(0) ≥ 0 + initial : y(0) = 1 + constr : y(t)² - z ≤ 42, ∀ t ∈ [0, 10] ``` Now we can make `JuMP` model containing the transcribed version of `inf_model` via [`build_optimizer_model!`](@ref) and then extract it via @@ -86,13 +86,13 @@ Solver name: No optimizer attached. julia> print(trans_model) Min 2 z + y(support: 1) + y(support: 2) + y(support: 3) Subject to - initial(support: 1) : y(support: 1) = 1.0 - constr(support: 1) : y(support: 1)² - z ≤ 42.0 - constr(support: 2) : y(support: 2)² - z ≤ 42.0 - constr(support: 3) : y(support: 3)² - z ≤ 42.0 - y(support: 1) ≥ 0.0 - y(support: 2) ≥ 0.0 - y(support: 3) ≥ 0.0 + initial(support: 1) : y(support: 1) = 1 + constr(support: 1) : y(support: 1)² - z ≤ 42 + constr(support: 2) : y(support: 2)² - z ≤ 42 + constr(support: 3) : y(support: 3)² - z ≤ 42 + y(support: 1) ≥ 0 + y(support: 2) ≥ 0 + y(support: 3) ≥ 0 z binary ``` !!! note @@ -134,13 +134,13 @@ can be queried via [`transcription_constraint`](@ref) and the associated support and infinite parameters can be found via `supports` and `parameter_refs`: ```jldoctest transcribe julia> transcription_constraint(initial) -initial(support: 1) : y(support: 1) = 1.0 +initial(support: 1) : y(support: 1) = 1 julia> transcription_constraint(constr) 3-element Vector{ConstraintRef}: - constr(support: 1) : y(support: 1)² - z ≤ 42.0 - constr(support: 2) : y(support: 2)² - z ≤ 42.0 - constr(support: 3) : y(support: 3)² - z ≤ 42.0 + constr(support: 1) : y(support: 1)² - z ≤ 42 + constr(support: 2) : y(support: 2)² - z ≤ 42 + constr(support: 3) : y(support: 3)² - z ≤ 42 julia> supports(constr) 3-element Vector{Tuple}: @@ -298,10 +298,10 @@ print(inf_model) # output Min support_sum{t}[y(t)²] Subject to - y(0) = 1.0 - g(0, [x[1], x[2]]) = 0.0, ∀ x[1] ∈ [-1, 1], x[2] ∈ [-1, 1] - support_sum{x}[∂/∂t[g(t, x)]] = 42.0, ∀ t ∈ [0, 10] - y(t)² + 3 g(t, x) ≤ 2.0, ∀ t ∈ [0, 10], x[1] ∈ [-1, 1], x[2] ∈ [-1, 1] + y(0) = 1 + g(0, [x[1], x[2]]) = 0, ∀ x[1] ∈ [-1, 1], x[2] ∈ [-1, 1] + support_sum{x}[∂/∂t[g(t, x)]] = 42, ∀ t ∈ [0, 10] + y(t)² + 3 g(t, x) ≤ 2, ∀ t ∈ [0, 10], x[1] ∈ [-1, 1], x[2] ∈ [-1, 1] ``` Thus, we obtain the infinite problem in `InfiniteOpt`. As previously noted, transcription would be handled automatically behind the scenes when the model is @@ -315,25 +315,25 @@ julia> trans_model = optimizer_model(inf_model); julia> print(trans_model) Min y(support: 1)² + y(support: 2)² Subject to - y(support: 1) = 1.0 - g(support: 1) = 0.0 - g(support: 3) = 0.0 - g(support: 5) = 0.0 - g(support: 7) = 0.0 - ∂/∂t[g(t, x)](support: 1) + ∂/∂t[g(t, x)](support: 3) + ∂/∂t[g(t, x)](support: 5) + ∂/∂t[g(t, x)](support: 7) = 42.0 - ∂/∂t[g(t, x)](support: 2) + ∂/∂t[g(t, x)](support: 4) + ∂/∂t[g(t, x)](support: 6) + ∂/∂t[g(t, x)](support: 8) = 42.0 - g(support: 1) - g(support: 2) + 10 ∂/∂t[g(t, x)](support: 2) = 0.0 - g(support: 3) - g(support: 4) + 10 ∂/∂t[g(t, x)](support: 4) = 0.0 - g(support: 5) - g(support: 6) + 10 ∂/∂t[g(t, x)](support: 6) = 0.0 - g(support: 7) - g(support: 8) + 10 ∂/∂t[g(t, x)](support: 8) = 0.0 - y(support: 1)² + 3 g(support: 1) ≤ 2.0 - y(support: 2)² + 3 g(support: 2) ≤ 2.0 - y(support: 1)² + 3 g(support: 3) ≤ 2.0 - y(support: 2)² + 3 g(support: 4) ≤ 2.0 - y(support: 1)² + 3 g(support: 5) ≤ 2.0 - y(support: 2)² + 3 g(support: 6) ≤ 2.0 - y(support: 1)² + 3 g(support: 7) ≤ 2.0 - y(support: 2)² + 3 g(support: 8) ≤ 2.0 + y(support: 1) = 1 + g(support: 1) = 0 + g(support: 3) = 0 + g(support: 5) = 0 + g(support: 7) = 0 + ∂/∂t[g(t, x)](support: 1) + ∂/∂t[g(t, x)](support: 3) + ∂/∂t[g(t, x)](support: 5) + ∂/∂t[g(t, x)](support: 7) = 42 + ∂/∂t[g(t, x)](support: 2) + ∂/∂t[g(t, x)](support: 4) + ∂/∂t[g(t, x)](support: 6) + ∂/∂t[g(t, x)](support: 8) = 42 + g(support: 1) - g(support: 2) + 10 ∂/∂t[g(t, x)](support: 2) = 0 + g(support: 3) - g(support: 4) + 10 ∂/∂t[g(t, x)](support: 4) = 0 + g(support: 5) - g(support: 6) + 10 ∂/∂t[g(t, x)](support: 6) = 0 + g(support: 7) - g(support: 8) + 10 ∂/∂t[g(t, x)](support: 8) = 0 + y(support: 1)² + 3 g(support: 1) ≤ 2 + y(support: 2)² + 3 g(support: 2) ≤ 2 + y(support: 1)² + 3 g(support: 3) ≤ 2 + y(support: 2)² + 3 g(support: 4) ≤ 2 + y(support: 1)² + 3 g(support: 5) ≤ 2 + y(support: 2)² + 3 g(support: 6) ≤ 2 + y(support: 1)² + 3 g(support: 7) ≤ 2 + y(support: 2)² + 3 g(support: 8) ≤ 2 ``` This precisely matches what we found analytically. Note that the unique support combinations are determined automatically and are represented visually as diff --git a/docs/src/guide/variable.md b/docs/src/guide/variable.md index 3691922d..b9517350 100644 --- a/docs/src/guide/variable.md +++ b/docs/src/guide/variable.md @@ -706,7 +706,7 @@ such constraint exists). For example, the upper bound constraint of `y_bd` can b obtained via [`UpperBoundRef`](@ref JuMP.UpperBoundRef(::UserDecisionVariableRef)): ```jldoctest var_macro julia> UpperBoundRef(y_bd) -y_bd(t, x) ≤ 10.0, ∀ t ∈ [0, 10], x[1] ∈ [-1, 1], x[2] ∈ [-1, 1], x[3] ∈ [-1, 1] +y_bd(t, x) ≤ 10, ∀ t ∈ [0, 10], x[1] ∈ [-1, 1], x[2] ∈ [-1, 1], x[3] ∈ [-1, 1] ``` The other methods are [`LowerBoundRef`](@ref JuMP.LowerBoundRef(::UserDecisionVariableRef)), [`FixRef`](@ref JuMP.FixRef(::UserDecisionVariableRef)), diff --git a/docs/src/tutorials/quick_start.md b/docs/src/tutorials/quick_start.md index bd9378e9..41971e8d 100644 --- a/docs/src/tutorials/quick_start.md +++ b/docs/src/tutorials/quick_start.md @@ -179,15 +179,15 @@ julia> @constraint(model, [i in I], x[i](0, ξ) == x0[i]) 1-dimensional DenseAxisArray{InfOptConstraintRef,1,...} with index sets: Dimension 1, 1:2 And data, a 2-element Vector{InfOptConstraintRef}: - x[1](0, ξ) = 0.0, ∀ ξ ~ Normal - x[2](0, ξ) = 0.0, ∀ ξ ~ Normal + x[1](0, ξ) = 0, ∀ ξ ~ Normal + x[2](0, ξ) = 0, ∀ ξ ~ Normal julia> @constraint(model, [i in I], v[i](0, ξ) == v0[i]) 1-dimensional DenseAxisArray{InfOptConstraintRef,1,...} with index sets: Dimension 1, 1:2 And data, a 2-element Vector{InfOptConstraintRef}: - v[1](0, ξ) = 0.0, ∀ ξ ~ Normal - v[2](0, ξ) = 0.0, ∀ ξ ~ Normal + v[1](0, ξ) = 0, ∀ ξ ~ Normal + v[2](0, ξ) = 0, ∀ ξ ~ Normal ``` Note it is important that we include appropriate boundary conditions when using derivatives in our model. For more information please see @@ -201,15 +201,15 @@ julia> @constraint(model, c1[i in I], deriv(x[i], t) == v[i]) 1-dimensional DenseAxisArray{InfOptConstraintRef,1,...} with index sets: Dimension 1, 1:2 And data, a 2-element Vector{InfOptConstraintRef}: - c1[1] : ∂/∂t[x[1](t, ξ)] - v[1](t, ξ) = 0.0, ∀ t ∈ [0, 60], ξ ~ Normal - c1[2] : ∂/∂t[x[2](t, ξ)] - v[2](t, ξ) = 0.0, ∀ t ∈ [0, 60], ξ ~ Normal + c1[1] : ∂/∂t[x[1](t, ξ)] - v[1](t, ξ) = 0, ∀ t ∈ [0, 60], ξ ~ Normal + c1[2] : ∂/∂t[x[2](t, ξ)] - v[2](t, ξ) = 0, ∀ t ∈ [0, 60], ξ ~ Normal julia> @constraint(model, c2[i in I], ξ * deriv(v[i], t) == u[i]) 1-dimensional DenseAxisArray{InfOptConstraintRef,1,...} with index sets: Dimension 1, 1:2 And data, a 2-element Vector{InfOptConstraintRef}: - c2[1] : ξ*∂/∂t[v[1](t, ξ)] - u[1](t) = 0.0, ∀ t ∈ [0, 60], ξ ~ Normal - c2[2] : ξ*∂/∂t[v[2](t, ξ)] - u[2](t) = 0.0, ∀ t ∈ [0, 60], ξ ~ Normal + c2[1] : ξ*∂/∂t[v[1](t, ξ)] - u[1](t) = 0, ∀ t ∈ [0, 60], ξ ~ Normal + c2[2] : ξ*∂/∂t[v[2](t, ξ)] - u[2](t) = 0, ∀ t ∈ [0, 60], ξ ~ Normal ``` Finally, we can define our last 2 constraints: @@ -218,13 +218,13 @@ julia> @constraint(model, c3[w in W], y[w] == sum((x[i](tw[w], ξ) - p[i, w])^2 1-dimensional DenseAxisArray{InfOptConstraintRef,1,...} with index sets: Dimension 1, 1:4 And data, a 4-element Vector{InfOptConstraintRef}: - c3[1] : -x[1](0, ξ)² - x[2](0, ξ)² + y[1](ξ) + 2 x[1](0, ξ) + 2 x[2](0, ξ) = 2.0, ∀ ξ ~ Normal - c3[2] : -x[1](25, ξ)² - x[2](25, ξ)² + y[2](ξ) + 8 x[1](25, ξ) + 6 x[2](25, ξ) = 25.0, ∀ ξ ~ Normal - c3[3] : -x[1](50, ξ)² - x[2](50, ξ)² + y[3](ξ) + 12 x[1](50, ξ) = 36.0, ∀ ξ ~ Normal - c3[4] : -x[1](60, ξ)² - x[2](60, ξ)² + y[4](ξ) + 2 x[1](60, ξ) + 2 x[2](60, ξ) = 2.0, ∀ ξ ~ Normal + c3[1] : -x[1](0, ξ)² - x[2](0, ξ)² + y[1](ξ) + 2 x[1](0, ξ) + 2 x[2](0, ξ) = 2, ∀ ξ ~ Normal + c3[2] : -x[1](25, ξ)² - x[2](25, ξ)² + y[2](ξ) + 8 x[1](25, ξ) + 6 x[2](25, ξ) = 25, ∀ ξ ~ Normal + c3[3] : -x[1](50, ξ)² - x[2](50, ξ)² + y[3](ξ) + 12 x[1](50, ξ) = 36, ∀ ξ ~ Normal + c3[4] : -x[1](60, ξ)² - x[2](60, ξ)² + y[4](ξ) + 2 x[1](60, ξ) + 2 x[2](60, ξ) = 2, ∀ ξ ~ Normal julia> @constraint(model, c4, expect(sum(y[w] for w in W), ξ) <= ϵ) -c4 : 𝔼{ξ}[y[1](ξ) + y[2](ξ) + y[3](ξ) + y[4](ξ)] - ϵ ≤ 0.0 +c4 : 𝔼{ξ}[y[1](ξ) + y[2](ξ) + y[3](ξ) + y[4](ξ)] - ϵ ≤ 0 ``` Notice we are able to invoke an expectation simply by calling [`expect`](@ref). diff --git a/test/show.jl b/test/show.jl index b23f7b70..6fdaea7e 100644 --- a/test/show.jl +++ b/test/show.jl @@ -248,14 +248,14 @@ # test measure_data_string with 1-D DiscreteMeasureData/FunctionalDiscreteMeasureData @testset "measure_data_string (1-D)" begin # test with bounds - data = FunctionalDiscreteMeasureData(par1, ones, 0, All, NoGenerativeSupports(), + data = FunctionalDiscreteMeasureData(par1, ones, 0, All, NoGenerativeSupports(), default_weight, 0, 1, false) str = "par1 " * InfiniteOpt._math_symbol(MIME("text/plain"), :in) * " [0, 1]" @test InfiniteOpt.measure_data_string(MIME("text/plain"), data) == str str = "par1 " * InfiniteOpt._math_symbol(MIME("text/latex"), :in) * " [0, 1]" @test InfiniteOpt.measure_data_string(MIME("text/latex"), data) == str # test without bounds - data = FunctionalDiscreteMeasureData(par1, ones, 0, All, NoGenerativeSupports(), + data = FunctionalDiscreteMeasureData(par1, ones, 0, All, NoGenerativeSupports(), default_weight, NaN, NaN, false) @test InfiniteOpt.measure_data_string(MIME("text/plain"), data) == "par1" @test InfiniteOpt.measure_data_string(MIME("text/latex"), data) == "par1" @@ -329,7 +329,7 @@ meas = dispatch_variable_ref(expect(y, t)) str = "\\mathbb{E}_{t \\in [0, 1]}\\left[y\\right]" @test InfiniteOpt.variable_string(MIME("text/latex"), meas) == str - str = InfiniteOpt._math_symbol(MIME("text/plain"), :expect) * "{t " * + str = InfiniteOpt._math_symbol(MIME("text/plain"), :expect) * "{t " * InfiniteOpt._math_symbol(MIME("text/plain"), :in) * " [0, 1]}[y]" @test InfiniteOpt.variable_string(MIME("text/plain"), meas) == str meas = dispatch_variable_ref(integral(y, t)) @@ -392,7 +392,7 @@ d_re = InfiniteOpt._math_symbol(MIME("text/plain"), :partial) @test InfiniteOpt.variable_string(MIME("text/plain"), dref) == "$d_re/$(d_re)par1[x(par1)]" @test InfiniteOpt.variable_string(MIME("text/latex"), dref) == "\\frac{\\partial}{\\partial par1}\\left[x(par1)\\right]" - # test nested one + # test nested one dref = dispatch_variable_ref(d2) expected = "$d_re/$(d_re)par1[$d_re/$(d_re)pars[1][inf(pars, par1, pars3)]]" @test InfiniteOpt.variable_string(MIME("text/plain"), dref) == expected @@ -436,11 +436,11 @@ dvref = dispatch_variable_ref(@variable(m, z0, Point(z, [0, 0]))) @test InfiniteOpt.variable_string(MIME("text/plain"), dvref) == "z0" @test InfiniteOpt.variable_string(MIME("text/latex"), dvref) == "z0" - # test with derivative + # test with derivative dvref = dispatch_variable_ref(@variable(m, variable_type = Point(d1, 0))) d_re = InfiniteOpt._math_symbol(MIME("text/plain"), :partial) @test InfiniteOpt.variable_string(MIME("text/plain"), dvref) == "$(d_re)/$(d_re)par1[x(par1)](0)" - # test named derivative + # test named derivative dvref = dispatch_variable_ref(@variable(m, variable_type = Point(d3, [0, 0]))) @test InfiniteOpt.variable_string(MIME("text/plain"), dvref) == "d3([0, 0])" end @@ -455,7 +455,7 @@ dvref = dispatch_variable_ref(rv) @test InfiniteOpt.variable_string(MIME("text/plain"), dvref) == "inf([0, 0], par1, [0, pars3[2]])" @test InfiniteOpt.variable_string(MIME("text/latex"), dvref) == "inf([0, 0], par1, [0, pars3[2]])" - # test named derivative + # test named derivative rv = @variable(m, variable_type = SemiInfinite(d3, [0, pars[2]])) dvref = dispatch_variable_ref(rv) @test InfiniteOpt.variable_string(MIME("text/plain"), dvref) == "d3([0, pars[2]])" @@ -493,19 +493,19 @@ # test constraint_string (Finite constraint) @testset "JuMP.constraint_string (Finite)" begin # test named - str = "c2 : y² " * InfiniteOpt._math_symbol(MIME("text/plain"), :eq) * " 3.0" + str = "c2 : y² " * in_set_string(MIME("text/plain"), MOI.EqualTo(3.0)) @test constraint_string(MIME("text/plain"), c2) == str - str = "c2 : \$ y^2 " * InfiniteOpt._math_symbol(MIME("text/latex"), :eq) * " 3.0 \$" + str = "c2 : \$ y^2 " * in_set_string(MIME("text/latex"), MOI.EqualTo(3.0)) * " \$" @test constraint_string(MIME("text/latex"), c2) == str # test unnamed - str = "y² " * InfiniteOpt._math_symbol(MIME("text/plain"), :eq) * " 3.0" + str = "y² " * in_set_string(MIME("text/plain"), MOI.EqualTo(3.0)) @test constraint_string(MIME("text/plain"), ac2) == str - str = "\$ y^2 " * InfiniteOpt._math_symbol(MIME("text/latex"), :eq) * " 3.0 \$" + str = "\$ y^2 " * in_set_string(MIME("text/latex"), MOI.EqualTo(3.0)) * " \$" @test constraint_string(MIME("text/latex"), ac2) == str # test named in math mode - str = "c2 : y² " * InfiniteOpt._math_symbol(MIME("text/plain"), :eq) * " 3.0" + str = "c2 : y² " * in_set_string(MIME("text/plain"), MOI.EqualTo(3.0)) @test constraint_string(MIME("text/plain"), c2, in_math_mode = true) == str - str = "y^2 " * InfiniteOpt._math_symbol(MIME("text/latex"), :eq) * " 3.0" + str = "y^2 " * in_set_string(MIME("text/latex"), MOI.EqualTo(3.0)) @test constraint_string(MIME("text/latex"), c2, in_math_mode = true) == str end # test _param_domain_string (IndependentParameter) @@ -573,47 +573,47 @@ # test constraint_string (infinite constraint) @testset "JuMP.constraint_string (Infinite)" begin # test c1 with name - str = "c1 : x(par1) + y " * InfiniteOpt._math_symbol(MIME("text/plain"), :leq) * " 2.0, " * + str = "c1 : x(par1) + y " * in_set_string(MIME("text/plain"), MOI.LessThan(2.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/plain"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/plain"), :in) * " [0, 1]" @test constraint_string(MIME("text/plain"), c1) == str - str = "c1 : \$ x(par1) + y " * InfiniteOpt._math_symbol(MIME("text/latex"), :leq) * " 2.0, " * + str = "c1 : \$ x(par1) + y " * in_set_string(MIME("text/latex"), MOI.LessThan(2.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/latex"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/latex"), :in) * " [0, 1] \$" @test constraint_string(MIME("text/latex"), c1) == str # test c1 without name - str = "x(par1) + y " * InfiniteOpt._math_symbol(MIME("text/plain"), :leq) * " 2.0, " * + str = "x(par1) + y " * in_set_string(MIME("text/plain"), MOI.LessThan(2.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/plain"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/plain"), :in) * " [0, 1]" @test constraint_string(MIME("text/plain"), ac1) == str - str = "\$ x(par1) + y " * InfiniteOpt._math_symbol(MIME("text/latex"), :leq) * " 2.0, " * + str = "\$ x(par1) + y " * in_set_string(MIME("text/latex"), MOI.LessThan(2.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/latex"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/latex"), :in) * " [0, 1] \$" @test constraint_string(MIME("text/latex"), ac1) == str # test c1 with name and in_math_mode - str = "c1 : x(par1) + y " * InfiniteOpt._math_symbol(MIME("text/plain"), :leq) * " 2.0, " * + str = "c1 : x(par1) + y " * in_set_string(MIME("text/plain"), MOI.LessThan(2.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/plain"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/plain"), :in) * " [0, 1]" @test constraint_string(MIME("text/plain"), c1, in_math_mode = true) == str - str = "x(par1) + y " * InfiniteOpt._math_symbol(MIME("text/latex"), :leq) * " 2.0, " * + str = "x(par1) + y " * in_set_string(MIME("text/latex"), MOI.LessThan(2.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/latex"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/latex"), :in) * " [0, 1]" @test constraint_string(MIME("text/latex"), c1, in_math_mode = true) == str # test c3 with name - str = "c3 : x(par1) " * InfiniteOpt._math_symbol(MIME("text/plain"), :eq) * " 5.0, " * + str = "c3 : x(par1) " * in_set_string(MIME("text/plain"), MOI.EqualTo(5.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/plain"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/plain"), :in) * " [0, 0.5]" @test constraint_string(MIME("text/plain"), c3) == str - str = "c3 : \$ x(par1) " * InfiniteOpt._math_symbol(MIME("text/latex"), :eq) * " 5.0, " * + str = "c3 : \$ x(par1) " * in_set_string(MIME("text/latex"), MOI.EqualTo(5.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/latex"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/latex"), :in) * " [0, 0.5] \$" @test constraint_string(MIME("text/latex"), c3) == str # test c3 without name - str = "x(par1) " * InfiniteOpt._math_symbol(MIME("text/plain"), :eq) * " 5.0, " * + str = "x(par1) " * in_set_string(MIME("text/plain"), MOI.EqualTo(5.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/plain"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/plain"), :in) * " [0, 0.5]" @test constraint_string(MIME("text/plain"), ac3) == str - str = "\$ x(par1) " * InfiniteOpt._math_symbol(MIME("text/latex"), :eq) * " 5.0, " * + str = "\$ x(par1) " * in_set_string(MIME("text/latex"), MOI.EqualTo(5.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/latex"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/latex"), :in) * " [0, 0.5] \$" @test constraint_string(MIME("text/latex"), ac3) == str @@ -622,35 +622,35 @@ @testset "JuMP.constraints_string" begin # test MIME("text/plain") strings = Vector{String}(undef, 6) - strings[1] = "c1 : x(par1) + y " * InfiniteOpt._math_symbol(MIME("text/plain"), :leq) * - " 2.0, " * InfiniteOpt._math_symbol(MIME("text/plain"), :for_all) * " par1 " * + strings[1] = "c1 : x(par1) + y " * in_set_string(MIME("text/plain"), MOI.LessThan(2.0)) * + ", " * InfiniteOpt._math_symbol(MIME("text/plain"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/plain"), :in) * " [0, 1]" - strings[2] = "x(par1) + y " * InfiniteOpt._math_symbol(MIME("text/plain"), :leq) * - " 2.0, " * InfiniteOpt._math_symbol(MIME("text/plain"), :for_all) * " par1 " * + strings[2] = "x(par1) + y " * in_set_string(MIME("text/plain"), MOI.LessThan(2.0)) * + ", " * InfiniteOpt._math_symbol(MIME("text/plain"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/plain"), :in) * " [0, 1]" - strings[3] = "c2 : y² " * InfiniteOpt._math_symbol(MIME("text/plain"), :eq) * " 3.0" - strings[4] = "y² " * InfiniteOpt._math_symbol(MIME("text/plain"), :eq) * " 3.0" - strings[5] = "c3 : x(par1) " * InfiniteOpt._math_symbol(MIME("text/plain"), :eq) * " 5.0, " * + strings[3] = "c2 : y² " * in_set_string(MIME("text/plain"), MOI.EqualTo(3.0)) + strings[4] = "y² " * in_set_string(MIME("text/plain"), MOI.EqualTo(3.0)) + strings[5] = "c3 : x(par1) " * in_set_string(MIME("text/plain"), MOI.EqualTo(5.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/plain"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/plain"), :in) * " [0, 0.5]" - strings[6] = "x(par1) " * InfiniteOpt._math_symbol(MIME("text/plain"), :eq) * " 5.0, " * + strings[6] = "x(par1) " * in_set_string(MIME("text/plain"), MOI.EqualTo(5.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/plain"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/plain"), :in) * " [0, 0.5]" @test constraints_string(MIME("text/plain"), m) == strings # test MIME("text/latex") strings = Vector{String}(undef, 6) - strings[1] = "x(par1) + y " * InfiniteOpt._math_symbol(MIME("text/latex"), :leq) * - " 2.0, " * InfiniteOpt._math_symbol(MIME("text/latex"), :for_all) * " par1 " * + strings[1] = "x(par1) + y " * in_set_string(MIME("text/latex"), MOI.LessThan(2.0)) * + ", " * InfiniteOpt._math_symbol(MIME("text/latex"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/latex"), :in) * " [0, 1]" - strings[2] = "x(par1) + y " * InfiniteOpt._math_symbol(MIME("text/latex"), :leq) * - " 2.0, " * InfiniteOpt._math_symbol(MIME("text/latex"), :for_all) * " par1 " * + strings[2] = "x(par1) + y " * in_set_string(MIME("text/latex"), MOI.LessThan(2.0)) * + ", " * InfiniteOpt._math_symbol(MIME("text/latex"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/latex"), :in) * " [0, 1]" - strings[3] = "y^2 " * InfiniteOpt._math_symbol(MIME("text/latex"), :eq) * " 3.0" - strings[4] = "y^2 " * InfiniteOpt._math_symbol(MIME("text/latex"), :eq) * " 3.0" - strings[5] = "x(par1) " * InfiniteOpt._math_symbol(MIME("text/latex"), :eq) * " 5.0, " * + strings[3] = "y^2 " * in_set_string(MIME("text/latex"), MOI.EqualTo(3.0)) + strings[4] = "y^2 " * in_set_string(MIME("text/latex"), MOI.EqualTo(3.0)) + strings[5] = "x(par1) " * in_set_string(MIME("text/latex"), MOI.EqualTo(5.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/latex"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/latex"), :in) * " [0, 0.5]" - strings[6] = "x(par1) " * InfiniteOpt._math_symbol(MIME("text/latex"), :eq) * " 5.0, " * + strings[6] = "x(par1) " * in_set_string(MIME("text/latex"), MOI.EqualTo(5.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/latex"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/latex"), :in) * " [0, 0.5]" @test constraints_string(MIME("text/latex"), m) == strings @@ -726,12 +726,12 @@ end # test Base.show (constraint in REPL) @testset "Base.show (REPL Constraint)" begin # test normal - str = "c1 : x(par1) + y " * InfiniteOpt._math_symbol(MIME("text/plain"), :leq) * - " 2.0, " * InfiniteOpt._math_symbol(MIME("text/plain"), :for_all) * " par1 " * + str = "c1 : x(par1) + y " * in_set_string(MIME("text/plain"), MOI.LessThan(2.0)) * + ", " * InfiniteOpt._math_symbol(MIME("text/plain"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/plain"), :in) * " [0, 1]" show_test(MIME("text/plain"), c1, str) # test restricted - str = "c3 : x(par1) " * InfiniteOpt._math_symbol(MIME("text/plain"), :leq) * " 5.0, " * + str = "c3 : x(par1) " * in_set_string(MIME("text/plain"), MOI.LessThan(5.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/plain"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/plain"), :in) * " [0, 0.5]" show_test(MIME("text/plain"), c3, str) @@ -739,12 +739,12 @@ end # test Base.show (constraint in IJulia) @testset "Base.show (IJulia Constraint)" begin # test normal - str = "c1 : \$ x(par1) + y " * InfiniteOpt._math_symbol(MIME("text/latex"), :leq) * - " 2.0, " * InfiniteOpt._math_symbol(MIME("text/latex"), :for_all) * " par1 " * + str = "c1 : \$ x(par1) + y " * in_set_string(MIME("text/latex"), MOI.LessThan(2.0)) * + ", " * InfiniteOpt._math_symbol(MIME("text/latex"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/latex"), :in) * " [0, 1] \$" show_test(MIME("text/latex"), c1, str) # test restricted - str = "c3 : \$ x(par1) " * InfiniteOpt._math_symbol(MIME("text/latex"), :leq) * " 5.0, " * + str = "c3 : \$ x(par1) " * in_set_string(MIME("text/latex"), MOI.LessThan(5.0)) * ", " * InfiniteOpt._math_symbol(MIME("text/latex"), :for_all) * " par1 " * InfiniteOpt._math_symbol(MIME("text/latex"), :in) * " [0, 0.5] \$" show_test(MIME("text/latex"), c3, str)