ppopt.solver_interface package

Submodules

ppopt.solver_interface.cvxopt_interface module

ppopt.solver_interface.cvxopt_interface.process_cvxopt_solution(sol, equality_constraints, inequality_constraints, num_constraints, get_duals) SolverOutput | None
ppopt.solver_interface.cvxopt_interface.separate_constraints(A, b, equality_constraints, ineq)
Parameters:
  • A – The main constraint Matrix

  • b – The main constraint vector

  • equality_constraints – the indices of equations

  • ineq – the indices of inequalities

Returns:

ppopt.solver_interface.cvxopt_interface.solve_fully_constraints(c: ndarray, A: ndarray, b: ndarray) SolverOutput | None

This solves a fully constrained linear system by directly solving the linear system. This is NOT complete!

Parameters:
  • c – Column Vector

  • A – Constraint LHS matrix

  • b – Constraint RHS matrix

Returns:

A SolverOutput Object

ppopt.solver_interface.cvxopt_interface.solve_lp_cvxopt(c: ndarray, A: ndarray, b: ndarray, equality_constraints=None, verbose=False, get_duals=True, cvx_solver='glpk') SolverOutput | None

This is the breakout for solving linear programs with cvxopt, This is the preferred Solver as it has the lowest interface cost of all the other solvers

\[\min_{x} c^Tx\]
\[\begin{split}\begin{align} Ax &\leq b\\ A_{eq}x &= b_{eq}\\ x &\in R^n\\ \end{align}\end{split}\]
Parameters:
  • c – Column Vector, can be None

  • A – Constraint LHS matrix, can be None

  • b – Constraint RHS matrix, can be None

  • equality_constraints – List of Equality constraints

  • verbose – Flag for output of underlying Solver, default False

  • get_duals – Flag for returning dual variable of problem, default True

  • cvx_solver – selects the cvxopt Solver, default is glpk

Returns:

A SolverOutput Object

ppopt.solver_interface.cvxopt_interface.solve_qp_cvxopt(Q: ndarray, c: ndarray, A: ndarray, b: ndarray, equality_constraints=None, verbose=False, get_duals=True, cvx_solver='quadprog') SolverOutput | None

This is the breakout for QP with cvxopt

\[\min_{x} \frac{1}{2}x^TQx + c^Tx\]
\[\begin{split}\begin{align} Ax &\leq b\\ A_{eq}x &= b_{eq}\\ x &\in R^n\\ \end{align}\end{split}\]
Parameters:
  • Q – The hessian of the quadratic program, must be symmetric and positive definite

  • c – Column Vector, can be None

  • A – Constraint LHS matrix, can be None

  • b – Constraint RHS matrix, can be None

  • equality_constraints – List of Equality constraints

  • verbose – Flag for output of underlying Solver, default False

  • get_duals – Flag for returning dual variable of problem, default True

  • cvx_solver – the sub solver to use

Returns:

the solver object associated with the solution of this QP

ppopt.solver_interface.gurobi_solver_interface module

ppopt.solver_interface.gurobi_solver_interface.gurobi_pretest(A, b) bool

Simple shortcuts that indicate an unbounded or infeasible LP

Parameters:
  • A – LHS Matrix

  • b – RHS Vector

Returns:

True is not trivial unbounded or infeasible constraints

ppopt.solver_interface.gurobi_solver_interface.solve_lp_gurobi(c: ndarray, A: ndarray, b: ndarray, equality_constraints: Iterable[int] | None = None, verbose: bool = False, get_duals: bool = True) SolverOutput | None

This is the breakout for solving linear programs with gruobi.

\[\min_{x} c^Tx\]
\[\begin{split}\begin{align} Ax &\leq b\\ A_{eq}x &= b_{eq}\\ x &\in R^n\\ \end{align}\end{split}\]
Parameters:
  • c – Column Vector, can be None

  • A – Constraint LHS matrix, can be None

  • b – Constraint RHS matrix, can be None

  • equality_constraints – List of Equality constraints

  • verbose – Flag for output of underlying Solver, default False

  • get_duals – Flag for returning dual variable of problem, default True

Returns:

A SolverOutput Object

ppopt.solver_interface.gurobi_solver_interface.solve_milp_gurobi(c: ndarray, A: ndarray, b: ndarray, equality_constraints: Iterable[int] | None = None, bin_vars: Iterable[int] | None = None, verbose=False, get_duals=True) SolverOutput | None

This is the breakout for solving mixed integer linear programs with gruobi, This is feed directly into the MIQP Solver that is defined in the same file.

\[\min_{xy} c^T[xy]\]
\[\begin{split}\begin{align} A[xy] &\leq b\\ A_{eq}[xy] &= b_{eq}\\ x &\in R^n\\ y &\in \{0, 1\}^m \end{align}\end{split}\]
Parameters:
  • c – Column Vector, can be None

  • A – Constraint LHS matrix, can be None

  • b – Constraint RHS matrix, can be None

  • equality_constraints – List of Equality constraints

  • bin_vars – List of binary variable indices

  • verbose – Flag for output of underlying Solver, default False

  • get_duals – Flag for returning dual variable of problem, default True (false for all mixed integer models)

