diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index d6599e4ccdf..e8e1145d4b1 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@latest with: - version: '1.10' + version: '1' - name: Install dependencies shell: julia --color=yes --project=docs/ {0} run: | diff --git a/docs/src/tutorials/algorithms/tsp_lazy_constraints.jl b/docs/src/tutorials/algorithms/tsp_lazy_constraints.jl index e1f616bf3d5..82dd8871eea 100644 --- a/docs/src/tutorials/algorithms/tsp_lazy_constraints.jl +++ b/docs/src/tutorials/algorithms/tsp_lazy_constraints.jl @@ -124,7 +124,7 @@ function generate_distance_matrix(n; random_seed = 1) return X, Y, d end -n = 40 +n = 20 X, Y, d = generate_distance_matrix(n) # For the JuMP model, we first initialize the model object. Then, we create the @@ -252,7 +252,6 @@ function subtour_elimination_callback(cb_data) if !(1 < length(cycle) < n) return # Only add a constraint if there is a cycle end - println("Found cycle of length $(length(cycle))") S = [(i, j) for (i, j) in Iterators.product(cycle, cycle) if i < j] con = @build_constraint( sum(lazy_model[:x][i, j] for (i, j) in S) <= length(cycle) - 1, diff --git a/docs/src/tutorials/conic/ellipse_approx.jl b/docs/src/tutorials/conic/ellipse_approx.jl index e09b95a0abd..5b2ef3efc3e 100644 --- a/docs/src/tutorials/conic/ellipse_approx.jl +++ b/docs/src/tutorials/conic/ellipse_approx.jl @@ -94,7 +94,7 @@ plot = Plots.scatter( model = Model(SCS.Optimizer) ## We need to use a tighter tolerance for this example, otherwise the bounding ## ellipse won't actually be bounding... -set_attribute(model, "eps_rel", 1e-6) +set_attribute(model, "eps_rel", 1e-7) set_silent(model) m, n = size(S) @variable(model, z[1:n]) @@ -124,11 +124,13 @@ D = value.(Z) c = D \ value.(z) -# Finally, overlaying the solution in the plot we see the minimal volume approximating -# ellipsoid: +# We can check that each point lies inside the ellipsoid, by checking if the +# largest normalized radius is less than 1: + +largest_radius = maximum(map(x -> (x - c)' * D * (x - c), eachrow(S))) -Test.@test isapprox(D, [0.00707 -0.0102; -0.0102173 0.0175624]; atol = 1e-2) #src -Test.@test isapprox(c, [-3.24802, -1.842825]; atol = 1e-2) #src +# Finally, overlaying the solution in the plot we see the minimal volume +# approximating ellipsoid: P = sqrt(D) q = -P * c @@ -211,7 +213,7 @@ f = [1 - S[i, :]' * Z * S[i, :] + 2 * S[i, :]' * z - s for i in 1:m] @objective(model, Max, 1 * t + 0) optimize!(model) Test.@test is_solved_and_feasible(model) -Test.@test isapprox(D, value.(Z); atol = 1e-6) #src +Test.@test isapprox(D, value.(Z); atol = 1e-3) #src solve_time_1 = solve_time(model) # This formulation gives the much smaller graph: diff --git a/src/macros/@force_nonlinear.jl b/src/macros/@force_nonlinear.jl index 5ea1dfde2a7..57b9e5534ca 100644 --- a/src/macros/@force_nonlinear.jl +++ b/src/macros/@force_nonlinear.jl @@ -84,10 +84,10 @@ julia> @expression(model, @force_nonlinear(x * 2.0 * (1 + x) * x)) x * 2.0 * (1 + x) * x julia> @allocated @expression(model, x * 2.0 * (1 + x) * x) -3200 +2640 julia> @allocated @expression(model, @force_nonlinear(x * 2.0 * (1 + x) * x)) -640 +672 ``` """ macro force_nonlinear(expr)