34 std::vector< std::pair<int, int> >
items_;
45 KnapModel(
int cap, std::vector<std::pair<int, int> > items,
int* seq)
50 {
items_.insert(
items_.begin(), items.begin(), items.end()); }
73 AlpsPar_->readFromArglist(argnum, arglist);
76 std::cout <<
"Reading in KNAP parameters ..." << std::endl;
77 std::cout <<
"Reading in ALPS parameters ..." << std::endl;
79 KnapPar_->readFromArglist(argnum, arglist);
83 inline std::pair<int, int>
getItem(
int i)
const {
95 {
items_.push_back(std::pair<int, int>(size, cost)); }
This data structure is to contain the packed form of an encodable knowledge.
AlpsParams * AlpsPar_
The parameter set that is used in Alps.
AlpsModel(const AlpsModel &)
@ msgLevel
The level of printing messages on screen.
std::pair< int, int > getItem(int i) const
Get the size of item i.
void setCapacity(int capacity)
Set the capacity of the knapsack.
int getCapacity() const
Get the capacity of the knapsack.
virtual AlpsEncoded * encode() const
The method that encodes the solution into a buffer.
virtual void readParameters(const int argnum, const char *const *arglist)
Read in Alps and Knap parameters.
void readInstance(const char *dataFile)
Read in the problem data.
KnapParams * KnapPar_
Knap parameters.
KnapModel(int cap, std::vector< std::pair< int, int > > items, int *seq)
void addItem(int size, int cost)
Set the size of item i.
int capacity_
Capacity of the knapsack.
int * getSequence() const
Get the sequence of items in the knapsack.
void setSequence(const int *seq)
Set the sequence of items in the knapsack.
void orderItems()
Order the items based on their cost/size.
int getNumItems() const
Get the number of items in the knapsack.
int * sequence_
The descent sequence based on ratio: profit/size.
virtual void decodeToSelf(AlpsEncoded &)
The method that decodes model data from the encoded form and fill member data.
std::vector< std::pair< int, int > > items_
List of sizes and profits of the items.