jump-dev / JuMP.jl

Modeling language for Mathematical Optimization (linear, mixed-integer, conic, semidefinite, nonlinear)
http://jump.dev/JuMP.jl/
Other
2.17k stars 390 forks source link

Skip terms when printing a large vector of expressions #3759

Closed odow closed 1 month ago

odow commented 1 month ago

Closes #3757

TODO

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.38%. Comparing base (ba34a49) to head (909eee9).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #3759 +/- ## ======================================= Coverage 98.38% 98.38% ======================================= Files 44 44 Lines 5871 5872 +1 ======================================= + Hits 5776 5777 +1 Misses 95 95 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

odow commented 1 month ago

Now I get:

julia> using JuMP

julia> function test_print_omit_vector()
           n = 100
           model = Model()
           @variable(model, x[1:n, 1:n])
           @constraint(model, vec(x) >= 0)
           @constraint(model, x >= 0, PSDCone())
           print(model)
           return
       end
test_print_omit_vector (generic function with 1 method)

julia> test_print_omit_vector()
Feasibility
Subject to
 [x[1,1], x[2,1], x[3,1], x[4,1], x[5,1], x[6,1], x[7,1], x[8,1], x[9,1], x[10,1], x[11,1], x[12,1], x[13,1], x[14,1], x[15,1], [[...9970 terms omitted...]], x[86,100], x[87,100], x[88,100], x[89,100], x[90,100], x[91,100], x[92,100], x[93,100], x[94,100], x[95,100], x[96,100], x[97,100], x[98,100], x[99,100], x[100,100]] ∈ MathOptInterface.Nonnegatives(10000)
 [x[1,1]    x[1,2]    x[1,3]    x[1,4]    …  x[1,98]    x[1,99]    x[1,100]
  x[2,1]    x[2,2]    x[2,3]    x[2,4]       x[2,98]    x[2,99]    x[2,100]
  x[3,1]    x[3,2]    x[3,3]    x[3,4]       x[3,98]    x[3,99]    x[3,100]
  x[4,1]    x[4,2]    x[4,3]    x[4,4]       x[4,98]    x[4,99]    x[4,100]
  x[5,1]    x[5,2]    x[5,3]    x[5,4]       x[5,98]    x[5,99]    x[5,100]
  x[6,1]    x[6,2]    x[6,3]    x[6,4]    …  x[6,98]    x[6,99]    x[6,100]
  x[7,1]    x[7,2]    x[7,3]    x[7,4]       x[7,98]    x[7,99]    x[7,100]
  x[8,1]    x[8,2]    x[8,3]    x[8,4]       x[8,98]    x[8,99]    x[8,100]
  x[9,1]    x[9,2]    x[9,3]    x[9,4]       x[9,98]    x[9,99]    x[9,100]
  x[10,1]   x[10,2]   x[10,3]   x[10,4]      x[10,98]   x[10,99]   x[10,100]
  ⋮                                       ⋱                        
  x[92,1]   x[92,2]   x[92,3]   x[92,4]      x[92,98]   x[92,99]   x[92,100]
  x[93,1]   x[93,2]   x[93,3]   x[93,4]      x[93,98]   x[93,99]   x[93,100]
  x[94,1]   x[94,2]   x[94,3]   x[94,4]      x[94,98]   x[94,99]   x[94,100]
  x[95,1]   x[95,2]   x[95,3]   x[95,4]      x[95,98]   x[95,99]   x[95,100]
  x[96,1]   x[96,2]   x[96,3]   x[96,4]   …  x[96,98]   x[96,99]   x[96,100]
  x[97,1]   x[97,2]   x[97,3]   x[97,4]      x[97,98]   x[97,99]   x[97,100]
  x[98,1]   x[98,2]   x[98,3]   x[98,4]      x[98,98]   x[98,99]   x[98,100]
  x[99,1]   x[99,2]   x[99,3]   x[99,4]      x[99,98]   x[99,99]   x[99,100]
  x[100,1]  x[100,2]  x[100,3]  x[100,4]     x[100,98]  x[100,99]  x[100,100]] ∈ PSDCone()
odow commented 1 month ago

The downside is that it's not controllable from JuMP, but I don't think anyone is ever served by printing out the 100x100 elements of a matrix.