#include <GAP_Knapsack.h>
Public Member Functions | |
Access get methods. | |
const int | getLength () const |
const double | getCapacity () const |
const double * | getProfit () const |
const double * | getWeight () const |
const double * | getProfitSort () const |
const double * | getWeightSort () const |
const int * | getSolution () const |
const double | getOptObj () const |
const SOR_IntDblArr * | getRatio () const |
double * | getMutableProfit () |
double * | getMutableWeight () |
Set methods. | |
void | setLength (const int length) |
Helper Methods. | |
void | populateAndSortRatio (const double *profit=0, const double *weight=0) |
int | solveKnapsack () |
Constructor and Destructor | |
GAP_Knapsack (const int length, const double capacity, const double *profit, const double *weight) | |
Default constructor. | |
~GAP_Knapsack () | |
Default constructor. | |
Private Member Functions | |
Copy Constructors | |
GAP_Knapsack (const GAP_Knapsack &) | |
GAP_Knapsack & | operator= (const GAP_Knapsack &) |
Private Attributes | |
int | m_length |
GAP_Knapsack problem instance data. | |
double | m_capacity |
double * | m_profit |
double * | m_weight |
double * | m_profitSort |
double * | m_weightSort |
int * | m_solution |
double | m_optObj |
SOR_IntDblArr * | m_ratio |
A class to store an instance of the Knapsack Problem
max sum{j = 0..n-1} p[j] x[j] s.t. sum{j = 0..n-1} w[j] x[j] <= b x binary
Definition at line 34 of file GAP_Knapsack.h.
GAP_Knapsack::GAP_Knapsack | ( | const GAP_Knapsack & | ) | [private] |
GAP_Knapsack::GAP_Knapsack | ( | const int | length, | |
const double | capacity, | |||
const double * | profit, | |||
const double * | weight | |||
) | [inline] |
Default constructor.
Takes an instance of UtilParameters
Definition at line 106 of file GAP_Knapsack.h.
References CoinAssert, CoinAssertHint, m_profit, m_profitSort, m_ratio, m_solution, m_weight, m_weightSort, and SOR_IntDblArrNew().
GAP_Knapsack::~GAP_Knapsack | ( | ) | [inline] |
Default constructor.
Takes an instance of UtilParameters
Definition at line 136 of file GAP_Knapsack.h.
References m_profit, m_profitSort, m_ratio, m_solution, m_weight, m_weightSort, SOR_IntDblArrFree(), and UTIL_DELARR.
const int GAP_Knapsack::getLength | ( | ) | const [inline] |
Definition at line 50 of file GAP_Knapsack.h.
References m_length.
const double GAP_Knapsack::getCapacity | ( | ) | const [inline] |
Definition at line 51 of file GAP_Knapsack.h.
References m_capacity.
const double* GAP_Knapsack::getProfit | ( | ) | const [inline] |
Definition at line 52 of file GAP_Knapsack.h.
References m_profit.
const double* GAP_Knapsack::getWeight | ( | ) | const [inline] |
Definition at line 53 of file GAP_Knapsack.h.
References m_weight.
const double* GAP_Knapsack::getProfitSort | ( | ) | const [inline] |
Definition at line 54 of file GAP_Knapsack.h.
References m_profitSort.
const double* GAP_Knapsack::getWeightSort | ( | ) | const [inline] |
Definition at line 55 of file GAP_Knapsack.h.
References m_weightSort.
const int* GAP_Knapsack::getSolution | ( | ) | const [inline] |
Definition at line 56 of file GAP_Knapsack.h.
References m_solution.
const double GAP_Knapsack::getOptObj | ( | ) | const [inline] |
Definition at line 57 of file GAP_Knapsack.h.
References m_optObj.
const SOR_IntDblArr* GAP_Knapsack::getRatio | ( | ) | const [inline] |
Definition at line 58 of file GAP_Knapsack.h.
References m_ratio.
double* GAP_Knapsack::getMutableProfit | ( | ) | [inline] |
Definition at line 59 of file GAP_Knapsack.h.
References m_profit.
double* GAP_Knapsack::getMutableWeight | ( | ) | [inline] |
Definition at line 60 of file GAP_Knapsack.h.
References m_weight.
void GAP_Knapsack::setLength | ( | const int | length | ) | [inline] |
Definition at line 63 of file GAP_Knapsack.h.
References m_length.
void GAP_Knapsack::populateAndSortRatio | ( | const double * | profit = 0 , |
|
const double * | weight = 0 | |||
) | [inline] |
Definition at line 67 of file GAP_Knapsack.h.
References SOR_IntDblArrT::arr, KnapsackSortRatioOut(), m_length, m_profit, m_profitSort, m_ratio, m_weight, and m_weightSort.
int GAP_Knapsack::solveKnapsack | ( | ) | [inline] |
Definition at line 81 of file GAP_Knapsack.h.
References CoinAssert, KnapsackOptimizeHS(), m_capacity, m_length, m_optObj, m_profitSort, m_solution, and m_weightSort.
GAP_Knapsack& GAP_Knapsack::operator= | ( | const GAP_Knapsack & | ) | [private] |
int GAP_Knapsack::m_length [private] |
GAP_Knapsack problem instance data.
Definition at line 38 of file GAP_Knapsack.h.
Referenced by getLength(), populateAndSortRatio(), setLength(), and solveKnapsack().
double GAP_Knapsack::m_capacity [private] |
Definition at line 39 of file GAP_Knapsack.h.
Referenced by getCapacity(), and solveKnapsack().
double* GAP_Knapsack::m_profit [private] |
Definition at line 40 of file GAP_Knapsack.h.
Referenced by GAP_Knapsack(), getMutableProfit(), getProfit(), populateAndSortRatio(), and ~GAP_Knapsack().
double* GAP_Knapsack::m_weight [private] |
Definition at line 41 of file GAP_Knapsack.h.
Referenced by GAP_Knapsack(), getMutableWeight(), getWeight(), populateAndSortRatio(), and ~GAP_Knapsack().
double* GAP_Knapsack::m_profitSort [private] |
Definition at line 42 of file GAP_Knapsack.h.
Referenced by GAP_Knapsack(), getProfitSort(), populateAndSortRatio(), solveKnapsack(), and ~GAP_Knapsack().
double* GAP_Knapsack::m_weightSort [private] |
Definition at line 43 of file GAP_Knapsack.h.
Referenced by GAP_Knapsack(), getWeightSort(), populateAndSortRatio(), solveKnapsack(), and ~GAP_Knapsack().
int* GAP_Knapsack::m_solution [private] |
Definition at line 44 of file GAP_Knapsack.h.
Referenced by GAP_Knapsack(), getSolution(), solveKnapsack(), and ~GAP_Knapsack().
double GAP_Knapsack::m_optObj [private] |
Definition at line 45 of file GAP_Knapsack.h.
Referenced by getOptObj(), and solveKnapsack().
SOR_IntDblArr* GAP_Knapsack::m_ratio [private] |
Definition at line 46 of file GAP_Knapsack.h.
Referenced by GAP_Knapsack(), getRatio(), populateAndSortRatio(), and ~GAP_Knapsack().