el1xr_opt.Modules.oM_ProblemSolving#
- el1xr_opt.Modules.oM_ProblemSolving.solving_model(DirName, CaseName, SolverName, optmodel, pWriteLP, indlog)[source]#
Solves a Pyomo optimization model with a selected solver and handles post-processing.
This function orchestrates the model solving process. It first selects a solver based on availability, prioritizing high-performance AMPL modules (like HiGHS) for speed. If the requested solver is not available as an AMPL module, it may fall back to other configurations depending on the setup in
oM_SolverSetup.The process includes:
Solver Selection: Chooses and configures the solver (e.g., HiGHS, GAMS, CPLEX).
LP File Generation: Optionally writes the model to an LP file for debugging.
Initial Solve: Solves the optimization problem.
Post-processing for Duals: If the model contains binary or integer variables, it fixes them to their optimal values and re-solves the now-continuous problem. This is a common technique to obtain meaningful dual values (shadow prices) for all constraints in a mixed-integer problem.
Results Logging: Prints the objective function value and total solving time.
- Parameters:
DirName (str) – The base directory where case-related files are stored.
CaseName (str) – The specific name of the case folder.
SolverName (str) – The name of the desired solver (e.g., ‘highs’, ‘gurobi’, ‘cbc’, ‘gams’, ‘cplex’).
optmodel (pyomo.environ.ConcreteModel) – The Pyomo model instance to be solved.
pWriteLP (str or bool) – If ‘Yes’ or True, writes the model formulation to an LP file.
- Returns:
The solved Pyomo model instance, with variable values, objective function, and duals populated.
- Return type:
pyomo.environ.ConcreteModel