Alps  2.0.2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
KnapModel Class Reference

#include <KnapModel.h>

+ Inheritance diagram for KnapModel:
+ Collaboration diagram for KnapModel:

Public Member Functions

 KnapModel ()
 
 KnapModel (int cap, std::vector< std::pair< int, int > > items, int *seq)
 
virtual ~KnapModel ()
 
int getCapacity () const
 Get the capacity of the knapsack. More...
 
int getNumItems () const
 Get the number of items in the knapsack. More...
 
int * getSequence () const
 Get the sequence of items in the knapsack. More...
 
virtual void readParameters (const int argnum, const char *const *arglist)
 Read in Alps and Knap parameters. More...
 
virtual AlpsTreeNodecreateRoot ()
 Create the root node. More...
 
std::pair< int, int > getItem (int i) const
 Get the size of item i. More...
 
void setCapacity (int capacity)
 Set the capacity of the knapsack. More...
 
void setSequence (const int *seq)
 Set the sequence of items in the knapsack. More...
 
void addItem (int size, int cost)
 Set the size of item i. More...
 
void readInstance (const char *dataFile)
 Read in the problem data. More...
 
void orderItems ()
 Order the items based on their cost/size. More...
 
virtual AlpsReturnStatus encode (AlpsEncoded *encoded) const
 Encode this into the given AlpsEncoded object. More...
 
virtual AlpsReturnStatus decodeToSelf (AlpsEncoded &encoded)
 Decode the given AlpsEncoded object into this. More...
 
virtual AlpsKnowledgedecode (AlpsEncoded &encoded) const
 Decode the given AlpsEncoded object into a new AlpsKnowledge object and return a pointer to it. More...
 
AlpsEncodedencode () const
 Get encode from AlpsModel. More...
 
virtual AlpsReturnStatus encode (AlpsEncoded *encoded) const
 Get encode from AlpsModel. More...
 
- Public Member Functions inherited from AlpsModel
 AlpsModel ()
 Default construtor. More...
 
virtual ~AlpsModel ()
 Destructor. More...
 
std::string getDataFile () const
 Get the input file. More...
 
AlpsParamsAlpsPar ()
 Access Alps Parameters. More...
 
void setDataFile (std::string infile)
 Set the data file. More...
 
void writeParameters (std::ostream &outstream) const
 Write out parameters. More...
 
virtual bool setupSelf ()
 Do necessary work to make model ready for use, such as classify variable and constraint types. More...
 
virtual void preprocess ()
 Preprocessing the model. More...
 
virtual void postprocess ()
 Postprocessing results. More...
 
virtual void modelLog ()
 Problem specific log. More...
 
virtual void nodeLog (AlpsTreeNode *node, bool force)
 Node log. More...
 
virtual bool fathomAllNodes ()
 Return true if all nodes on this process can be fathomed. More...
 
virtual void registerKnowledge ()
 Register knowledge class. More...
 
virtual void sendGeneratedKnowledge ()
 Send generated knowledge. More...
 
virtual void receiveGeneratedKnowledge ()
 Receive generated knowledge. More...
 
virtual AlpsEncodedpackSharedKnowlege ()
 Pack knowledge to be shared with others into an encoded object. More...
 
virtual void unpackSharedKnowledge (AlpsEncoded &)
 Unpack and store shared knowledge from an encoded object. More...
 
AlpsEncodedencode () const
 Get encode function defined in AlpsKnowledge. More...
 
virtual AlpsReturnStatus encode (AlpsEncoded *encoded) const
 Get encode function defined in AlpsKnowledge. More...
 
- Public Member Functions inherited from AlpsKnowledge
 AlpsKnowledge ()
 Default constructor. More...
 
 AlpsKnowledge (AlpsKnowledgeType type)
 
 AlpsKnowledge (AlpsKnowledgeType type, AlpsKnowledgeBroker *broker)
 
virtual ~AlpsKnowledge ()
 Destructor. More...
 
AlpsKnowledgeType getType () const
 Get knowledge type. More...
 
void setType (AlpsKnowledgeType t)
 Set knowledge type. More...
 
AlpsKnowledgeBrokerbroker ()
 Get pointer to the knowledge broker. More...
 
const AlpsKnowledgeBrokerbroker () const
 Get pointer to the knowledge broker. More...
 
void setBroker (AlpsKnowledgeBroker *broker)
 Set knowledge broker. More...
 
AlpsEncodedencode () const
 Encode the content of this into an AlpsEncoded object and return a pointer to it. More...
 

Private Member Functions

 KnapModel (KnapModel const &)
 
KnapModeloperator= (KnapModel const &)
 

Private Attributes

int capacity_
 Capacity of the knapsack. More...
 
std::vector< std::pair< int, int > > items_
 List of sizes and profits of the items. More...
 
int * sequence_
 The descent sequence based on ratio: profit/size. More...
 
KnapParamsKnapPar_
 Knap parameters. More...
 

Additional Inherited Members

- Public Attributes inherited from AlpsKnowledge
AlpsKnowledgeBrokerbroker_
 
- Protected Attributes inherited from AlpsModel
std::string dataFile_
 Data file. More...
 
AlpsParamsAlpsPar_
 The parameter set that is used in Alps. More...
 

Detailed Description

Definition at line 39 of file KnapModel.h.

Constructor & Destructor Documentation

◆ KnapModel() [1/3]

KnapModel::KnapModel ( )
inline

Definition at line 51 of file KnapModel.h.

◆ KnapModel() [2/3]

KnapModel::KnapModel ( int  cap,
std::vector< std::pair< int, int > >  items,
int *  seq 
)
inline

Definition at line 52 of file KnapModel.h.

◆ ~KnapModel()

virtual KnapModel::~KnapModel ( )
inlinevirtual

Definition at line 59 of file KnapModel.h.

◆ KnapModel() [3/3]

KnapModel::KnapModel ( KnapModel const &  )
private

Member Function Documentation

◆ getCapacity()

int KnapModel::getCapacity ( ) const
inline

Get the capacity of the knapsack.

Definition at line 68 of file KnapModel.h.

◆ getNumItems()

int KnapModel::getNumItems ( ) const
inline

Get the number of items in the knapsack.

Definition at line 71 of file KnapModel.h.

◆ getSequence()

int* KnapModel::getSequence ( ) const
inline

Get the sequence of items in the knapsack.

Definition at line 74 of file KnapModel.h.

◆ readParameters()

virtual void KnapModel::readParameters ( const int  argnum,
const char *const *  arglist 
)
inlinevirtual

Read in Alps and Knap parameters.

Reimplemented from AlpsModel.

Definition at line 79 of file KnapModel.h.

◆ createRoot()

virtual AlpsTreeNode* KnapModel::createRoot ( )
inlinevirtual

Create the root node.

Default: do nothing

Implements AlpsModel.

Definition at line 89 of file KnapModel.h.

◆ getItem()

std::pair<int, int> KnapModel::getItem ( int  i) const
inline

Get the size of item i.

Definition at line 95 of file KnapModel.h.

◆ setCapacity()

void KnapModel::setCapacity ( int  capacity)
inline

Set the capacity of the knapsack.

Definition at line 100 of file KnapModel.h.

◆ setSequence()

void KnapModel::setSequence ( const int *  seq)

Set the sequence of items in the knapsack.

◆ addItem()

void KnapModel::addItem ( int  size,
int  cost 
)
inline

Set the size of item i.

Definition at line 106 of file KnapModel.h.

◆ readInstance()

void KnapModel::readInstance ( const char *  dataFile)
virtual

Read in the problem data.

Reimplemented from AlpsModel.

◆ orderItems()

void KnapModel::orderItems ( )

Order the items based on their cost/size.

◆ encode() [1/3]

virtual AlpsReturnStatus KnapModel::encode ( AlpsEncoded encoded) const
virtual

Encode this into the given AlpsEncoded object.

Reimplemented from AlpsModel.

◆ decodeToSelf()

virtual AlpsReturnStatus KnapModel::decodeToSelf ( AlpsEncoded encoded)
virtual

Decode the given AlpsEncoded object into this.

Reimplemented from AlpsModel.

◆ decode()

virtual AlpsKnowledge* KnapModel::decode ( AlpsEncoded encoded) const
virtual

Decode the given AlpsEncoded object into a new AlpsKnowledge object and return a pointer to it.

User application sub-classes should implement this since the returned pointer will point to user sub-class instances.

Implements AlpsKnowledge.

◆ operator=()

KnapModel& KnapModel::operator= ( KnapModel const &  )
private

◆ encode() [2/3]

AlpsEncoded* AlpsKnowledge::encode

Get encode from AlpsModel.

◆ encode() [3/3]

virtual AlpsReturnStatus AlpsKnowledge::encode

Get encode from AlpsModel.

Member Data Documentation

◆ capacity_

int KnapModel::capacity_
private

Capacity of the knapsack.

Definition at line 41 of file KnapModel.h.

◆ items_

std::vector< std::pair<int, int> > KnapModel::items_
private

List of sizes and profits of the items.

Definition at line 43 of file KnapModel.h.

◆ sequence_

int* KnapModel::sequence_
private

The descent sequence based on ratio: profit/size.

Definition at line 45 of file KnapModel.h.

◆ KnapPar_

KnapParams* KnapModel::KnapPar_
private

Knap parameters.

Definition at line 47 of file KnapModel.h.


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