|
Interior-point-optimisation
1.0-1
Interior-pointoptimisationlibrary
|
This class represents an array of Variable objects. More...
#include <Array.hpp>


Classes | |
| struct | Data |
| Struct to contain Array dataArray. More... | |
Public Types | |
| typedef std::vector< Variable > ::value_type | value_type |
| Value type. More... | |
| typedef std::vector< Variable > ::allocator_type | allocator_type |
| Allocator type. More... | |
| typedef std::vector< Variable > ::size_type | size_type |
| Size type. More... | |
| typedef std::vector< Variable > ::difference_type | difference_type |
| Difference type. More... | |
| typedef std::vector< Variable > ::reference | reference |
| Reference type. More... | |
| typedef std::vector< Variable > ::const_reference | const_reference |
| Const reference type. More... | |
| typedef std::vector< Variable > ::pointer | pointer |
| Pointer type. More... | |
| typedef std::vector< Variable > ::const_pointer | const_pointer |
| Const pointer type. More... | |
| typedef std::vector< Variable > ::iterator | iterator |
| Iterator type. More... | |
| typedef std::vector< Variable > ::const_iterator | const_iterator |
| Const iterator type. More... | |
| typedef std::vector< Variable > ::reverse_iterator | reverse_iterator |
| Reverse iterator type. More... | |
| typedef std::vector< Variable > ::const_reverse_iterator | const_reverse_iterator |
| Const reverse iterator type. More... | |
Public Member Functions | |
| Array (detail::ModelBase &model, allocator_type const &alloc=allocator_type(), char const *const name=nullptr) | |
| Default constructor. More... | |
| Array (detail::ModelBase &model, std::string const &name) | |
| Constructor. More... | |
| Array (detail::ModelBase &model, size_t const size, char const *const name=nullptr) | |
| Create a named array with the given name, initial values 0 and unbounded. More... | |
| Array (detail::ModelBase &model, size_t const size, std::string const &name) | |
| Create a named array with the given name, initial values 0 and unbounded. More... | |
| Array (detail::ModelBase &model, size_t const size, value_type const &val, allocator_type const &alloc, std::string const &name) | |
| Create a named array with the given name, initial values 0 and unbounded. More... | |
| Array (detail::ModelBase &model, size_t const size, value_type const &val, allocator_type const &alloc=allocator_type(), char const *const name=0) | |
| Create a named array with the given name, initial values 0 and unbounded. More... | |
| Array (detail::ModelBase &model, size_t const size, value_type const &val, std::string const &name) | |
| Create a named array with the given name, initial values 0 and unbounded. More... | |
| Array (detail::ModelBase &model, size_t const size, value_type const &val, char const *const name) | |
| Create a named array with the given name, initial values 0 and unbounded. More... | |
| Array (Array const &array) | |
| Copy constructor. More... | |
| Array (Array const &array, allocator_type const &alloc) | |
| Copy constructor. More... | |
| Array (Array &&array) | |
| Move constructor. More... | |
| Array (detail::ModelBase &model, std::initializer_list< Variable > init, std::vector< Variable >::allocator_type const &alloc=std::vector< Variable >::allocator_type(), char const *const name=0) | |
| Initialiser list constructor. More... | |
| Array (detail::ModelBase &model, std::initializer_list< Variable > init, std::vector< Variable >::allocator_type const &alloc, std::string const &name) | |
| Initialiser list constructor. More... | |
| Array (detail::ModelBase &model, std::initializer_list< Variable > init, char const *const name=0) | |
| Initialiser list constructor. More... | |
| Array (detail::ModelBase &model, std::initializer_list< Variable > init, std::string const &name) | |
| Initialiser list constructor. More... | |
| Array & | operator= (Array &&array) |
| Move assignment operator. More... | |
| Array & | operator= (Array &array) |
| Copy assignment operator. More... | |
| std::string | getName () const |
| Get name of variable. More... | |
| void | setName (std::string const &name) |
| Set name of variable. More... | |
| void | setName (char *const name) |
| Set name of variable. More... | |
| void | assign (size_type count, value_type const &value) |
| Assign values. More... | |
| template<typename InputIterator > | |
| void | assign (InputIterator first, InputIterator last) |
| Assign values. More... | |
| void | assign (std::initializer_list< Variable > init) |
| Assign values. More... | |
| allocator_type | get_allocator () const |
| Get allocator. More... | |
| reference | at (size_type pos) |
| Get reference to Variable at position pos. More... | |
| const_reference | at (size_type pos) const |
| Get reference to Variable at position pos. More... | |
| reference | operator[] (size_type pos) |
| Get reference to Variable at position pos. More... | |
| const_reference | operator[] (size_type pos) const |
| Get reference to Variable at position pos. More... | |
| reference | front () |
| Get reference to first Variable. More... | |
| const_reference | front () const |
| Get reference to first Variable. More... | |
| reference | back () |
| Get reference to last Variable. More... | |
| const_reference | back () const |
| Get reference to last Variable. More... | |
| pointer | data () |
| Get direct access to data. More... | |
| const_pointer | data () const |
| Get direct access to data. More... | |
| iterator | begin () |
| Get iterator to beginning of range. More... | |
| const_iterator | begin () const |
| Get iterator to beginning of range. More... | |
| const_iterator | cbegin () const |
| Get iterator to beginning of range. More... | |
| iterator | end () |
| Get iterator to end of range. More... | |
| const_iterator | end () const |
| Get iterator to end of range. More... | |
| const_iterator | cend () const |
| Get iterator to end of range. More... | |
| reverse_iterator | rbegin () |
| Get reverse iterator to beginning of range. More... | |
| const_reverse_iterator | rbegin () const |
| Get reverse iterator to beginning of range. More... | |
| const_reverse_iterator | crbegin () const |
| Get reverse iterator to beginning of range. More... | |
| reverse_iterator | rend () |
| Get reverse iterator to end of range. More... | |
| const_reverse_iterator | rend () const |
| Get reverse iterator to end of range. More... | |
| const_reverse_iterator | crend () const |
| Get reverse iterator to end of range. More... | |
| bool | empty () const |
| Check if array is empty. More... | |
| size_type | size () const |
| Get size of array. More... | |
| size_type | max_size () const |
| Get maximum size of array. More... | |
| void | reserve (size_type size) |
| Reserve capacity. More... | |
| size_type | capacity () const |
| Get capacity of array. More... | |
| void | shrink_to_fit () |
| Free unused memory. More... | |
| void | clear () |
| Clear array. More... | |
| iterator | insert (iterator pos, value_type const &value) |
| Insert value before position given by iterator pos. More... | |
| iterator | insert (iterator pos, value_type &&value) |
| Insert value before position given by iterator pos. More... | |
| void | insert (iterator pos, size_type count, const value_type &value) |
| Insert count copies of value before position given by iterator pos. More... | |
| template<typename InputIterator > | |
| void | insert (iterator pos, InputIterator first, InputIterator last) |
| Insert count copies of value before position given by iterator pos. More... | |
| void | insert (iterator pos, std::initializer_list< Variable > ilist) |
| Insert values before pos. More... | |
| template<class... Args> | |
| iterator | emplace (const_iterator pos, Args &&...args) |
| Insert new value construted in-place before pos. More... | |
| iterator | erase (iterator pos) |
| Erase element specified by pos. More... | |
| iterator | erase (iterator first, iterator last) |
| Erase elements in range [first, last). More... | |
| void | push_back (value_type const &value) |
| Insert value at end of array. More... | |
| void | push_back (value_type &&value) |
| Insert value at end of array. More... | |
| template<typename... Args> | |
| void | emplace_back (Args &&...args) |
| Insert value at end of array. More... | |
| void | pop_back () |
| Remove last element of array. More... | |
| void | resize (size_type count) |
| Resize array. More... | |
| void | resize (size_type count, const value_type &value) |
| Resize array. More... | |
| void | swap (Array &array) |
| Swap contents of container with those of another. More... | |
| bool | contains (Variable const &variable) const |
| Check whether or not array contains variable. More... | |
| void | setValue (gsl::vector const &vector) |
Set the value of this from a gsl::vector. More... | |
| gsl::vector | getValue () const |
Create a gsl::vector containing the values of this in order. More... | |
| virtual void | summary (std::ostream &ostream=std::cout, std::string const &prefix="") const override |
| Create a summary of this Array object. 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... | |
| Var & | operator= (Var &var) |
| Copy assignment operator. More... | |
| Var (Var &&var) | |
| Move constructor. More... | |
| Var & | operator= (Var &&var) |
| Move assignment operator. More... | |
| ModelBase const *const | getModel () const |
| Get pointer to model. More... | |
Private Attributes | |
| std::shared_ptr< Data > | dataArray |
| The Variable dataArray as a shared pointer. More... | |
Friends | |
| bool | ipo::operator== (Array const &, Array const &) |
| bool | ipo::operator!= (Array const &, Array const &) |
| bool | ipo::operator< (Array const &, Array const &) |
| bool | ipo::operator<= (Array const &, Array const &) |
| bool | ipo::operator> (Array const &, Array const &) |
| bool | ipo::operator>= (Array const &, Array const &) |
Additional Inherited Members | |
Protected Attributes inherited from ipo::detail::Var | |
| ModelBase & | model |
| A Model to attach this to. More... | |
This class represents an array of Variable objects.
An object of Array class has optionally a name. A Variable contains a shared pointer to its dataArray so that it is safe and inexpensive to copy Array objects, put them in arrays, pass them as function values, and the like.
This class acts as a random access container and can be used as if it were std::vector<Variable>. Thus, for example, for an object array, for( auto variable : array ){ ... } works as expected.
| typedef std::vector<Variable>::allocator_type ipo::Array::allocator_type |
| typedef std::vector<Variable>::const_iterator ipo::Array::const_iterator |
| typedef std::vector<Variable>::const_pointer ipo::Array::const_pointer |
| typedef std::vector<Variable>::const_reference ipo::Array::const_reference |
| typedef std::vector<Variable>::const_reverse_iterator ipo::Array::const_reverse_iterator |
| typedef std::vector<Variable>::difference_type ipo::Array::difference_type |
| typedef std::vector<Variable>::iterator ipo::Array::iterator |
| typedef std::vector<Variable>::pointer ipo::Array::pointer |
| typedef std::vector<Variable>::reference ipo::Array::reference |
| typedef std::vector<Variable>::reverse_iterator ipo::Array::reverse_iterator |
| typedef std::vector<Variable>::size_type ipo::Array::size_type |
| typedef std::vector<Variable>::value_type ipo::Array::value_type |
| Array::Array | ( | detail::ModelBase & | model, |
| allocator_type const & | alloc = allocator_type(), |
||
| char const *const | name = nullptr |
||
| ) |
Default constructor.
| model | The Model |
| alloc | An allocator |
| name | The name |
Definition at line 113 of file Array.cc.
References ipo::detail::Var::model.
| Array::Array | ( | detail::ModelBase & | model, |
| std::string const & | name | ||
| ) |
| Array::Array | ( | detail::ModelBase & | model, |
| size_t const | size, | ||
| char const *const | name = nullptr |
||
| ) |
Create a named array with the given name, initial values 0 and unbounded.
| model | The Model |
| size | The size of the array |
| name | The name |
Definition at line 126 of file Array.cc.
References ipo::detail::Var::model, and size().
| Array::Array | ( | detail::ModelBase & | model, |
| size_t const | size, | ||
| std::string const & | name | ||
| ) |
| Array::Array | ( | detail::ModelBase & | model, |
| size_t const | size, | ||
| value_type const & | val, | ||
| allocator_type const & | alloc, | ||
| std::string const & | name | ||
| ) |
Create a named array with the given name, initial values 0 and unbounded.
| model | The Model |
| size | The size of the array |
| val | A value |
| alloc | An allocator |
| name | The name |
| Array::Array | ( | detail::ModelBase & | model, |
| size_t const | size, | ||
| value_type const & | val, | ||
| allocator_type const & | alloc = allocator_type(), |
||
| char const *const | name = 0 |
||
| ) |
Create a named array with the given name, initial values 0 and unbounded.
| model | The Model |
| size | The size of the array |
| val | A value |
| alloc | An allocator |
| name | The name |
| Array::Array | ( | detail::ModelBase & | model, |
| size_t const | size, | ||
| value_type const & | val, | ||
| std::string const & | name | ||
| ) |
Create a named array with the given name, initial values 0 and unbounded.
| model | The Model |
| size | The size of the array |
| val | A value |
| name | The name |
| Array::Array | ( | detail::ModelBase & | model, |
| size_t const | size, | ||
| value_type const & | val, | ||
| char const *const | name | ||
| ) |
Create a named array with the given name, initial values 0 and unbounded.
| model | The Model |
| size | The size of the array |
| val | A value |
| name | The name |
| Array::Array | ( | Array const & | array | ) |
Copy constructor.
| array | An Array object to copy |
Definition at line 170 of file Array.cc.
References ipo::detail::Var::model.
| Array::Array | ( | Array const & | array, |
| allocator_type const & | alloc | ||
| ) |
Copy constructor.
| array | An Array object to copy |
| alloc | An allocator |
Definition at line 177 of file Array.cc.
References ipo::detail::Var::model.
|
inline |
| Array::Array | ( | detail::ModelBase & | model, |
| std::initializer_list< Variable > | init, | ||
| std::vector< Variable >::allocator_type const & | alloc = std::vector<Variable>::allocator_type(), |
||
| char const *const | name = 0 |
||
| ) |
Initialiser list constructor.
| model | The Model |
| init | An initialiser list |
| alloc | An allocator |
| name | The name of the array |
| Array::Array | ( | detail::ModelBase & | model, |
| std::initializer_list< Variable > | init, | ||
| std::vector< Variable >::allocator_type const & | alloc, | ||
| std::string const & | name | ||
| ) |
Initialiser list constructor.
| model | The Model |
| init | An initialiser list |
| alloc | An allocator |
| name | The name of the array |
| Array::Array | ( | detail::ModelBase & | model, |
| std::initializer_list< Variable > | init, | ||
| char const *const | name = 0 |
||
| ) |
Initialiser list constructor.
| model | The Model |
| init | An initialiser list |
| name | The name of the array |
| Array::Array | ( | detail::ModelBase & | model, |
| std::initializer_list< Variable > | init, | ||
| std::string const & | name | ||
| ) |
Initialiser list constructor.
| model | The Model |
| init | An initialiser list |
| name | The name of the array |
| void Array::assign | ( | size_type | count, |
| value_type const & | value | ||
| ) |
Assign values.
| count | The new array size |
| value | The initialising value |
Definition at line 269 of file Array.cc.
References dataArray, ipo::detail::Var::getModel(), IPOE, ipo::detail::Var::model, and ipo::detail::ModelBase::notify().
|
inline |
Assign values.
| first | Iterator dereferencable to first value |
| last | Iterator dereferencable to last value |
Definition at line 260 of file Array.hpp.
References dataArray, ipo::detail::Var::getModel(), and IPOE.
| void Array::assign | ( | std::initializer_list< Variable > | init | ) |
Assign values.
| init | An initialiser list |
Definition at line 278 of file Array.cc.
References dataArray, ipo::detail::Var::getModel(), IPOE, ipo::detail::Var::model, and ipo::detail::ModelBase::notify().
|
inline |
|
inline |
|
inline |
|
inline |
Get iterator to beginning of range.
Definition at line 335 of file Array.hpp.
References dataArray.
Referenced by contains().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| bool Array::contains | ( | Variable const & | variable | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Insert new value construted in-place before pos.
| pos | An iterator giving position for insertion |
| args | Arguments to the element constructor |
Definition at line 472 of file Array.hpp.
References dataArray, ipo::detail::Var::getModel(), and IPOE.
|
inline |
|
inline |
|
inline |
Get iterator to end of range.
Definition at line 350 of file Array.hpp.
References dataArray.
Referenced by contains().
|
inline |
Erase element specified by pos.
| pos | An iterator giving position of element to be removed |
Definition at line 487 of file Array.hpp.
References dataArray.
Referenced by ipo::Objective::removeArray().
|
inline |
|
inline |
|
inline |
| std::string Array::getName | ( | ) | const |
Get name of variable.
Definition at line 217 of file Array.cc.
References dataArray.
Referenced by ipo::Objective::addArray(), ipo::Objective::removeArray(), ipo::detail::PhaseIModel::setIndices(), and summary().
| gsl::vector Array::getValue | ( | ) | const |
| Array::iterator Array::insert | ( | iterator | pos, |
| value_type const & | value | ||
| ) |
Insert value before position given by iterator pos.
| pos | An iterator giving position for insertion |
| value | The value to insert |
Definition at line 287 of file Array.cc.
References dataArray, ipo::detail::Var::getModel(), IPOE, ipo::detail::Var::model, and ipo::detail::ModelBase::notify().
| Array::iterator Array::insert | ( | iterator | pos, |
| value_type && | value | ||
| ) |
Insert value before position given by iterator pos.
| pos | An iterator giving position for insertion |
| value | The value to insert |
Definition at line 296 of file Array.cc.
References dataArray, ipo::detail::Var::getModel(), IPOE, ipo::detail::Var::model, and ipo::detail::ModelBase::notify().
| void Array::insert | ( | iterator | pos, |
| size_type | count, | ||
| const value_type & | value | ||
| ) |
Insert count copies of value before position given by iterator pos.
| pos | An iterator giving position for insertion |
| count | The number of copies to insert |
| value | The value to insert |
Definition at line 305 of file Array.cc.
References dataArray, ipo::detail::Var::getModel(), IPOE, ipo::detail::Var::model, and ipo::detail::ModelBase::notify().
|
inline |
Insert count copies of value before position given by iterator pos.
| pos | An iterator giving position for insertion |
| first | Iterator dereferencable to first value |
| last | Iterator dereferencable to last value |
Definition at line 452 of file Array.hpp.
References dataArray, ipo::detail::Var::getModel(), and IPOE.
Insert values before pos.
| pos | An iterator giving position for insertion |
| ilist | An initialiser list |
Definition at line 314 of file Array.cc.
References dataArray, ipo::detail::Var::getModel(), IPOE, ipo::detail::Var::model, and ipo::detail::ModelBase::notify().
|
inline |
Move assignment operator.
| array | The array to be moved |
*this Definition at line 241 of file Array.cc.
References dataArray, IPOE, ipo::detail::Var::model, and ipo::swap().
Copy assignment operator.
| array | The array to be copied |
*this Definition at line 249 of file Array.cc.
References dataArray, IPOE, and ipo::detail::Var::model.
|
inline |
|
inline |
| void Array::push_back | ( | value_type const & | value | ) |
Insert value at end of array.
| value | Variable to add to end of array |
Definition at line 323 of file Array.cc.
References dataArray, ipo::detail::Var::getModel(), IPOE, ipo::detail::Var::model, and ipo::detail::ModelBase::notify().
Referenced by ipo::Objective::addArray(), ipo::detail::ModelFunction::addVariable(), and ipo::detail::PhaseIModel::setIndices().
| void Array::push_back | ( | value_type && | value | ) |
Insert value at end of array.
| value | Variable to add to end of array |
Definition at line 332 of file Array.cc.
References dataArray, ipo::detail::Var::getModel(), IPOE, ipo::detail::Var::model, and ipo::detail::ModelBase::notify().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| void Array::resize | ( | size_type | count, |
| const value_type & | value | ||
| ) |
Resize array.
| count | The new size of the array |
| value | The value to insert in any new elements of the array |
Definition at line 341 of file Array.cc.
References dataArray, ipo::detail::Var::getModel(), IPOE, ipo::detail::Var::model, and ipo::detail::ModelBase::notify().
| void Array::setName | ( | std::string const & | name | ) |
| void Array::setName | ( | char *const | name | ) |
| void Array::setValue | ( | gsl::vector const & | vector | ) |
Set the value of this from a gsl::vector.
| vector | The vector |
| IPOException | if vector size and array size don’t match |
|
inline |
|
inline |
Get size of array.
Definition at line 400 of file Array.hpp.
References dataArray.
Referenced by Array(), ipo::detail::ModelFunction::checkSize(), ipo::detail::ModelFunction::getSizes(), getValue(), ipo::LinearConstraint::setCoefficients(), ipo::Model::setConstraintIndices(), ipo::Model::setIndices(), ipo::Model::setObjectiveIndices(), setValue(), and ipo::Objective::value().
|
overridevirtual |
Create a summary of this Array object.
| ostream | The stream to print to. |
| prefix | This is put in front of every row of output, for example for indentation |
Implements ipo::detail::Var.
Definition at line 372 of file Array.cc.
References getName().
| void Array::swap | ( | Array & | array | ) |
Swap contents of container with those of another.
| array | Array to swap with |
Definition at line 232 of file Array.cc.
References dataArray, ipo::detail::Var::getModel(), IPOE, ipo::detail::Var::model, ipo::detail::ModelBase::notify(), and ipo::swap().
Referenced by ipo::swap().
|
private |
The Variable dataArray as a shared pointer.
Definition at line 672 of file Array.hpp.
Referenced by assign(), at(), back(), begin(), capacity(), cbegin(), cend(), clear(), crbegin(), crend(), data(), emplace(), emplace_back(), empty(), end(), erase(), front(), get_allocator(), getName(), insert(), max_size(), ipo::operator!=(), ipo::operator<(), ipo::operator<=(), operator=(), ipo::operator==(), ipo::operator>(), ipo::operator>=(), operator[](), pop_back(), push_back(), rbegin(), rend(), reserve(), resize(), setName(), shrink_to_fit(), size(), and swap().