Interior-point-optimisation  1.0-1
Interior-pointoptimisationlibrary
ipo::Constraint Class Reference

Class for a constraint function. More...

#include <Constraint.hpp>

Inheritance diagram for ipo::Constraint:
Inheritance graph
Collaboration diagram for ipo::Constraint:
Collaboration graph

Public Member Functions

 Constraint (detail::ModelBase &model, detail::SharedFunctionPtr function, std::string const &name)
 Use this constructor to construct from a ipo_function::SharedFunctionPtr object. More...
 
 Constraint (detail::ModelBase &model, ipo_function::Function *function, std::string const &name)
 Use this constructor to construct from a pointer to a ipo_function::Function object. More...
 
 Constraint (detail::ModelBase &model, ipo_function::Function &function, std::string const &name)
 Constructor. More...
 
 Constraint (detail::ModelBase &model, detail::SharedFunctionPtr function, char const *const name=0)
 Use this constructor to construct from a ipo_function::SharedFunctionPtr object. More...
 
 Constraint (detail::ModelBase &model, ipo_function::Function *function, char const *const name=0)
 Use this constructor to construct from a pointer to a ipo_function::Function object. More...
 
 Constraint (detail::ModelBase &model, ipo_function::Function &function, char const *const name=0)
 Constructor. More...
 
double getUpperBound () const
 Get upper bound of Constraint. More...
 
double getLowerBound () const
 Get lower bound of Constraint. More...
 
virtual void setUpperBound (double const upperBound)
 Set upper bound of Constraint. More...
 
virtual void setLowerBound (double const lowerBound)
 Set lower bound of Constraint. More...
 
 Constraint (Constraint const &constraint)
 Copy constructor. More...
 
Constraintoperator= (Constraint const &constraint)
 Assignment operator. More...
 
 Constraint (Constraint &&constraint)
 Move constructor. More...
 
Constraintoperator= (Constraint &&constraint)
 Move assignment operator. More...
 
virtual void summary (std::ostream &ostream=std::cout, std::string const &prefix="") const override
 Create a summary of this function. More...
 
- Public Member Functions inherited from ipo::Objective
 Objective (detail::ModelBase &model, detail::SharedFunctionPtr function, std::string const &name)
 Use this constructor to construct from a SharedFunctionPtr object. More...
 
 Objective (detail::ModelBase &model, ipo_function::Function *function, std::string const &name)
 Use this constructor to construct from a pointer to a ipo_function::Function object. More...
 
 Objective (detail::ModelBase &model, ipo_function::Function &function, std::string const &name)
 Use this constructor to construct from a ipo_function::Function object by reference. More...
 
 Objective (detail::ModelBase &model, detail::SharedFunctionPtr function, char const *const name=0)
 Use this constructor to construct from a SharedFunctionPtr object. More...
 
 Objective (detail::ModelBase &model, ipo_function::Function *function, char const *const name=0)
 Use this constructor to construct from a pointer to a ipo_function::Function object. More...
 
 Objective (detail::ModelBase &model, ipo_function::Function &function, char const *const name=0)
 Constructor. More...
 
 Objective (Objective const &objective)
 Copy constructor. More...
 
 Objective (Objective &&objective)
 Move constructor. More...
 
Objectiveoperator= (Objective const &objective)
 Assignment operator. More...
 
Objectiveoperator= (Objective &&objective)
 Assignment operator. More...
 
std::string getName () const
 Get name of variable. More...
 
void setName (std::string const &name)
 Set name of Objective. More...
 
void setName (char *const name)
 Set name of Objective. More...
 
ArraygetVariables ()
 Get variables used by Objective function. More...
 
void addVariable (Variable &variable)
 Add a Variable. More...
 
void removeVariable (Variable &variable)
 Remove (first, and usually only occurrence of) a Variable. More...
 
void addArray (Array &array)
 Add an Array. More...
 
void removeArray (Array &array)
 Remove an Array. More...
 
