lpinterface
 All Classes Namespaces Files Functions Variables Enumerations Enumerator
Public Member Functions | List of all members
lpint::ILinearProgramHandle Class Referenceabstract

Interface representing linear program formulation. This interface represents linear programs of the form {min, max} c^T x, Ax <= b, x >= 0, where c, x, and b are real-valued vectors, and A is a real-valued matrix. The interface provides methods to modify the LP internally, as well access the LP structure. More...

#include <lp.hpp>

Inheritance diagram for lpint::ILinearProgramHandle:
lpint::LinearProgramHandleGurobi lpint::LinearProgramHandleSoplex

Public Member Functions

 ILinearProgramHandle (const ILinearProgramHandle &)=default
 
 ILinearProgramHandle (ILinearProgramHandle &&)=default
 
ILinearProgramHandleoperator= (const ILinearProgramHandle &)=default
 
ILinearProgramHandleoperator= (ILinearProgramHandle &&)=default
 
virtual std::size_t num_vars () const =0
 Get the number of variables in the LP.
 
virtual std::size_t num_constraints () const =0
 Get the number of cosntraints in the LP.
 
virtual void set_objective_sense (const OptimizationType objsense)=0
 Set the objective sense of this ILinearProgramHandle. The Optimization type can be either OptimizationType::Minimize or OptimizationType::Maximize, which correspond to the LP formulations min c^T * x and max c^T * x, respectively.
 
virtual Variable variable (std::size_t i) const =0
 Retrieve variable i from the internal LP solver. More...
 
virtual std::vector< Variablevariables () const =0
 Retrieve the variables from the internal LP solver. More...
 
virtual void add_variables (const std::vector< Variable > &vars)=0
 Add variables to the LP. More...
 
virtual void add_variables (const std::size_t num_vars)=0
 Add num_vars non-negative variables to the LP. To be called before settings the objective function.
 
virtual void add_constraints (const std::vector< Constraint< double >> &constraints)=0
 Add a set of constraints to the LP formulation. This can only be called after calling set_objective().
 
virtual void remove_constraint (const std::size_t i)=0
 Remove a constraint from the LP. More...
 
virtual void remove_variable (const std::size_t i)=0
 Remove a variable from the LP. More...
 
virtual OptimizationType optimization_type () const =0
 Retrieve the objective sense of this ILinearProgramHandle. The Optimization type can be either OptimizationType::Minimize or OptimizationType::Maximize, which correspond to the LP formulations min c^T * x and max c^T * x, respectively.
 
virtual void set_objective (const Objective< double > &objective)=0
 Set the objective function to be used. This method must be called before calling add_constraints().
 
virtual Constraint< double > constraint (std::size_t i) const =0
 Retrieve constraint i of the internal LP. This method requests a constraint from the internal LP solver backend, copies it, and returns it. Since constraints have to be copied from the backend, this can be an expensive operation, and so should be used sparingly. More...
 
virtual std::vector
< Constraint< double > > 
constraints () const =0
 Retrieve the constraints of the internal LP. This method requests the constraints from the internal LP solver backend, copies them, and returns them in a vector. Since the constraints have to be copied from the backend, this can be quite an expensive operation, and so should not be called in a loop. More...
 
virtual Objective< double > objective () const =0
 Retrieve the objective function of the internal LP. This method requests the objective function values from the LP backend, copies them, and returns them. Since the objective values have to be copied from the backend, this can be quite an expensive operation, and so should not be called in a loop. More...
 

Detailed Description

Interface representing linear program formulation. This interface represents linear programs of the form {min, max} c^T x, Ax <= b, x >= 0, where c, x, and b are real-valued vectors, and A is a real-valued matrix. The interface provides methods to modify the LP internally, as well access the LP structure.

Member Function Documentation

virtual void lpint::ILinearProgramHandle::add_variables ( const std::vector< Variable > &  vars)
pure virtual

Add variables to the LP.

Parameters
varsVector of variables to add.

Implemented in lpint::LinearProgramHandleGurobi, and lpint::LinearProgramHandleSoplex.

virtual Constraint<double> lpint::ILinearProgramHandle::constraint ( std::size_t  i) const
pure virtual

Retrieve constraint i of the internal LP. This method requests a constraint from the internal LP solver backend, copies it, and returns it. Since constraints have to be copied from the backend, this can be an expensive operation, and so should be used sparingly.

Parameters
iIndex of constraint.
Returns
Constraint<double>

Implemented in lpint::LinearProgramHandleSoplex, and lpint::LinearProgramHandleGurobi.

virtual std::vector<Constraint<double> > lpint::ILinearProgramHandle::constraints ( ) const
pure virtual

Retrieve the constraints of the internal LP. This method requests the constraints from the internal LP solver backend, copies them, and returns them in a vector. Since the constraints have to be copied from the backend, this can be quite an expensive operation, and so should not be called in a loop.

Returns
std::vector<Constraint<double>>

Implemented in lpint::LinearProgramHandleSoplex, and lpint::LinearProgramHandleGurobi.

virtual Objective<double> lpint::ILinearProgramHandle::objective ( ) const
pure virtual

Retrieve the objective function of the internal LP. This method requests the objective function values from the LP backend, copies them, and returns them. Since the objective values have to be copied from the backend, this can be quite an expensive operation, and so should not be called in a loop.

Returns
Objective<double>

Implemented in lpint::LinearProgramHandleSoplex, and lpint::LinearProgramHandleGurobi.

virtual void lpint::ILinearProgramHandle::remove_constraint ( const std::size_t  i)
pure virtual

Remove a constraint from the LP.

Parameters
iIndex of the constraint to remove.

Implemented in lpint::LinearProgramHandleGurobi, and lpint::LinearProgramHandleSoplex.

virtual void lpint::ILinearProgramHandle::remove_variable ( const std::size_t  i)
pure virtual

Remove a variable from the LP.

Parameters
iIndex of variable to remove.

Implemented in lpint::LinearProgramHandleGurobi, and lpint::LinearProgramHandleSoplex.

virtual Variable lpint::ILinearProgramHandle::variable ( std::size_t  i) const
pure virtual

Retrieve variable i from the internal LP solver.

Parameters
iIndex of variable to retrieve.
Returns
std::vector<Variable> Vector containing internal LP variables.

Implemented in lpint::LinearProgramHandleGurobi, and lpint::LinearProgramHandleSoplex.

virtual std::vector<Variable> lpint::ILinearProgramHandle::variables ( ) const
pure virtual

Retrieve the variables from the internal LP solver.

Returns
std::vector<Variable> Vector containing internal LP variables.

Implemented in lpint::LinearProgramHandleGurobi, and lpint::LinearProgramHandleSoplex.


The documentation for this class was generated from the following file: