long variable and constraint names in python model variable / lp file memory usage

332 views
Skip to first unread message

Simon Hilpert

unread,
May 6, 2015, 6:31:34 AM5/6/15
to pyomo...@googlegroups.com
hi,

i like to generate a big model (>25000 rows/cols) and i was wondering, if e.g. i do:

model = ConcreteModel()

it slows down the process of creating the model by adding constraints etc. if the variable and constraint names are getting long like:

model.regional_dispatch_in_timestep_1000_electricity = Var()

An other question is, if a generated lp-file has these long names as well and is handed over too the solver, if there could there be a problem regarding memory usage?

thanks,
simon

Siirola, John D

unread,
May 6, 2015, 9:47:49 AM5/6/15
to pyomo...@googlegroups.com
I have not seen or heard of cases where long variable names noticeably affected performance. It will take a marginally larger amount of memory, but depending on how you express the model that could be only a few kbytes. 

For the solver, by default we change the variable names to "x1" "x2" ... So you wouldn't see any difference there, unless you force Pyomo to emit your names with --symbolic-solver-labels option. 

John 

--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

William Hart

unread,
May 6, 2015, 3:36:07 PM5/6/15
to pyomo...@googlegroups.com
I agree.  Can you give an example that illustrates this performance difference?

--Bill

Simon Hilpert

unread,
May 7, 2015, 2:53:03 AM5/7/15
to pyomo...@googlegroups.com
I can't provide information on how much it slows down the building process. Only thing I wondered about is the following:

 if I have a big pure LP with over 200000 variables, building the model is > 1 minuten and solving it with gurobi is about 1 minute as well (pure solving time)

That's why I came up with this question. I think if we introduce integer variables (what will happen) then of course solving time increases and 1 minute for building the model becomes relatively less important.

thanks for the answers!

Gabriel Hackebeil

unread,
May 7, 2015, 3:23:26 AM5/7/15
to pyomo...@googlegroups.com
Note that we also support the direct Python interfaces to Gurobi and Cplex, which can be significantly faster than the file based interfaces (LP and NL). This is especially true in cases where you construct the model once, and then perform many solves on incrementally changed versions of the model. However, if it is in fact the solve time that is dominating (and not the process of creating the solver input file from a Pyomo model), then this won’t help much.

If you’re interested in using the Python interfaces, just install the Gurobi/Cplex python bindings into the same Python installation as Pyomo (you should be able to “import gurobipy” / “import cplex”). The “--solver-io=python” pyomo command-line option will activate the appropriate interface (if available) based on the solver name. If you are scripting, then the keyword "solver_io=‘python’” should be passed into SolverFactory. E.g.,

# Python interface
solver = SolverFactory(“gurobi”, solver_io=‘python’)

# LP-file interface (default)
solver = SolverFactory(“gurobi”)   #, solver_io=‘lp’)

# NL-file interface (executable name)
solver = SolverFactory(“gurobi_ampl”)   #, solver_io=‘nl’)

Regards,
Gabe

Reply all
Reply to author
Forward
0 new messages