25 #include<ccgsl/vector.hpp>
74 typedef std::vector<Variable>::pointer
pointer;
82 typedef std::vector<Variable>::iterator
iterator;
102 char const*
const name =
nullptr );
135 allocator_type
const& alloc, std::string
const&
name );
156 std::string
const&
name );
166 char const *
const name );
177 Array(
Array const& array, allocator_type
const& alloc );
190 Array( detail::ModelBase& model, std::initializer_list<Variable> init,
191 std::vector<Variable>::allocator_type
const& alloc
192 = std::vector<Variable>::allocator_type(),
193 char const*
const name = 0 );
201 Array( detail::ModelBase& model, std::initializer_list<Variable> init,
202 std::vector<Variable>::allocator_type
const& alloc,
203 std::string
const&
name );
210 Array( detail::ModelBase& model, std::initializer_list<Variable> init,
211 char const*
const name = 0 );
218 Array( detail::ModelBase& model, std::initializer_list<Variable> init,
219 std::string
const&
name );
253 void assign( size_type count, value_type
const& value );
259 template<
typename InputIterator>
260 void assign( InputIterator first, InputIterator last ){
263 throw IPOE(
"iop::Array::assign: at least one variable discarded because it is "
264 "not owned by model that owns array." );
271 void assign( std::initializer_list<Variable> init );
282 reference
at( size_type pos ){ model.notify();
return dataArray->array.at( pos ); }
288 const_reference
at( size_type pos )
const {
return dataArray->array.at( pos ); }
360 const_iterator
cend()
const { model.notify();
return dataArray->array.cend(); }
430 iterator
insert( iterator pos, value_type
const& value );
437 iterator
insert( iterator pos, value_type&& value );
444 void insert( iterator pos, size_type count,
const value_type& value );
451 template<
typename InputIterator>
452 void insert( iterator pos, InputIterator first, InputIterator last ){
453 dataArray->array.insert( pos, first, last );
455 throw IPOE(
"iop::Array::insert: at least one variable discarded because it is "
456 "not owned by model that owns array." );
464 void insert( iterator pos, std::initializer_list<Variable> ilist );
471 template<
class... Args>
472 iterator
emplace( const_iterator pos, Args&&... args ){
474 iterator i =
dataArray->array.emplace( pos, args... );
477 throw IPOE(
"iop::Array::emplace: variable not inserted because it is "
478 "not owned by model that owns array." );
487 iterator
erase( iterator pos ){ model.notify();
return dataArray->array.erase( pos ); }
494 iterator
erase( iterator first, iterator last ){
495 model.notify();
return dataArray->array.erase( first, last ); }
500 void push_back( value_type
const& value );
510 template<
typename... Args>
512 dataArray->array.emplace_back( args... );
515 throw IPOE(
"iop::Array::emplace: variable not inserted because it is "
516 "not owned by model that owns array." );
535 void resize( size_type count,
const value_type& value);
551 void setValue( gsl::vector
const& vector );
563 virtual void summary( std::ostream& ostream = std::cout,
564 std::string
const& prefix =
"" )
const override;
577 std::string
const&
name );
594 std::vector<Variable>::value_type
const& val,
595 std::vector<Variable>::allocator_type alloc, std::string
const& name );
609 std::vector<Variable>::allocator_type
const& alloc );
623 Data( detail::ModelBase& model, std::initializer_list<Variable> init,
624 std::vector<Variable>::allocator_type
const& alloc
625 = std::vector<Variable>::allocator_type(),
626 char const*
const name = 0 );
634 Data( detail::ModelBase& model, std::initializer_list<Variable> init,
635 std::vector<Variable>::allocator_type
const& alloc,
636 std::string
const name );
643 Data( detail::ModelBase& model, std::initializer_list<Variable> init,
644 char const*
const name = 0 );
651 Data( detail::ModelBase& model, std::initializer_list<Variable> init,
652 std::string
const& name );
737 first.
swap( second ); }
const_reverse_iterator rend() const
Get reverse iterator to end of range.
bool operator>=(Array const &lhs, Array const &rhs)
Compare two Array objects.
const_reference front() const
Get reference to first Variable.
void setName(std::string const &name)
Set name of variable.
Var(ModelBase &model)
Constructor needs a model so that variable can only be attached to one model.
void insert(iterator pos, InputIterator first, InputIterator last)
Insert count copies of value before position given by iterator pos.
std::vector< Variable >::pointer pointer
Pointer type.
bool operator!=(Array const &lhs, Array const &rhs)
Compare two Array objects.
std::string name
The name of the array.
const_reverse_iterator crend() const
Get reverse iterator to end of range.
std::vector< Variable >::iterator iterator
Iterator type.
bool operator<(Array const &lhs, Array const &rhs)
Compare two Array objects.
std::vector< Variable >::reverse_iterator reverse_iterator
Reverse iterator type.
reference operator[](size_type pos)
Get reference to Variable at position pos.
std::vector< Variable >::const_pointer const_pointer
Const pointer type.
void swap(Array &array)
Swap contents of container with those of another.
void push_back(value_type const &value)
Insert value at end of array.
iterator erase(iterator first, iterator last)
Erase elements in range [first, last).
reference back()
Get reference to last Variable.
const_reference operator[](size_type pos) const
Get reference to Variable at position pos.
iterator emplace(const_iterator pos, Args &&...args)
Insert new value construted in-place before pos.
void setValue(gsl::vector const &vector)
Set the value of this from a gsl::vector.
std::vector< Variable >::reference reference
Reference type.
const_iterator begin() const
Get iterator to beginning of range.
bool empty() const
Check if array is empty.
std::vector< Variable >::const_iterator const_iterator
Const iterator type.
ModelBase & model
A Model to attach this to.
std::vector< Variable > array
The array.
iterator end()
Get iterator to end of range.
Data(detail::ModelBase &model, std::vector< Variable >::allocator_type alloc, std::string const &name)
Constructor.
std::vector< Variable >::const_reverse_iterator const_reverse_iterator
Const reverse iterator type.
bool contains(Variable const &variable) const
Check whether or not array contains variable.
size_type size() const
Get size of array.
const_reverse_iterator rbegin() const
Get reverse iterator to beginning of range.
void assign(size_type count, value_type const &value)
Assign values.
iterator erase(iterator pos)
Erase element specified by pos.
std::shared_ptr< Data > dataArray
The Variable dataArray as a shared pointer.
#define IPOE(message)
Macro to allow file and line names in exceptions.
std::vector< Variable >::difference_type difference_type
Difference type.
const_reverse_iterator crbegin() const
Get reverse iterator to beginning of range.
Abstract base class for model.
reverse_iterator rbegin()
Get reverse iterator to beginning of range.
Array & operator=(Array &&array)
Move assignment operator.
void shrink_to_fit()
Free unused memory.
reverse_iterator rend()
Get reverse iterator to end of range.
bool operator<=(Array const &lhs, Array const &rhs)
Compare two Array objects.
const_iterator cbegin() const
Get iterator to beginning of range.
void swap(Array &first, Array &second)
Swap contents of container with those of another.
Array(detail::ModelBase &model, allocator_type const &alloc=allocator_type(), char const *const name=nullptr)
Default constructor.
size_type max_size() const
Get maximum size of array.
const_iterator cend() const
Get iterator to end of range.
pointer data()
Get direct access to data.
const_iterator end() const
Get iterator to end of range.
Array(Array &&array)
Move constructor.
gsl::vector getValue() const
Create a gsl::vector containing the values of this in order.
virtual void summary(std::ostream &ostream=std::cout, std::string const &prefix="") const override
Create a summary of this Array object.
This class represents a variable.
std::string getName() const
Get name of variable.
const_reference back() const
Get reference to last Variable.
size_type capacity() const
Get capacity of array.
std::vector< Variable >::value_type value_type
Value type.
This class represents an array of Variable objects.
allocator_type get_allocator() const
Get allocator.
Struct to contain Array dataArray.
const_pointer data() const
Get direct access to data.
void resize(size_type count)
Resize array.
void assign(InputIterator first, InputIterator last)
Assign values.
iterator insert(iterator pos, value_type const &value)
Insert value before position given by iterator pos.
ModelBase const *const getModel() const
Get pointer to model.
Abstract base class for Variable and Array;.
const_reference at(size_type pos) const
Get reference to Variable at position pos.
reference at(size_type pos)
Get reference to Variable at position pos.
void emplace_back(Args &&...args)
Insert value at end of array.
bool operator==(Array const &lhs, Array const &rhs)
Compare two Array objects.
std::vector< Variable >::const_reference const_reference
Const reference type.
std::vector< Variable >::size_type size_type
Size type.
void pop_back()
Remove last element of array.
Data(Data &&dataArray)
Move constructor.
iterator begin()
Get iterator to beginning of range.
std::vector< Variable >::allocator_type allocator_type
Allocator type.
reference front()
Get reference to first Variable.
bool testModelMatch(detail::ModelBase const &model)
Test model match and remove any Vraiable objects that fail.
This namespace holds all the interior-point optimisation classes.
bool operator>(Array const &lhs, Array const &rhs)
Compare two Array objects.
void reserve(size_type size)
Reserve capacity.