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