- Public Member Functions inherited from ipo::detail::Var
 Var (ModelBase &model)
 Constructor needs a model so that variable can only be attached to one model. More...
 
virtual ~Var ()=0
 Virtual destructor to make class abstract. More...
 
 Var (Var &var)
 Copy constructor. More...
 
Varoperator= (Var &var)
 Copy assignment operator. More...
 
 Var (Var &&var)
 Move constructor. More...
 
Varoperator= (Var &&var)
 Move assignment operator. More...
 
ModelBase const *const getModel () const
 Get pointer to model. More...
 
- Public Member Functions inherited from ipo::detail::ModelFunction
 ModelFunction (SharedFunctionPtr function)
 Use this constructor to construct from a SharedFunctionPtr object. More...
 
 ModelFunction (ipo_function::Function *function)
 Use this constructor to construct from a pointer to a ipo_function::Function object. More...
 
 ModelFunction (ipo_function::Function &function)
 Use this constructor to construct from a ipo_function::Function object by reference. More...
 
bool checkSize () const
 Check size of vector for function arguments matches number of variables supplied. More...
 
std::tuple< size_t, size_t > getSizes () const
 Get size of vector for function arguments and number of variables supplied. More...
 
virtual ::ipo_function::FunctiongetFunction ()
 Get function. More...
 

Friends

bool ipo::operator== (Constraint const &, Constraint const &)
 

Additional Inherited Members

- Protected Member Functions inherited from ipo::Objective
double value () const noexcept
 Value of the objective function at the current value of the variables. More...
 
- Protected Attributes inherited from ipo::Objective
std::shared_ptr< Datadata
 The objective data. More...
 
- Protected Attributes inherited from ipo::detail::Var
ModelBasemodel
 A Model to attach this to. More...
 
- Protected Attributes inherited from ipo::detail::ModelFunction
SharedFunctionPtr function
 The objective or constraint function. More...
 

Detailed Description

Class for a constraint function.

The function should be set from an object of a subclass of Function. Use getVariables() = ... to specify an Array or Variable for the constraint function to use. Note that setting getVariables() also implicitly determines the size of the vector to be passed to function, but this class does not check the sizes of variables and function arguments match. Note also that if function is destructed before a Constraint object that uses it, the behaviour of the Constraint object is undefined.

A constraint has no effect unless at least one of setUpperBound() or setLowerBound() is used to set a bound. Both can be set, though this only makes sense for a linear constraint.

Definition at line 40 of file Constraint.hpp.

Constructor & Destructor Documentation

Constraint::Constraint ( detail::ModelBase model,
detail::SharedFunctionPtr  function,
std::string const &  name 
)

Use this constructor to construct from a ipo_function::SharedFunctionPtr object.

Parameters
modelA Model
functionA ipo_function::SharedFunctionPtr object
nameA name for this object

Definition at line 28 of file Constraint.cc.

References ipo::detail::Var::model.

Constraint::Constraint ( detail::ModelBase model,
ipo_function::Function function,
std::string const &  name 
)

Use this constructor to construct from a pointer to a ipo_function::Function object.

The Function object should be constructed using new and should not be deleted explicitly.

Parameters
modelA Model
functionA pointer to an object of a subclass of ipo_function::Function
nameA name for this object

Definition at line 32 of file Constraint.cc.

References ipo::detail::Var::model.

Constraint::Constraint ( detail::ModelBase model,
ipo_function::Function function,
std::string const &  name 
)

Constructor.

Parameters
modelA Model
functionAn object of a subclass of ipo_function::Function
nameA name for this object

Definition at line 36 of file Constraint.cc.

References ipo::detail::Var::model.

Constraint::Constraint ( detail::ModelBase model,
detail::SharedFunctionPtr  function,
char const *const  name = 0 
)

Use this constructor to construct from a ipo_function::SharedFunctionPtr object.

