lemon/lp_cplex.cc
changeset 2318 45d76c6e7f66
parent 2218 50f1a780a5ff
child 2328 b4931ae52069
equal deleted inserted replaced
16:16ee0a49094e 17:69799e1e24b3
   107     ///\bug return code unchecked for error
   107     ///\bug return code unchecked for error
   108     CPXchgcolname(env, lp, 1, &col, names);    
   108     CPXchgcolname(env, lp, 1, &col, names);    
   109   }
   109   }
   110   
   110   
   111   ///\warning Data at index 0 is ignored in the arrays.
   111   ///\warning Data at index 0 is ignored in the arrays.
   112   void LpCplex::_setRowCoeffs(int i, 
   112   void LpCplex::_setRowCoeffs(int i, LpRowIterator b, LpRowIterator e)
   113 			      int length,
   113   {
   114 			      int  const * indices, 
   114     std::vector<int> indices;
   115 			      Value  const * values )
   115     std::vector<int> rowlist;
   116   {
   116     std::vector<Value> values;
   117     int rowlist[length+1];
   117 
   118     int* p=rowlist;
   118     for(LpRowIterator it=b; it!=e; ++it) {
   119     for (int k=1;k<=length;++k){
   119       indices.push_back(it->first);
   120       rowlist[k]=i;
   120       values.push_back(it->second);
   121     }
   121       rowlist.push_back(i);
   122     status = CPXchgcoeflist(env, lp, 
   122     }
   123 			    length, 
   123 
   124 			    p+1, 
   124     status = CPXchgcoeflist(env, lp, values.size(), 
   125 			    const_cast<int * >(indices+1), 
   125 			    &rowlist[0], &indices[0], &values[0]); 
   126 			    const_cast<Value * >(values+1));
   126   }
   127   }
   127   
   128   
   128   void LpCplex::_setColCoeffs(int i, LpColIterator b, LpColIterator e)
   129   void LpCplex::_setColCoeffs(int i, 
   129   {
   130 			      int length,
   130     std::vector<int> indices;
   131 			      int  const * indices, 
   131     std::vector<int> collist;
   132 			      Value  const * values)
   132     std::vector<Value> values;
   133   {
   133 
   134     int collist[length+1];
   134     for(LpColIterator it=b; it!=e; ++it) {
   135     int* p=collist;
   135       indices.push_back(it->first);
   136     for (int k=1;k<=length;++k){
   136       values.push_back(it->second);
   137       collist[k]=i;
   137       collist.push_back(i);
   138     }
   138     }
   139     status = CPXchgcoeflist(env, lp, 
   139 
   140 			    length, 
   140     status = CPXchgcoeflist(env, lp, values.size(), 
   141 			    const_cast<int * >(indices+1), 
   141 			    &indices[0], &collist[0], &values[0]); 
   142 			    p+1, 
       
   143 			    const_cast<Value * >(values+1));
       
   144   }
   142   }
   145   
   143   
   146   void LpCplex::_setCoeff(int row, int col, Value value) 
   144   void LpCplex::_setCoeff(int row, int col, Value value) 
   147   {
   145   {
   148     CPXchgcoef(env, lp, row, col, value);
   146     CPXchgcoef(env, lp, row, col, value);