Returns:

A SolverOutput Object

ppopt.solver_interface.gurobi_solver_interface.solve_miqp_gurobi(Q: ndarray | None = None, c: ndarray | None = None, A: ndarray | None = None, b: ndarray | None = None, equality_constraints: Iterable[int] | None = None, bin_vars: Iterable[int] | None = None, verbose: bool = False, get_duals: bool = True) SolverOutput | None

This is the breakout for solving mixed integer quadratic programs with gruobi

The Mixed Integer Quadratic program programming problem

\[\min_{xy} \frac{1}{2} [xy]^TQ[xy] + c^T[xy]\]
\[\begin{split}\begin{align} A[xy] &\leq b\\ A_{eq}[xy] &= b_{eq}\\ x &\in R^n\\ y &\in \{0, 1\}^m \end{align}\end{split}\]
Parameters:
  • Q – Square matrix, can be None

  • c – Column Vector, can be None

  • A – Constraint LHS matrix, can be None

  • b – Constraint RHS matrix, can be None

  • equality_constraints – List of Equality constraints

  • bin_vars – List of binary variable indices

  • verbose – Flag for output of underlying Solver, default False

  • get_duals – Flag for returning dual variable of problem, default True (false for all mixed integer models)

Returns:

A solver object relating to the solution of the optimization problem

ppopt.solver_interface.gurobi_solver_interface.solve_qp_gurobi(Q: ndarray, c: ndarray, A: ndarray, b: ndarray, equality_constraints: Iterable[int] | None = None, verbose=False, get_duals=True) SolverOutput | None

This is the breakout for solving quadratic programs with gruobi

\[\min_{x} \frac{1}{2}x^TQx + c^Tx\]
\[\begin{split}\begin{align} Ax &\leq b\\ A_{eq}x &= b_{eq}\\ x &\in R^n\\ \end{align}\end{split}\]
Parameters:
  • Q – Square matrix, can be None

  • c – Column Vector, can be None

  • A – Constraint LHS matrix, can be None

  • b – Constraint RHS matrix, can be None

  • equality_constraints – List of Equality constraints

  • verbose – Flag for output of underlying Solver, default False

  • get_duals – Flag for returning dual variable of problem, default True (false for all mixed integer models)

Returns:

A SolverOutput Object

ppopt.solver_interface.quad_prog_interface module

ppopt.solver_interface.quad_prog_interface.solve_qp_quadprog(Q: ndarray, c: ndarray, A: ndarray, b: ndarray, equality_constraints: Iterable[int] | None = None, verbose=False, get_duals: bool = True) SolverOutput | None

Calls Quadprog to solve the following optimization problem

\[\min_{x} \frac{1}{2}x^TQx + c^Tx\]
\[\begin{split}\begin{align} Ax &\leq b\\ A_{eq}x &= b_{eq}\\ x &\in R^n\\ \end{align}\end{split}\]
Parameters:
  • Q – Square matrix, can be None

  • c – Column Vector, can be None

  • A – Constraint LHS matrix, can be None

  • b – Constraint RHS matrix, can be None

  • equality_constraints – List of Equality constraints

  • verbose – Flag for output of underlying Solver, default False

  • get_duals – Flag for returning dual variable of problem, default True (false for all mixed integer models)

Returns:

A SolverOutput object if optima found, otherwise None.

ppopt.solver_interface.solver_interface module

ppopt.solver_interface.solver_interface.solve_lp(c: ndarray | None, A: ndarray | None, b: ndarray | None, equality_constraints=None, verbose=False, get_duals=True, deterministic_solver='gurobi') SolverOutput | None

This is the breakout for solving linear programs

\[\min_{x} c^Tx\]
\[\begin{split}\begin{align} Ax &\leq b\\ A_{eq}x &= b_{eq}\\ x &\in R^n\\ \end{align}\end{split}\]
Parameters:
  • c – Column Vector, can be None

  • A – Constraint LHS matrix, can be None

  • b – Constraint RHS matrix, can be None

  • equality_constraints – List of Equality constraints

  • verbose – Flag for output of underlying Solver, default False

  • get_duals – Flag for returning dual variable of problem, default True (false for all mixed integer models)

  • deterministic_solver – The underlying Solver to use, e.g. gurobi, ect

Returns:

A SolverOutput object if optima found, otherwise None.

ppopt.solver_interface.solver_interface.solve_milp(c: ndarray | None, A: ndarray | None, b: ndarray | None, equality_constraints: Iterable[int] | None = None, bin_vars: Iterable[int] | None = None, verbose=False, get_duals=True, deterministic_solver='gurobi') SolverOutput | None