Parameters
modelA Model
functionA ipo_function::SharedFunctionPtr object
nameA name for this object

Definition at line 40 of file Constraint.cc.

References ipo::detail::Var::model.

Constraint::Constraint ( detail::ModelBase model,
ipo_function::Function function,
char const *const  name = 0 
)

Use this constructor to construct from a pointer to a ipo_function::Function object.

The Function object should be constructed using new and should not be deleted explicitly.

Parameters
modelA Model
functionA pointer to an object of a subclass of ipo_function::Function
nameA name for this object

Definition at line 44 of file Constraint.cc.

References ipo::detail::Var::model.

Constraint::Constraint ( detail::ModelBase model,
ipo_function::Function function,
char const *const  name = 0 
)

Constructor.

Parameters
modelA Model
functionAn object of a subclass of ipo_function::Function
nameA name for this object

Definition at line 48 of file Constraint.cc.

References ipo::detail::Var::model.

Constraint::Constraint ( Constraint const &  constraint)

Copy constructor.

Parameters
constraintA Constraint object to copy

Definition at line 82 of file Constraint.cc.

ipo::Constraint::Constraint ( Constraint &&  constraint)
inline

Move constructor.

Parameters
constraintA Constraint object to copy

Definition at line 131 of file Constraint.hpp.

Member Function Documentation

double Constraint::getLowerBound ( ) const

Get lower bound of Constraint.

Definition at line 58 of file Constraint.cc.

References ipo::Objective::data.

Referenced by ipo::LinearConstraint::isEqualityConstraint(), and summary().

double Constraint::getUpperBound ( ) const

Get upper bound of Constraint.

Definition at line 53 of file Constraint.cc.

References ipo::Objective::data.

Referenced by ipo::LinearConstraint::isEqualityConstraint(), and summary().

Constraint & Constraint::operator= ( Constraint const &  constraint)

Assignment operator.

Parameters
constraintThe constraint to be copied
Returns
*this

Definition at line 86 of file Constraint.cc.

References ipo::Objective::data, ipo::detail::ModelFunction::function, and ipo::detail::Var::model.

Constraint& ipo::Constraint::operator= ( Constraint &&  constraint)
inline

Move assignment operator.

Parameters
constraintThe constraint to be moved
Returns
*this

Definition at line 137 of file Constraint.hpp.

References ipo::Objective::data, ipo::detail::ModelFunction::function, and ipo::detail::Var::model.

void Constraint::setLowerBound ( double const  lowerBound)
virtual

Set lower bound of Constraint.

This may invalidate value set if the value is less than the lower bound

Parameters
lowerBoundThe new lower bound.
Exceptions
IPOExceptionif new lower bound greater than or equal to upper bound

Reimplemented in ipo::LinearConstraint.

Definition at line 70 of file Constraint.cc.

References ipo::Objective::data, IPOE, and lowerBound.

void Constraint::setUpperBound ( double const  upperBound)
virtual

Set upper bound of Constraint.

This may invalidate value set if the value is not less than the upper bound

Parameters
upperBoundThe new upper bound.
Exceptions
IPOExceptionif new upper bound less than or equal to lower bound

Reimplemented in ipo::LinearConstraint.

Definition at line 63 of file Constraint.cc.

References ipo::Objective::data, IPOE, lowerBound, and upperBound.

void Constraint::summary ( std::ostream &  ostream = std::cout,
std::string const &  prefix = "" 
) const
overridevirtual

Create a summary of this function.

This should be a description of the constraint function and its variables together with the bounds.

Parameters
ostreamThe stream to print to.
prefixThis is put in front of every row of output, for example for indentation

Reimplemented from ipo::Objective.

Definition at line 94 of file Constraint.cc.

References getLowerBound(), ipo::Objective::getName(), getUpperBound(), ipo::format::infinity, and ipo::Objective::value().

Friends And Related Function Documentation

bool ipo::operator== ( Constraint const &  ,
Constraint const &   
)
friend

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