Index: src/work/athos/lp/lp_solver_glpk.h
===================================================================
--- src/work/athos/lp/lp_solver_glpk.h	(revision 1243)
+++ src/work/athos/lp/lp_solver_glpk.h	(revision 1260)
@@ -6,33 +6,8 @@
 ///\file
 
-// #include <stdio.h>
-/* #include <stdlib.h> */
-/* #include <iostream> */
-/* #include <map> */
-/* #include <limits> */
-// #include <stdio>
-//#include <stdlib>
 extern "C" {
 #include "glpk.h"
 }
-
-/* #include <iostream> */
-/* #include <vector> */
-/* #include <string> */
-/* #include <list> */
-/* #include <memory> */
-/* #include <utility> */
-
-//#include <lemon/invalid.h>
-//#include <expression.h>
 #include <lp_solver_base.h>
-//#include <stp.h>
-//#include <lemon/max_flow.h>
-//#include <augmenting_flow.h>
-//#include <iter_map.h>
-
-using std::cout;
-using std::cin;
-using std::endl;
 
 namespace lemon {
@@ -47,17 +22,17 @@
   /// This class implements a lemon wrapper for GLPK.
   class LpGlpk : public LpSolverBase<double> {
+
   public:
+
     typedef LpSolverBase<double> Parent;
-
-  public:
+    
     /// \e
     LPX* lp;
 
-  public:
     /// \e
     LpGlpk() : Parent(), 
 			lp(lpx_create_prob()) {
-      int_row_map.push_back(Row());
-      int_col_map.push_back(Col());
+      //int_row_map.push_back(Row());
+      //int_col_map.push_back(Col());
       lpx_set_int_parm(lp, LPX_K_DUAL, 1);
     }
@@ -78,9 +53,14 @@
     }
 
-    //LOW LEVEL INTERFACE, MATRIX MANIPULATING FUNCTIONS
+    /// \e
+    /// Retrieve number of rows
+    int rowNum() const { return lpx_get_num_rows(lp); }
+    /// \e
+    /// Retrieve number of coloumns
+    int colNum() const { return lpx_get_num_cols(lp); }
 
   protected:
     /// \e
-    int _addCol() { 
+    int LpGlpk::_addCol() { 
       int i=lpx_add_cols(lp, 1);
       _setColLowerBound(i, -INF);
@@ -89,5 +69,5 @@
     }
     /// \e
-    int _addRow() { 
+    int LpGlpk::_addRow() { 
       int i=lpx_add_rows(lp, 1);
       return i;
@@ -164,33 +144,70 @@
       lpx_del_rows(lp, 1, rows);
     }
-    void _setCoeff(int col, int row, double value) {
+
+    void _setCoeff(int row, int col, double value) {
       ///FIXME Of course this is not efficient at all, but GLPK knows not more.
-      int change_this;
-      bool get_set_row;
-      //The only thing we can do is optimize on whether working with a row 
-      //or a coloumn
-      int row_num = rowNum();
-      int col_num = colNum();
-      if (col_num<row_num){
-	//There are more rows than coloumns
-	get_set_row=true;
-	int mem_length=1+row_num;
-	int* indices = new int[mem_length];
-	double* doubles = new double[mem_length];
-	int length=lpx_get_mat_col(lp, i, indices, doubles);
-      }else{
-	get_set_row=false;
-	int mem_length=1+col_num;
-	int* indices = new int[mem_length];
-	double* doubles = new double[mem_length];
-	int length=lpx_get_mat_row(lp, i, indices, doubles);
-      }
-      //Itten      
-int* indices = new int[mem_length];
+      /// First approach: get one row, apply changes and set it again
+
+      int mem_length=1+colNum();
+      int* indices = new int[mem_length];
       double* doubles = new double[mem_length];
-      int length=lpx_get_mat_col(lp, i, indices, doubles);
- 
+
+
+      int length=lpx_get_mat_row(lp, i, indices, doubles);
+
+      //The following code does not suppose that the elements of the array indices are sorted
+      int i=1;
+      bool found=false;
+      while (i <= length && !found){
+	if (indices[i]=col){
+	  found = true;
+	  doubles[i]=value;
+	}
+	++i;
+      }
+      if (!found){
+	++length;
+	indices[length]=col;
+	doubles[length]=value;
+      }
+
+// This is a piece of code that assumes that the array 'indices' is sorted. 
+// Not ready, I suppose. 
+//       //We need another arrays to put the data back, anyway
+//       int* new_indices = new int[length+1];
+//       double* new_doubles = new double[length+1];
+//       int offset;
+
+//       int i=1;
+//       while (i <= length && indices[i]<col){
+// 	new_indiced[i]=indices[i];
+// 	new_doubles[i]=doubles[i];
+// 	++i;
+//       }
+//       if (i>length || indices[i]>col){
+// 	//Ha atugrottuk, vagy a vegen van
+// 	new_indices[i]=col;
+// 	new_doubles[i]=value;
+// 	offset = 1;
+//       }
+//       else{
+// 	//I.e.: indices[i]=col
+// 	new_doubles[i]=value;
+// 	offset = 0;
+// 	++i;
+//       }
+//       while (i <= length){
+// 	new_indices[i+offset]=indices[i];
+// 	new_values[i+offset]=values[i];
+//       }
+
+      lpx_set_mat_row(lp, row, length, indices, doubles);
       delete [] indices;
       delete [] doubles;
+
+//       lpx_set_mat_row(lp, row, length+offset, new_indices, new_doubles);
+//       delete [] new_indices;
+//       delete [] new_doubles;
+      
 
     }
@@ -443,91 +460,11 @@
       lpx_set_obj_coef(lp, i, obj_coef);
     }
-  public:
-    /// \e
-    void solveSimplex() { lpx_simplex(lp); }
-    /// \e
-    void solvePrimalSimplex() { lpx_simplex(lp); }
-    /// \e
-    void solveDualSimplex() { lpx_simplex(lp); }
+
   protected:
     virtual double _getPrimal(int i) {
       return lpx_get_col_prim(lp, i);
     }
-  public:
-    /// \e
-    double getObjVal() { return lpx_get_obj_val(lp); }
-    /// \e
-    int rowNum() const { return lpx_get_num_rows(lp); }
-    /// \e
-    int colNum() const { return lpx_get_num_cols(lp); }
-    /// \e
-    int warmUp() { return lpx_warm_up(lp); }
-    /// \e
-    void printWarmUpStatus(int i) {
-      switch (i) {
-      case LPX_E_OK: cout << "LPX_E_OK" << endl; break;
-      case LPX_E_EMPTY: cout << "LPX_E_EMPTY" << endl; break;	
-      case LPX_E_BADB: cout << "LPX_E_BADB" << endl; break;
-      case LPX_E_SING: cout << "LPX_E_SING" << endl; break;
-      }
-    }
-    /// \e
-    int getPrimalStatus() { return lpx_get_prim_stat(lp); }
-    /// \e
-    void printPrimalStatus(int i) {
-      switch (i) {
-      case LPX_P_UNDEF: cout << "LPX_P_UNDEF" << endl; break;
-      case LPX_P_FEAS: cout << "LPX_P_FEAS" << endl; break;	
-      case LPX_P_INFEAS: cout << "LPX_P_INFEAS" << endl; break;
-      case LPX_P_NOFEAS: cout << "LPX_P_NOFEAS" << endl; break;
-      }
-    }
-    /// \e
-    int getDualStatus() { return lpx_get_dual_stat(lp); }
-    /// \e
-    void printDualStatus(int i) {
-      switch (i) {
-      case LPX_D_UNDEF: cout << "LPX_D_UNDEF" << endl; break;
-      case LPX_D_FEAS: cout << "LPX_D_FEAS" << endl; break;	
-      case LPX_D_INFEAS: cout << "LPX_D_INFEAS" << endl; break;
-      case LPX_D_NOFEAS: cout << "LPX_D_NOFEAS" << endl; break;
-      }
-    }
-    /// Returns the status of the slack variable assigned to row \c row.
-    int getRowStat(const Row& row) { 
-      return lpx_get_row_stat(lp, row_iter_map[row]); 
-    }
-    /// \e
-    void printRowStatus(int i) {
-      switch (i) {
-      case LPX_BS: cout << "LPX_BS" << endl; break;
-      case LPX_NL: cout << "LPX_NL" << endl; break;	
-      case LPX_NU: cout << "LPX_NU" << endl; break;
-      case LPX_NF: cout << "LPX_NF" << endl; break;
-      case LPX_NS: cout << "LPX_NS" << endl; break;
-      }
-    }
-    /// Returns the status of the variable assigned to column \c col.
-    int getColStat(const Col& col) { 
-      return lpx_get_col_stat(lp, col_iter_map[col]); 
-    }
-    /// \e
-    void printColStatus(int i) {
-      switch (i) {
-      case LPX_BS: cout << "LPX_BS" << endl; break;
-      case LPX_NL: cout << "LPX_NL" << endl; break;	
-      case LPX_NU: cout << "LPX_NU" << endl; break;
-      case LPX_NF: cout << "LPX_NF" << endl; break;
-      case LPX_NS: cout << "LPX_NS" << endl; break;
-      }
-    }
-
-    // MIP
-    /// \e
-    void solveBandB() { lpx_integer(lp); }
-    /// \e
-    void setLP() { lpx_set_class(lp, LPX_LP); }
-    /// \e
-    void setMIP() { lpx_set_class(lp, LPX_MIP); }
+
+    //MIP
   protected:
     /// \e
@@ -537,4 +474,87 @@
     /// \e
     double _getMIPPrimal(int i) { return lpx_mip_col_val(lp, i); }
+
+
+//   public:
+//     /// \e
+//     void solveSimplex() { lpx_simplex(lp); }
+//     /// \e
+//     void solvePrimalSimplex() { lpx_simplex(lp); }
+//     /// \e
+//     void solveDualSimplex() { lpx_simplex(lp); }
+//     /// \e
+//     double getObjVal() { return lpx_get_obj_val(lp); }
+//     /// \e
+//     int warmUp() { return lpx_warm_up(lp); }
+//     /// \e
+//     void printWarmUpStatus(int i) {
+//       switch (i) {
+//       case LPX_E_OK: cout << "LPX_E_OK" << endl; break;
+//       case LPX_E_EMPTY: cout << "LPX_E_EMPTY" << endl; break;	
+//       case LPX_E_BADB: cout << "LPX_E_BADB" << endl; break;
+//       case LPX_E_SING: cout << "LPX_E_SING" << endl; break;
+//       }
+//     }
+//     /// \e
+//     int getPrimalStatus() { return lpx_get_prim_stat(lp); }
+//     /// \e
+//     void printPrimalStatus(int i) {
+//       switch (i) {
+//       case LPX_P_UNDEF: cout << "LPX_P_UNDEF" << endl; break;
+//       case LPX_P_FEAS: cout << "LPX_P_FEAS" << endl; break;	
+//       case LPX_P_INFEAS: cout << "LPX_P_INFEAS" << endl; break;
+//       case LPX_P_NOFEAS: cout << "LPX_P_NOFEAS" << endl; break;
+//       }
+//     }
+//     /// \e
+//     int getDualStatus() { return lpx_get_dual_stat(lp); }
+//     /// \e
+//     void printDualStatus(int i) {
+//       switch (i) {
+//       case LPX_D_UNDEF: cout << "LPX_D_UNDEF" << endl; break;
+//       case LPX_D_FEAS: cout << "LPX_D_FEAS" << endl; break;	
+//       case LPX_D_INFEAS: cout << "LPX_D_INFEAS" << endl; break;
+//       case LPX_D_NOFEAS: cout << "LPX_D_NOFEAS" << endl; break;
+//       }
+//     }
+//     /// Returns the status of the slack variable assigned to row \c row.
+//     int getRowStat(const Row& row) { 
+//       return lpx_get_row_stat(lp, row_iter_map[row]); 
+//     }
+//     /// \e
+//     void printRowStatus(int i) {
+//       switch (i) {
+//       case LPX_BS: cout << "LPX_BS" << endl; break;
+//       case LPX_NL: cout << "LPX_NL" << endl; break;	
+//       case LPX_NU: cout << "LPX_NU" << endl; break;
+//       case LPX_NF: cout << "LPX_NF" << endl; break;
+//       case LPX_NS: cout << "LPX_NS" << endl; break;
+//       }
+//     }
+//     /// Returns the status of the variable assigned to column \c col.
+//     int getColStat(const Col& col) { 
+//       return lpx_get_col_stat(lp, col_iter_map[col]); 
+//     }
+//     /// \e
+//     void printColStatus(int i) {
+//       switch (i) {
+//       case LPX_BS: cout << "LPX_BS" << endl; break;
+//       case LPX_NL: cout << "LPX_NL" << endl; break;	
+//       case LPX_NU: cout << "LPX_NU" << endl; break;
+//       case LPX_NF: cout << "LPX_NF" << endl; break;
+//       case LPX_NS: cout << "LPX_NS" << endl; break;
+//       }
+//     }
+
+//     // MIP
+//     /// \e
+//     void solveBandB() { lpx_integer(lp); }
+//     /// \e
+//     void setLP() { lpx_set_class(lp, LPX_LP); }
+//     /// \e
+//     void setMIP() { lpx_set_class(lp, LPX_MIP); }
+
+
+
   };
   
