coin-Bcp
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Knapsack Class Reference

#include <KS.hpp>

Public Member Functions

 Knapsack (int n, double cap, const double *c, const double *w)
 
 ~Knapsack ()
 
void setCosts (const double *c)
 
void setCapacity (double cap)
 
void optimize (double lb=0.0, double minimp=1e-6)
 Return true/false depending on whether the problem is feasible. More...
 
const int * getBestSol () const
 
const double getBestVal () const
 

Private Member Functions

void sortItems (const double *c, const double *w)
 

Private Attributes

double cap_
 The capacity of the knapsack. More...
 
int n_
 The number of items. More...
 
int * perm_
 The permutation corresponding to the ordering (element perm[i] is the i-th in the original order. More...
 
const double * cost_
 The cost of each item (the order is after doing the cost/weight ordering) More...
 
const double * weight_
 The weight of the items (the order is after doing the cost/weight ordering) More...
 
int * x
 The optimal solution in terms of the input order. More...
 
double z
 The optimal solution value. More...
 

Detailed Description

Definition at line 52 of file KS.hpp.

Constructor & Destructor Documentation

Knapsack::Knapsack ( int  n,
double  cap,
const double *  c,
const double *  w 
)
inline

Definition at line 101 of file KS.hpp.

References sortItems().

Knapsack::~Knapsack ( )
inline

Definition at line 106 of file KS.hpp.

References cost_, perm_, weight_, and x.

Member Function Documentation

void Knapsack::sortItems ( const double *  c,
const double *  w 
)
inlineprivate

Definition at line 55 of file KS.hpp.

References triplet::c, cost_, triplet::i, n_, perm_, ratioComp(), triplet::w, and weight_.

Referenced by Knapsack(), and setCosts().

void Knapsack::setCosts ( const double *  c)
inline

Definition at line 113 of file KS.hpp.

References sortItems(), and weight_.

void Knapsack::setCapacity ( double  cap)
inline

Definition at line 116 of file KS.hpp.

References cap_.

void Knapsack::optimize ( double  lb = 0.0,
double  minimp = 1e-6 
)

Return true/false depending on whether the problem is feasible.

Definition at line 128 of file KS.hpp.

References cap_, cost_, n_, perm_, weight_, x, and z.

const int* Knapsack::getBestSol ( ) const
inline

Definition at line 121 of file KS.hpp.

References x.

const double Knapsack::getBestVal ( ) const
inline

Definition at line 122 of file KS.hpp.

References z.

Member Data Documentation

double Knapsack::cap_
private

The capacity of the knapsack.

Definition at line 82 of file KS.hpp.

Referenced by optimize(), and setCapacity().

int Knapsack::n_
private

The number of items.

Definition at line 84 of file KS.hpp.

Referenced by optimize(), and sortItems().

int* Knapsack::perm_
private

The permutation corresponding to the ordering (element perm[i] is the i-th in the original order.

Definition at line 87 of file KS.hpp.

Referenced by optimize(), sortItems(), and ~Knapsack().

const double* Knapsack::cost_
private

The cost of each item (the order is after doing the cost/weight ordering)

Definition at line 90 of file KS.hpp.

Referenced by optimize(), sortItems(), and ~Knapsack().

const double* Knapsack::weight_
private

The weight of the items (the order is after doing the cost/weight ordering)

Definition at line 93 of file KS.hpp.

Referenced by optimize(), setCosts(), sortItems(), and ~Knapsack().

int* Knapsack::x
private

The optimal solution in terms of the input order.

Definition at line 96 of file KS.hpp.

Referenced by getBestSol(), optimize(), and ~Knapsack().

double Knapsack::z
private

The optimal solution value.

Definition at line 98 of file KS.hpp.

Referenced by getBestVal(), and optimize().


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