Knapsack Class Reference

#include <KS.hpp>

List of all members.

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


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 
) [inline, private]

Definition at line 55 of file KS.hpp.

References 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:
Generated on Thu Jan 15 03:03:22 2009 for coin-Bcp by  doxygen 1.4.7