1.1 --- a/src/work/marci/lp/lp_solver_wrapper.h Tue Aug 17 13:20:46 2004 +0000
1.2 +++ b/src/work/marci/lp/lp_solver_wrapper.h Thu Aug 19 11:31:40 2004 +0000
1.3 @@ -2,6 +2,10 @@
1.4 #ifndef HUGO_LP_SOLVER_WRAPPER_H
1.5 #define HUGO_LP_SOLVER_WRAPPER
1.6
1.7 +///\ingroup misc
1.8 +///\file
1.9 +///\brief Dijkstra algorithm.
1.10 +
1.11 // #include <stdio.h>
1.12 #include <stdlib.h>
1.13 // #include <stdio>
1.14 @@ -31,6 +35,10 @@
1.15
1.16 namespace hugo {
1.17
1.18 +
1.19 + /// \addtogroup misc
1.20 + /// @{
1.21 +
1.22 /// \brief A partitioned vector with iterable classes.
1.23 ///
1.24 /// This class implements a container in which the data is stored in an
1.25 @@ -119,6 +127,7 @@
1.26 T& operator[](ClassIt it) { return nodes[it.i].data; }
1.27 /// Returns the data pointed by \c it.
1.28 const T& operator[](ClassIt it) const { return nodes[it.i].data; }
1.29 + ///.
1.30 class ClassIt {
1.31 friend class IterablePartition;
1.32 protected:
1.33 @@ -184,17 +193,25 @@
1.34 // };
1.35
1.36 public:
1.37 + ///.
1.38 LPX* lp;
1.39 + ///.
1.40 typedef IterablePartition<int>::ClassIt RowIt;
1.41 + ///.
1.42 IterablePartition<int> row_iter_map;
1.43 + ///.
1.44 typedef IterablePartition<int>::ClassIt ColIt;
1.45 + ///.
1.46 IterablePartition<int> col_iter_map;
1.47 //std::vector<int> row_id_to_lp_row_id;
1.48 //std::vector<int> col_id_to_lp_col_id;
1.49 + ///.
1.50 const int VALID_ID;
1.51 + ///.
1.52 const int INVALID_ID;
1.53
1.54 public:
1.55 + ///.
1.56 LPSolverWrapper() : lp(lpx_create_prob()),
1.57 row_iter_map(2),
1.58 col_iter_map(2),
1.59 @@ -202,15 +219,19 @@
1.60 VALID_ID(0), INVALID_ID(1) {
1.61 lpx_set_int_parm(lp, LPX_K_DUAL, 1);
1.62 }
1.63 + ///.
1.64 ~LPSolverWrapper() {
1.65 lpx_delete_prob(lp);
1.66 }
1.67 + ///.
1.68 void setMinimize() {
1.69 lpx_set_obj_dir(lp, LPX_MIN);
1.70 }
1.71 + ///.
1.72 void setMaximize() {
1.73 lpx_set_obj_dir(lp, LPX_MAX);
1.74 }
1.75 + ///.
1.76 ColIt addCol() {
1.77 int i=lpx_add_cols(lp, 1);
1.78 ColIt col_it;
1.79 @@ -229,6 +250,7 @@
1.80 // lpx_set_obj_coef(lp, i, cost[e]);
1.81 return col_it;
1.82 }
1.83 + ///.
1.84 RowIt addRow() {
1.85 int i=lpx_add_rows(lp, 1);
1.86 RowIt row_it;
1.87 @@ -242,6 +264,7 @@
1.88 return row_it;
1.89 }
1.90 //pair<RowIt, double>-bol kell megadni egy std range-et
1.91 + ///.
1.92 template <typename Begin, typename End>
1.93 void setColCoeffs(const ColIt& col_it,
1.94 Begin begin, End end) {
1.95 @@ -259,6 +282,7 @@
1.96 delete [] doubles;
1.97 }
1.98 //pair<ColIt, double>-bol kell megadni egy std range-et
1.99 + ///.
1.100 template <typename Begin, typename End>
1.101 void setRowCoeffs(const RowIt& row_it,
1.102 Begin begin, End end) {
1.103 @@ -275,6 +299,7 @@
1.104 delete [] indices;
1.105 delete [] doubles;
1.106 }
1.107 + ///.
1.108 void eraseCol(const ColIt& col_it) {
1.109 col_iter_map.set(col_it, VALID_ID, INVALID_ID);
1.110 int cols[2];
1.111 @@ -287,6 +312,7 @@
1.112 if (col_iter_map[it]>cols[1]) --col_iter_map[it];
1.113 }
1.114 }
1.115 + ///.
1.116 void eraseRow(const RowIt& row_it) {
1.117 row_iter_map.set(row_it, VALID_ID, INVALID_ID);
1.118 int rows[2];
1.119 @@ -299,13 +325,16 @@
1.120 if (row_iter_map[it]>rows[1]) --row_iter_map[it];
1.121 }
1.122 }
1.123 + ///.
1.124 void setColBounds(const ColIt& col_it, int bound_type,
1.125 double lo, double up) {
1.126 lpx_set_col_bnds(lp, col_iter_map[col_it], bound_type, lo, up);
1.127 }
1.128 + ///.
1.129 void setObjCoef(const ColIt& col_it, double obj_coef) {
1.130 lpx_set_obj_coef(lp, col_iter_map[col_it], obj_coef);
1.131 }
1.132 + ///.
1.133 void setRowBounds(const RowIt& row_it, int bound_type,
1.134 double lo, double up) {
1.135 lpx_set_row_bnds(lp, row_iter_map[row_it], bound_type, lo, up);
1.136 @@ -313,16 +342,25 @@
1.137 // void setObjCoef(const RowIt& row_it, double obj_coef) {
1.138 // lpx_set_obj_coef(lp, row_iter_map[row_it], obj_coef);
1.139 // }
1.140 + ///.
1.141 void solveSimplex() { lpx_simplex(lp); }
1.142 + ///.
1.143 void solvePrimalSimplex() { lpx_simplex(lp); }
1.144 + ///.
1.145 void solveDualSimplex() { lpx_simplex(lp); }
1.146 + ///.
1.147 double getPrimal(const ColIt& col_it) {
1.148 return lpx_get_col_prim(lp, col_iter_map[col_it]);
1.149 }
1.150 + ///.
1.151 double getObjVal() { return lpx_get_obj_val(lp); }
1.152 + ///.
1.153 int rowNum() const { return lpx_get_num_rows(lp); }
1.154 + ///.
1.155 int colNum() const { return lpx_get_num_cols(lp); }
1.156 + ///.
1.157 int warmUp() { return lpx_warm_up(lp); }
1.158 + ///.
1.159 void printWarmUpStatus(int i) {
1.160 switch (i) {
1.161 case LPX_E_OK: cout << "LPX_E_OK" << endl; break;
1.162 @@ -331,7 +369,9 @@
1.163 case LPX_E_SING: cout << "LPX_E_SING" << endl; break;
1.164 }
1.165 }
1.166 + ///.
1.167 int getPrimalStatus() { return lpx_get_prim_stat(lp); }
1.168 + ///.
1.169 void printPrimalStatus(int i) {
1.170 switch (i) {
1.171 case LPX_P_UNDEF: cout << "LPX_P_UNDEF" << endl; break;
1.172 @@ -340,7 +380,9 @@
1.173 case LPX_P_NOFEAS: cout << "LPX_P_NOFEAS" << endl; break;
1.174 }
1.175 }
1.176 + ///.
1.177 int getDualStatus() { return lpx_get_dual_stat(lp); }
1.178 + ///.
1.179 void printDualStatus(int i) {
1.180 switch (i) {
1.181 case LPX_D_UNDEF: cout << "LPX_D_UNDEF" << endl; break;
1.182 @@ -353,6 +395,7 @@
1.183 int getRowStat(const RowIt& row_it) {
1.184 return lpx_get_row_stat(lp, row_iter_map[row_it]);
1.185 }
1.186 + ///.
1.187 void printRowStatus(int i) {
1.188 switch (i) {
1.189 case LPX_BS: cout << "LPX_BS" << endl; break;
1.190 @@ -366,6 +409,7 @@
1.191 int getColStat(const ColIt& col_it) {
1.192 return lpx_get_col_stat(lp, col_iter_map[col_it]);
1.193 }
1.194 + ///.
1.195 void printColStatus(int i) {
1.196 switch (i) {
1.197 case LPX_BS: cout << "LPX_BS" << endl; break;
1.198 @@ -376,6 +420,8 @@
1.199 }
1.200 }
1.201 };
1.202 +
1.203 + /// @}
1.204
1.205 } //namespace hugo
1.206