gravatar
deba@inf.elte.hu
deba@inf.elte.hu
Fix LpBase::addRow(Constr) (#334)
0 1 0
default
1 file changed with 2 insertions and 2 deletions:
↑ Collapse diff ↑
Ignore white space 96 line context
... ...
@@ -1184,100 +1184,100 @@
1184 1184
      e.simplify();
1185 1185
      _setRowCoeffs(rows(id(r)), ExprIterator(e.comps.begin(), cols),
1186 1186
                    ExprIterator(e.comps.end(), cols));
1187 1187
      _setRowLowerBound(rows(id(r)),l - *e);
1188 1188
      _setRowUpperBound(rows(id(r)),u - *e);
1189 1189
    }
1190 1190

	
1191 1191
    ///Set a row (i.e a constraint) of the LP
1192 1192

	
1193 1193
    ///\param r is the row to be modified
1194 1194
    ///\param c is a linear expression (see \ref Constr)
1195 1195
    void row(Row r, const Constr &c) {
1196 1196
      row(r, c.lowerBounded()?c.lowerBound():-INF,
1197 1197
          c.expr(), c.upperBounded()?c.upperBound():INF);
1198 1198
    }
1199 1199

	
1200 1200

	
1201 1201
    ///Get a row (i.e a constraint) of the LP
1202 1202

	
1203 1203
    ///\param r is the row to get
1204 1204
    ///\return the expression associated to the row
1205 1205
    Expr row(Row r) const {
1206 1206
      Expr e;
1207 1207
      _getRowCoeffs(rows(id(r)), InsertIterator(e.comps, cols));
1208 1208
      return e;
1209 1209
    }
1210 1210

	
1211 1211
    ///Add a new row (i.e a new constraint) to the LP
1212 1212

	
1213 1213
    ///\param l is the lower bound (-\ref INF means no bound)
1214 1214
    ///\param e is a linear expression (see \ref Expr)
1215 1215
    ///\param u is the upper bound (\ref INF means no bound)
1216 1216
    ///\return The created row.
1217 1217
    Row addRow(Value l,const Expr &e, Value u) {
1218 1218
      Row r;
1219 1219
      e.simplify();
1220 1220
      r._id = _addRowId(_addRow(l - *e, ExprIterator(e.comps.begin(), cols),
1221 1221
                                ExprIterator(e.comps.end(), cols), u - *e));
1222 1222
      return r;
1223 1223
    }
1224 1224

	
1225 1225
    ///Add a new row (i.e a new constraint) to the LP
1226 1226

	
1227 1227
    ///\param c is a linear expression (see \ref Constr)
1228 1228
    ///\return The created row.
1229 1229
    Row addRow(const Constr &c) {
1230 1230
      Row r;
1231 1231
      c.expr().simplify();
1232
      r._id = _addRowId(_addRow(c.lowerBounded()?c.lowerBound():-INF, 
1232
      r._id = _addRowId(_addRow(c.lowerBounded()?c.lowerBound()-*c.expr():-INF, 
1233 1233
                                ExprIterator(c.expr().comps.begin(), cols),
1234 1234
                                ExprIterator(c.expr().comps.end(), cols),
1235
                                c.upperBounded()?c.upperBound():INF));
1235
                                c.upperBounded()?c.upperBound()-*c.expr():INF));
1236 1236
      return r;
1237 1237
    }
1238 1238
    ///Erase a column (i.e a variable) from the LP
1239 1239

	
1240 1240
    ///\param c is the column to be deleted
1241 1241
    void erase(Col c) {
1242 1242
      _eraseCol(cols(id(c)));
1243 1243
      _eraseColId(cols(id(c)));
1244 1244
    }
1245 1245
    ///Erase a row (i.e a constraint) from the LP
1246 1246

	
1247 1247
    ///\param r is the row to be deleted
1248 1248
    void erase(Row r) {
1249 1249
      _eraseRow(rows(id(r)));
1250 1250
      _eraseRowId(rows(id(r)));
1251 1251
    }
1252 1252

	
1253 1253
    /// Get the name of a column
1254 1254

	
1255 1255
    ///\param c is the coresponding column
1256 1256
    ///\return The name of the colunm
1257 1257
    std::string colName(Col c) const {
1258 1258
      std::string name;
1259 1259
      _getColName(cols(id(c)), name);
1260 1260
      return name;
1261 1261
    }
1262 1262

	
1263 1263
    /// Set the name of a column
1264 1264

	
1265 1265
    ///\param c is the coresponding column
1266 1266
    ///\param name The name to be given
1267 1267
    void colName(Col c, const std::string& name) {
1268 1268
      _setColName(cols(id(c)), name);
1269 1269
    }
1270 1270

	
1271 1271
    /// Get the column by its name
1272 1272

	
1273 1273
    ///\param name The name of the column
1274 1274
    ///\return the proper column or \c INVALID
1275 1275
    Col colByName(const std::string& name) const {
1276 1276
      int k = _colByName(name);
1277 1277
      return k != -1 ? Col(cols[k]) : Col(INVALID);
1278 1278
    }
1279 1279

	
1280 1280
    /// Get the name of a row
1281 1281

	
1282 1282
    ///\param r is the coresponding row
1283 1283
    ///\return The name of the row
0 comments (0 inline)