23 #ifndef BcpsObjectPool_h_
24 #define BcpsObjectPool_h_
28 #include "AlpsKnowledgePool.h"
47 if (! objects_.empty()) {
54 for (
int i = static_cast<int> (objects_.size() - 1); i > -1; --i) {
61 inline void clear(){ objects_.clear(); }
65 objects_.push_back(nk);
70 return static_cast<int>(objects_.size());
75 return std::make_pair(objects_[0], 0.0);
80 {
return objects_.empty() ?
false :
true; }
84 assert(k > -1 && k < ((
int)objects_.size()));
87 std::vector<AlpsKnowledge *>::iterator pos;
88 pos = objects_.begin() + k;
99 AlpsKnowledge *
getObject(
int k)
const {
return objects_[k]; }
150 #endif // End of file
int getNumVariables() const
Query how many variables are in the pool.
BcpsObjectPool()
Default construct.
virtual ~BcpsConstraintPool()
AlpsKnowledge * getObject(int k) const
Get a object.
void deleteObject(int k)
Delete object k from pool.
virtual ~BcpsVariablePool()
const std::vector< AlpsKnowledge * > & getConstraints() const
Get the vector of constraints.
virtual void addKnowledge(AlpsKnowledge *nk, double priority)
Add a knowledge to pool.
virtual bool hasKnowledge() const
Check whether the pool has knowledge.
virtual ~BcpsObjectPool()
Object pool is used to store objects.
const std::vector< AlpsKnowledge * > & getVariables() const
Get the vector of variables.
void clear()
Reset to empty.
void deleteConstraint(int k)
Delete constraint k from pool.
virtual int getNumKnowledges() const
Query how many knowledges are in the pool.
std::vector< AlpsKnowledge * > objects_
const std::vector< AlpsKnowledge * > & getObjects() const
Get all objects.
AlpsKnowledge * getVariable(int k) const
Get the vector of variables.
void addVariable(BcpsVariable *var)
Add a variable to pool.
void addConstraint(BcpsConstraint *con)
Add a constraint to pool.
void freeGuts()
Free object pointers.
void deleteVariable(int k)
Delete variable k from pool.
AlpsKnowledge * getConstraint(int k) const
Get a constraints.
int getNumConstraints() const
Query how many constraints are in the pool.
virtual std::pair< AlpsKnowledge *, double > getKnowledge() const
Query a knowledge, but doesn't remove it from the pool.