lpinterface
 All Classes Namespaces Files Functions Variables Enumerations Enumerator
Public Member Functions | List of all members
lpint::LinearProgramHandleGurobi Class Reference
Inheritance diagram for lpint::LinearProgramHandleGurobi:
lpint::ILinearProgramHandle

Public Member Functions

 LinearProgramHandleGurobi (detail::Badge< GurobiSolver >, std::shared_ptr< GRBmodel > grbmodel, std::shared_ptr< GRBenv > grbenv)
 
std::size_t num_vars () const override
 Get the number of variables in the LP.
 
std::size_t num_constraints () const override
 Get the number of cosntraints in the LP.
 
void set_objective_sense (const OptimizationType objsense) override
 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.
 
Variable variable (std::size_t i) const override
 Retrieve variable i from the internal LP solver. More...
 
std::vector< Variablevariables () const override
 Retrieve the variables from the internal LP solver. More...
 
void add_variables (const std::vector< Variable > &vars) override
 Add variables to the LP. More...
 
void add_variables (const std::size_t num_vars) override
 Add num_vars non-negative variables to the LP. To be called before settings the objective function.
 
void add_constraints (const std::vector< Constraint< double >> &constraints) override
 Add a set of constraints to the LP formulation. This can only be called after calling set_objective().
 
void remove_variable (const std::size_t i) override
 Remove a variable from the LP. More...
 
void remove_constraint (std::size_t i) override
 Remove a constraint from the LP. More...
 
OptimizationType optimization_type () const override
 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.
 
void set_objective (const Objective< double > &objective) override
 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 override
 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...
 
std::vector< Constraint< double > > constraints () const override
 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...
 
Objective< double > objective () const override
 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...
 
std::shared_ptr< GRBmodel > gurobi_model (detail::Badge< GurobiSolver >) const
 
std::shared_ptr< GRBenv > gurobi_env (detail::Badge< GurobiSolver >) const
 
void set_num_vars (detail::Badge< GurobiSolver >, std::size_t nvars)
 
- Public Member Functions inherited from lpint::ILinearProgramHandle
 ILinearProgramHandle (const ILinearProgramHandle &)=default
 
 ILinearProgramHandle (ILinearProgramHandle &&)=default
 
ILinearProgramHandleoperator= (const ILinearProgramHandle &)=default
 
ILinearProgramHandleoperator= (ILinearProgramHandle &&)=default
 

Member Function Documentation

void lpint::LinearProgramHandleGurobi::add_variables ( const std::vector< Variable > &  vars)
overridevirtual

Add variables to the LP.

Parameters
varsVector of variables to add.

Implements lpint::ILinearProgramHandle.

virtual Constraint<double> lpint::LinearProgramHandleGurobi::constraint ( std::size_t  i) const
overridevirtual

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>

Implements lpint::ILinearProgramHandle.

std::vector<Constraint<double> > lpint::LinearProgramHandleGurobi::constraints ( ) const
overridevirtual

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>>

Implements lpint::ILinearProgramHandle.

Objective<double> lpint::LinearProgramHandleGurobi::objective ( ) const
overridevirtual

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>

Implements lpint::ILinearProgramHandle.

void lpint::LinearProgramHandleGurobi::remove_constraint ( std::size_t  i)
overridevirtual

Remove a constraint from the LP.

Parameters
iIndex of the constraint to remove.

Implements lpint::ILinearProgramHandle.

void lpint::LinearProgramHandleGurobi::remove_variable ( const std::size_t  i)
overridevirtual

Remove a variable from the LP.

Parameters
iIndex of variable to remove.

Implements lpint::ILinearProgramHandle.

Variable lpint::LinearProgramHandleGurobi::variable ( std::size_t  i) const
overridevirtual

Retrieve variable i from the internal LP solver.

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

Implements lpint::ILinearProgramHandle.

std::vector<Variable> lpint::LinearProgramHandleGurobi::variables ( ) const
overridevirtual

Retrieve the variables from the internal LP solver.

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

Implements lpint::ILinearProgramHandle.


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