Optimizer Class

The Optimizer class serves as an abstract base class for implementing optimization models in the QuESt Planning tool. It leverages the Pyomo optimization framework to define, instantiate, and solve models. Subclasses must implement the abstract methods to define problem-specific parameters, variables, and constraints.

Authors: Sandia National Laboratories

Class Overview

class Optimizer

Abstract base class for Pyomo ConcreteModel optimization framework.

Attributes:
  • _model: A Pyomo ConcreteModel instance.

  • _solver: The solver to use for optimization (default: “glpk”).

  • _results: The optimization results.

Public Methods

__init__(solver='glpk')

Initializes the Optimizer class.

Parameters:
  • solver (str): The solver to use for optimization. Default is “glpk”.

solve_model()

Solves the optimization model using the specified solver.

Dependencies:
  • SolverFactory for solvers such as “glpk”, “cbc”, and “gurobi”.

  • Highs solver for HiGHs optimization.

Example Usage:
>>> optimizer.solve_model()
log_infeasible_constraints()

Logs infeasible constraints in the optimization model.

Example Usage:
>>> optimizer.log_infeasible_constraints()
run()

Runs the optimizer by instantiating, populating, and solving the model.

Example Usage:
>>> optimizer.run()
set_model_parameters(**kwargs)

Sets model parameters using keyword arguments.

Parameters:
  • **kwargs: Dictionary of parameter names and values to set.

Example Usage:
>>> optimizer.set_model_parameters(param1=value1, param2=value2)

Abstract Methods

The following methods must be implemented by subclasses:

_set_model_param()

Assigns model parameters and their default values.

_set_model_var()

Initializes model decision variables.

instantiate_model()

Instantiates the model and assigns optimizer attributes.

populate_model()

Sets model parameters, variables, and expressions.

_process_results()

Computes derived quantities of interest and prepares the results DataFrame.

get_results()

Returns the results DataFrame and any additional outputs.

Properties

model

Type: Pyomo ConcreteModel

Description: The Pyomo model used for optimization.

Example Usage:
>>> model = optimizer.model
solver

Type: str

Description: The solver name.

Example Usage:
>>> solver = optimizer.solver
results

Type: DataFrame

Description: Results of the optimization process.

Example Usage:
>>> results = optimizer.results

Error Handling

log_infeasible_constraints()

Logs infeasible constraints and generates an IIS (Irreducible Inconsistent Subsystem) analysis.

Example Usage:
>>> optimizer.log_infeasible_constraints()

API Reference

For a detailed reference of all methods, attributes, and inherited properties, refer to the autodoc-generated content below.

Optimizer class for the QuESt Planning tool - extracted from the QuESt Analytics platform Authors: Sandia National Laboratories

class quest_planning.explan.optimizer.Optimizer(solver='glpk')[source]

Bases: object

Abstract base class for Pyomo ConcreteModel optimization framework.

abstract get_results()[source]

A method for returning the results DataFrame plus any other quantities of interest.

abstract instantiate_model()[source]

A method for instantiating the model and assigning Optimizer attributes to model attributes.

log_infeasible_constraints()[source]

Logs infeasible constraints from the model.

property model

Pyomo ConcreteModel.

abstract populate_model()[source]

A method for setting model parameters, variables, and an ExpressionsBlock object for defining objectives and constraints.

property results

A results DataFrame containing series of indices, decision variables, and/or model parameters or derived quantities.

run()[source]

Instantiates, creates, and solves the optimizer model based on supplied information. Use if no steps are needed between constructing the model and solving it.

set_model_parameters(**kwargs)[source]

Sets model parameters in kwargs to their respective values.

solve_model()[source]

Solves the model using the specified solver.

property solver

The name of the solver for Pyomo to use.