Skip to main content

Sparsify a model without presolve

Ongoing

Comments

5 comments

  • David Torres Sanchez
    Gurobi Staff Gurobi Staff

    Hi Fredrick,

    If presolve manages to remove all columns/rows then the model is solved. (see: What does "Presolve: All rows and columns removed" mean?).

    I'm not sure how to avoid this consistently but you could try to set other presolve-related parameters: e.g. DualReductions=0, Aggregate=0.

    Also, note that customers can open tickets for support.

    Cheers, 
    David

    0
  • Frederik Schadd
    Gurobi-versary
    First Comment
    First Question

    In our case, the presolve removed all columns without providing a solution or objective value. The resulting model object contains no data. Here is an example of this happening:

    [2024-01-17 10:50:15][INFO] Presolve removed 63290 rows and 64145 columns (presolve time = 5s) ...
    [2024-01-17 10:50:25][INFO] Presolve removed 606719 rows and 606655 columns (presolve time = 15s) ...
    [2024-01-17 10:50:30][INFO] Presolve removed 607178 rows and 606679 columns (presolve time = 21s) ...
    [2024-01-17 10:50:36][INFO] Presolve removed 610847 rows and 611160 columns (presolve time = 27s) ...
    [2024-01-17 10:50:45][INFO] Presolve removed 610847 rows and 611160 columns (presolve time = 36s) ...
    [2024-01-17 10:50:51][INFO] Presolve removed 610847 rows and 611160 columns (presolve time = 42s) ...
    [2024-01-17 10:50:58][INFO] Presolve removed 611046 rows and 611160 columns (presolve time = 48s) ...
    [2024-01-17 10:51:02][INFO] Presolve removed 611046 rows and 611160 columns (presolve time = 52s) ...
    [2024-01-17 10:51:09][INFO] Presolve removed 611046 rows and 611160 columns (presolve time = 60s) ...
    [2024-01-17 10:51:14][INFO] Presolve removed 619886 rows and 620000 columns (presolve time = 65s) ...
    [2024-01-17 10:51:15][INFO] Presolve removed 621670 rows and 621784 columns (presolve time = 65s) ...
    [2024-01-17 10:51:20][INFO] Presolve removed 621682 rows and 621785 columns (presolve time = 70s) ...
    [2024-01-17 10:51:25][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 75s) ...
    [2024-01-17 10:51:30][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 80s) ...
    [2024-01-17 10:51:35][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 85s) ...
    [2024-01-17 10:51:40][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 90s) ...
    [2024-01-17 10:51:45][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 95s) ...
    [2024-01-17 10:51:50][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 100s) ...
    [2024-01-17 10:51:55][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 105s) ...
    [2024-01-17 10:52:00][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 110s) ...
    [2024-01-17 10:52:05][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 115s) ...
    [2024-01-17 10:52:10][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 120s) ...
    [2024-01-17 10:52:15][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 125s) ...
    [2024-01-17 10:52:20][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 130s) ...
    [2024-01-17 10:52:25][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 135s) ...
    [2024-01-17 10:52:30][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 140s) ...
    [2024-01-17 10:52:35][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 145s) ...
    [2024-01-17 10:52:40][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 150s) ...
    [2024-01-17 10:52:45][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 155s) ...
    [2024-01-17 10:52:50][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 160s) ...
    [2024-01-17 10:52:55][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 165s) ...
    [2024-01-17 10:53:00][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 170s) ...
    [2024-01-17 10:53:05][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 175s) ...
    [2024-01-17 10:53:10][INFO] Presolve removed 621693 rows and 621785 columns (presolve time = 180s) ...
    [2024-01-17 10:53:10][INFO] Presolve removed 621906 rows and 621785 columns
    [2024-01-17 10:53:10][INFO] Presolve time: 180.21s
    [2024-01-17 10:53:10][INFO] Set parameter TimeLimit to value 99999
    [2024-01-17 10:53:10][INFO] Set parameter NodefileStart to value 2
    [2024-01-17 10:53:10][INFO] Warning: Use node files with caution on Gurobi Cloud or Compute Server.
    [2024-01-17 10:53:10][INFO]          Check the server log files to verify!
    [2024-01-17 10:53:10][INFO] Optimize a model with 0 rows, 0 columns and 0 nonzeros
    [2024-01-17 10:53:10][INFO] Model fingerprint: 0xf9715da1
    [2024-01-17 10:53:10][INFO] Coefficient statistics:
    [2024-01-17 10:53:10][INFO]   Matrix range     [0e+00, 0e+00]
    [2024-01-17 10:53:10][INFO]   Objective range  [0e+00, 0e+00]
    [2024-01-17 10:53:10][INFO]   Bounds range     [0e+00, 0e+00]
    [2024-01-17 10:53:10][INFO]   RHS range        [0e+00, 0e+00]
    [2024-01-17 10:53:10][INFO] Presolve time: 0.00s
    [2024-01-17 10:53:10][INFO] Presolve: All rows and columns removed
    [2024-01-17 10:53:10][INFO] Presolve time: 0.00s
    [2024-01-17 10:53:10][INFO] Presolve: All rows and columns removed
    [2024-01-17 10:53:10][INFO] Iteration    Objective       Primal Inf.    Dual Inf.      Time
    [2024-01-17 10:53:10][INFO]        0    0.0000000e+00   0.000000e+00   0.000000e+00      0s
    [2024-01-17 10:53:10][INFO] 
    [2024-01-17 10:53:10][INFO] Solved in 0 iterations and 0.00 seconds (0.00 work units)
    [2024-01-17 10:53:10][INFO] Optimal objective  0.000000000e+00
    [2024-01-17 10:53:10][INFO] 
    [2024-01-17 10:53:10][INFO] Solved in 0 iterations and 0.00 seconds (0.00 work units)
    [2024-01-17 10:53:10][INFO] Optimal objective  0.000000000e+00
    [2024-01-17 10:53:10][ERROR] Unable to retrieve attribute 'ObjVal'
    0
  • David Torres Sanchez
    Gurobi Staff Gurobi Staff

    The lines after manual presolve (called with m.presolve() or something similar):

    [2024-01-17 10:53:10][INFO] Set parameter TimeLimit to value 99999
    [2024-01-17 10:53:10][INFO] Set parameter NodefileStart to value 2
    [2024-01-17 10:53:10][INFO] Warning: Use node files with caution on Gurobi Cloud or Compute Server.
    [2024-01-17 10:53:10][INFO]          Check the server log files to verify!
    [2024-01-17 10:53:10][INFO] Optimize a model with 0 rows, 0 columns and 0 nonzero

    Indicate that the model you are trying to solve is empty.

    Could you share a sample code snippet of what you're doing? 

    If you are trying to query the ObjVal of the original model, then this will not work as this model has not been solved:

    p = m.presolve() # presolved model
    p.optimize() # solve presolved model, which could be empty.
    print(p.ObjVal) # This will be fine even if it is empty, it will be 0 though
    print(m.ObjVal) # This will not work as this model has not been solved. Regardless of the state of the presolved model

    Cheers, 
    David

    0
  • Frederik Schadd
    Gurobi-versary
    First Comment
    First Question

    Sure, we've been trying explicit presolves like this:

    model_copy.reset()  
    model_copy.setParam("PreSolve", 1)
    model_copy.setParam("PreSparsify", 1)
    presolved = model_copy.presolve()
    relaxed = presolved.relax()
    relaxed.setParam("TimeLimit", 99999)
    relaxed.setParam("NodefileStart", 2)
    relaxed.setParam("PreSparsify", 1)
    relaxed.setParam("PreSolve", 2)
    relaxed.setParam("Aggregate", 1)
    relaxed.optimize()

    I've been trying different combinations of pre-solve and aggregate settings to no avail.

     

     

    0
  • Riley Clement
    Gurobi Staff Gurobi Staff

    Handling via support request.

    0

Please sign in to leave a comment.