This is the breakout for solving mixed integer linear programs

\[\min_{xy} c^T[xy]\]
\[\begin{split}\begin{align} A[xy] &\leq b\\ A_{eq}[xy] &= b_{eq}\\ x &\in R^n\\ y &\in \{0, 1\}^m \end{align}\end{split}\]
Parameters:
  • c – Column Vector, can be None

  • A – Constraint LHS matrix, can be None

  • b – Constraint RHS matrix, can be None

  • equality_constraints – List of Equality constraints

  • bin_vars – List of binary variable indices

  • verbose – Flag for output of underlying Solver, default False

  • get_duals – Flag for returning dual variable of problem, default True (false for all mixed integer models)

  • deterministic_solver – The underlying Solver to use, e.g. gurobi, ect

Returns:

A dictionary of the Solver outputs, or none if infeasible or unbounded. output[‘sol’] = primal

variables, output[‘dual’] = dual variables, output[‘obj’] = objective value, output[‘const’] = slacks, output[‘active’] = active constraints.

ppopt.solver_interface.solver_interface.solve_miqp(Q: ndarray | None, c: ndarray | None, A: ndarray | None, b: ndarray | None, equality_constraints: Iterable[int] | None = None, bin_vars: Iterable[int] | None = None, verbose: bool = False, get_duals: bool = True, deterministic_solver='gurobi') SolverOutput | None

This is the breakout for solving mixed integer quadratic programs

\[\min_{xy} \frac{1}{2} [xy]^TQ[xy] + c^T[xy]\]
\[\begin{split}\begin{align} A[xy] &\leq b\\ A_{eq}[xy] &= b_{eq}\\ x &\in R^n\\ y &\in \{0, 1\}^m \end{align}\end{split}\]
Parameters:
  • Q – Square matrix, can be None

  • c – Column Vector, can be None

  • A – Constraint LHS matrix, can be None

  • b – Constraint RHS matrix, can be None

  • equality_constraints – List of Equality constraints

  • bin_vars – List of binary variable indices

  • verbose – Flag for output of underlying Solver, default False

  • get_duals – Flag for returning dual variable of problem, default True (false for all mixed integer models)

  • deterministic_solver – The underlying Solver to use, e.g. gurobi, ect

Returns:

A SolverOutput object if optima found, otherwise None.

ppopt.solver_interface.solver_interface.solve_qp(Q: ndarray | None, c: ndarray | None, A: ndarray | None, b: ndarray | None, equality_constraints: Iterable[int] | None = None, verbose=False, get_duals=True, deterministic_solver='gurobi') SolverOutput | None

This is the breakout for solving quadratic programs

\[\min_{x} \frac{1}{2}x^TQx + c^Tx\]
\[\begin{split}\begin{align} Ax &\leq b\\ A_{eq}x &= b_{eq}\\ x &\in R^n\\ \end{align}\end{split}\]
Parameters:
  • Q – Square matrix, can be None

  • c – Column Vector, can be None

  • A – Constraint LHS matrix, can be None

  • b – Constraint RHS matrix, can be None

  • equality_constraints – List of Equality constraints

  • verbose – Flag for output of underlying Solver, default False

  • get_duals – Flag for returning dual variable of problem, default True (false for all mixed integer models)

  • deterministic_solver – The underlying Solver to use, e.g. gurobi, ect

Returns:

A SolverOutput object if optima found, otherwise None.

ppopt.solver_interface.solver_interface.solver_not_supported(solver_name: str) None

This is an internal method that throws an error and prompts the user when they use an unsupported Solver

ppopt.solver_interface.solver_interface_utils module

class ppopt.solver_interface.solver_interface_utils.SolverOutput(obj: float, sol: ndarray, slack: ndarray | None, active_set: ndarray | None, dual: ndarray | None)

Bases: object

This is the generic Solver information object. This will be the general return object from all the back end solvers. This was done to remove the need for the user to specialize IO for any particular Solver. It contains all the information you would need for the optimization solution including, optimal value, optimal solution, the active set, the value of the slack variables and the largange multipliers associated with every constraint ( these are listed) as the dual variables.

Members: obj: objective value of the optimal solution

sol: x*, numpy array

Optional Parameters -> None or numpy.ndarray type

slack: the slacks associated with every constraint

equality_indices: the active set of the solution, including strongly and weakly active constraints

dual: the lagrange multipliers associated with the problem

active_set: ndarray | None
dual: ndarray | None
obj: float
slack: ndarray | None
sol: ndarray
ppopt.solver_interface.solver_interface_utils.get_program_parameters(Q: ndarray | None, c: ndarray | None, A: ndarray | None, b: ndarray | None)

Given a set of possibly None optimization parameters determine the number of variables and constraints

Module contents

PPOPT.SOLVER INIT FILE - todo fill in.