gravatar
tapolcai@tmit.bme.hu
tapolcai@tmit.bme.hu
Dirty hacking for VS 2005 in lp_base.h (#209)
0 1 0
default
1 file changed with 24 insertions and 24 deletions:
↑ Collapse diff ↑
Show white space 192 line context
... ...
@@ -1290,259 +1290,259 @@
1290 1290
    }
1291 1291

	
1292 1292
    /// Get an element of the coefficient matrix of the LP
1293 1293

	
1294 1294
    ///\param r is the row of the element
1295 1295
    ///\param c is the column of the element
1296 1296
    ///\return the corresponding coefficient
1297 1297
    Value coeff(Row r, Col c) const {
1298 1298
      return _getCoeff(rows(id(r)),cols(id(c)));
1299 1299
    }
1300 1300

	
1301 1301
    /// Set the lower bound of a column (i.e a variable)
1302 1302

	
1303 1303
    /// The lower bound of a variable (column) has to be given by an
1304 1304
    /// extended number of type Value, i.e. a finite number of type
1305 1305
    /// Value or -\ref INF.
1306 1306
    void colLowerBound(Col c, Value value) {
1307 1307
      _setColLowerBound(cols(id(c)),value);
1308 1308
    }
1309 1309

	
1310 1310
    /// Get the lower bound of a column (i.e a variable)
1311 1311

	
1312 1312
    /// This function returns the lower bound for column (variable) \c c
1313 1313
    /// (this might be -\ref INF as well).
1314 1314
    ///\return The lower bound for column \c c
1315 1315
    Value colLowerBound(Col c) const {
1316 1316
      return _getColLowerBound(cols(id(c)));
1317 1317
    }
1318 1318

	
1319 1319
    ///\brief Set the lower bound of  several columns
1320 1320
    ///(i.e variables) at once
1321 1321
    ///
1322 1322
    ///This magic function takes a container as its argument
1323 1323
    ///and applies the function on all of its elements.
1324 1324
    ///The lower bound of a variable (column) has to be given by an
1325 1325
    ///extended number of type Value, i.e. a finite number of type
1326 1326
    ///Value or -\ref INF.
1327 1327
#ifdef DOXYGEN
1328 1328
    template<class T>
1329 1329
    void colLowerBound(T &t, Value value) { return 0;}
1330 1330
#else
1331 1331
    template<class T>
1332 1332
    typename enable_if<typename T::value_type::LpCol,void>::type
1333 1333
    colLowerBound(T &t, Value value,dummy<0> = 0) {
1334 1334
      for(typename T::iterator i=t.begin();i!=t.end();++i) {
1335 1335
        colLowerBound(*i, value);
1336 1336
      }
1337 1337
    }
1338 1338
    template<class T>
1339 1339
    typename enable_if<typename T::value_type::second_type::LpCol,
1340 1340
                       void>::type
1341 1341
    colLowerBound(T &t, Value value,dummy<1> = 1) {
1342 1342
      for(typename T::iterator i=t.begin();i!=t.end();++i) {
1343 1343
        colLowerBound(i->second, value);
1344 1344
      }
1345 1345
    }
1346 1346
    template<class T>
1347 1347
    typename enable_if<typename T::MapIt::Value::LpCol,
1348 1348
                       void>::type
1349 1349
    colLowerBound(T &t, Value value,dummy<2> = 2) {
1350 1350
      for(typename T::MapIt i(t); i!=INVALID; ++i){
1351 1351
        colLowerBound(*i, value);
1352 1352
      }
1353 1353
    }
1354 1354
#endif
1355 1355

	
1356 1356
    /// Set the upper bound of a column (i.e a variable)
1357 1357

	
1358 1358
    /// The upper bound of a variable (column) has to be given by an
1359 1359
    /// extended number of type Value, i.e. a finite number of type
1360 1360
    /// Value or \ref INF.
1361 1361
    void colUpperBound(Col c, Value value) {
1362 1362
      _setColUpperBound(cols(id(c)),value);
1363 1363
    };
1364 1364

	
1365 1365
    /// Get the upper bound of a column (i.e a variable)
1366 1366

	
1367 1367
    /// This function returns the upper bound for column (variable) \c c
1368 1368
    /// (this might be \ref INF as well).
1369 1369
    /// \return The upper bound for column \c c
1370 1370
    Value colUpperBound(Col c) const {
1371 1371
      return _getColUpperBound(cols(id(c)));
1372 1372
    }
1373 1373

	
1374 1374
    ///\brief Set the upper bound of  several columns
1375 1375
    ///(i.e variables) at once
1376 1376
    ///
1377 1377
    ///This magic function takes a container as its argument
1378 1378
    ///and applies the function on all of its elements.
1379 1379
    ///The upper bound of a variable (column) has to be given by an
1380 1380
    ///extended number of type Value, i.e. a finite number of type
1381 1381
    ///Value or \ref INF.
1382 1382
#ifdef DOXYGEN
1383 1383
    template<class T>
1384 1384
    void colUpperBound(T &t, Value value) { return 0;}
1385 1385
#else
1386
    template<class T>
1387
    typename enable_if<typename T::value_type::LpCol,void>::type
1388
    colUpperBound(T &t, Value value,dummy<0> = 0) {
1389
      for(typename T::iterator i=t.begin();i!=t.end();++i) {
1386
    template<class T1>
1387
    typename enable_if<typename T1::value_type::LpCol,void>::type
1388
    colUpperBound(T1 &t, Value value,dummy<0> = 0) {
1389
      for(typename T1::iterator i=t.begin();i!=t.end();++i) {
1390 1390
        colUpperBound(*i, value);
1391 1391
      }
1392 1392
    }
1393
    template<class T>
1394
    typename enable_if<typename T::value_type::second_type::LpCol,
1393
    template<class T1>
1394
    typename enable_if<typename T1::value_type::second_type::LpCol,
1395 1395
                       void>::type
1396
    colUpperBound(T &t, Value value,dummy<1> = 1) {
1397
      for(typename T::iterator i=t.begin();i!=t.end();++i) {
1396
    colUpperBound(T1 &t, Value value,dummy<1> = 1) {
1397
      for(typename T1::iterator i=t.begin();i!=t.end();++i) {
1398 1398
        colUpperBound(i->second, value);
1399 1399
      }
1400 1400
    }
1401
    template<class T>
1402
    typename enable_if<typename T::MapIt::Value::LpCol,
1401
    template<class T1>
1402
    typename enable_if<typename T1::MapIt::Value::LpCol,
1403 1403
                       void>::type
1404
    colUpperBound(T &t, Value value,dummy<2> = 2) {
1405
      for(typename T::MapIt i(t); i!=INVALID; ++i){
1404
    colUpperBound(T1 &t, Value value,dummy<2> = 2) {
1405
      for(typename T1::MapIt i(t); i!=INVALID; ++i){
1406 1406
        colUpperBound(*i, value);
1407 1407
      }
1408 1408
    }
1409 1409
#endif
1410 1410

	
1411 1411
    /// Set the lower and the upper bounds of a column (i.e a variable)
1412 1412

	
1413 1413
    /// The lower and the upper bounds of
1414 1414
    /// a variable (column) have to be given by an
1415 1415
    /// extended number of type Value, i.e. a finite number of type
1416 1416
    /// Value, -\ref INF or \ref INF.
1417 1417
    void colBounds(Col c, Value lower, Value upper) {
1418 1418
      _setColLowerBound(cols(id(c)),lower);
1419 1419
      _setColUpperBound(cols(id(c)),upper);
1420 1420
    }
1421 1421

	
1422 1422
    ///\brief Set the lower and the upper bound of several columns
1423 1423
    ///(i.e variables) at once
1424 1424
    ///
1425 1425
    ///This magic function takes a container as its argument
1426 1426
    ///and applies the function on all of its elements.
1427 1427
    /// The lower and the upper bounds of
1428 1428
    /// a variable (column) have to be given by an
1429 1429
    /// extended number of type Value, i.e. a finite number of type
1430 1430
    /// Value, -\ref INF or \ref INF.
1431 1431
#ifdef DOXYGEN
1432 1432
    template<class T>
1433 1433
    void colBounds(T &t, Value lower, Value upper) { return 0;}
1434 1434
#else
1435
    template<class T>
1436
    typename enable_if<typename T::value_type::LpCol,void>::type
1437
    colBounds(T &t, Value lower, Value upper,dummy<0> = 0) {
1438
      for(typename T::iterator i=t.begin();i!=t.end();++i) {
1435
    template<class T2>
1436
    typename enable_if<typename T2::value_type::LpCol,void>::type
1437
    colBounds(T2 &t, Value lower, Value upper,dummy<0> = 0) {
1438
      for(typename T2::iterator i=t.begin();i!=t.end();++i) {
1439 1439
        colBounds(*i, lower, upper);
1440 1440
      }
1441 1441
    }
1442
    template<class T>
1443
    typename enable_if<typename T::value_type::second_type::LpCol, void>::type
1444
    colBounds(T &t, Value lower, Value upper,dummy<1> = 1) {
1445
      for(typename T::iterator i=t.begin();i!=t.end();++i) {
1442
    template<class T2>
1443
    typename enable_if<typename T2::value_type::second_type::LpCol, void>::type
1444
    colBounds(T2 &t, Value lower, Value upper,dummy<1> = 1) {
1445
      for(typename T2::iterator i=t.begin();i!=t.end();++i) {
1446 1446
        colBounds(i->second, lower, upper);
1447 1447
      }
1448 1448
    }
1449
    template<class T>
1450
    typename enable_if<typename T::MapIt::Value::LpCol, void>::type
1451
    colBounds(T &t, Value lower, Value upper,dummy<2> = 2) {
1452
      for(typename T::MapIt i(t); i!=INVALID; ++i){
1449
    template<class T2>
1450
    typename enable_if<typename T2::MapIt::Value::LpCol, void>::type
1451
    colBounds(T2 &t, Value lower, Value upper,dummy<2> = 2) {
1452
      for(typename T2::MapIt i(t); i!=INVALID; ++i){
1453 1453
        colBounds(*i, lower, upper);
1454 1454
      }
1455 1455
    }
1456 1456
#endif
1457 1457

	
1458 1458
    /// Set the lower bound of a row (i.e a constraint)
1459 1459

	
1460 1460
    /// The lower bound of a constraint (row) has to be given by an
1461 1461
    /// extended number of type Value, i.e. a finite number of type
1462 1462
    /// Value or -\ref INF.
1463 1463
    void rowLowerBound(Row r, Value value) {
1464 1464
      _setRowLowerBound(rows(id(r)),value);
1465 1465
    }
1466 1466

	
1467 1467
    /// Get the lower bound of a row (i.e a constraint)
1468 1468

	
1469 1469
    /// This function returns the lower bound for row (constraint) \c c
1470 1470
    /// (this might be -\ref INF as well).
1471 1471
    ///\return The lower bound for row \c r
1472 1472
    Value rowLowerBound(Row r) const {
1473 1473
      return _getRowLowerBound(rows(id(r)));
1474 1474
    }
1475 1475

	
1476 1476
    /// Set the upper bound of a row (i.e a constraint)
1477 1477

	
1478 1478
    /// The upper bound of a constraint (row) has to be given by an
1479 1479
    /// extended number of type Value, i.e. a finite number of type
1480 1480
    /// Value or -\ref INF.
1481 1481
    void rowUpperBound(Row r, Value value) {
1482 1482
      _setRowUpperBound(rows(id(r)),value);
1483 1483
    }
1484 1484

	
1485 1485
    /// Get the upper bound of a row (i.e a constraint)
1486 1486

	
1487 1487
    /// This function returns the upper bound for row (constraint) \c c
1488 1488
    /// (this might be -\ref INF as well).
1489 1489
    ///\return The upper bound for row \c r
1490 1490
    Value rowUpperBound(Row r) const {
1491 1491
      return _getRowUpperBound(rows(id(r)));
1492 1492
    }
1493 1493

	
1494 1494
    ///Set an element of the objective function
1495 1495
    void objCoeff(Col c, Value v) {_setObjCoeff(cols(id(c)),v); };
1496 1496

	
1497 1497
    ///Get an element of the objective function
1498 1498
    Value objCoeff(Col c) const { return _getObjCoeff(cols(id(c))); };
1499 1499

	
1500 1500
    ///Set the objective function
1501 1501

	
1502 1502
    ///\param e is a linear expression of type \ref Expr.
1503 1503
    ///
1504 1504
    void obj(const Expr& e) {
1505 1505
      _setObjCoeffs(ExprIterator(e.comps.begin(), cols),
1506 1506
                    ExprIterator(e.comps.end(), cols));
1507 1507
      obj_const_comp = *e;
1508 1508
    }
1509 1509

	
1510 1510
    ///Get the objective function
1511 1511

	
1512 1512
    ///\return the objective function as a linear expression of type
1513 1513
    ///Expr.
1514 1514
    Expr obj() const {
1515 1515
      Expr e;
1516 1516
      _getObjCoeffs(InsertIterator(e.comps, cols));
1517 1517
      *e = obj_const_comp;
1518 1518
      return e;
1519 1519
    }
1520 1520

	
1521 1521

	
1522 1522
    ///Set the direction of optimization
1523 1523
    void sense(Sense sense) { _setSense(sense); }
1524 1524

	
1525 1525
    ///Query the direction of the optimization
1526 1526
    Sense sense() const {return _getSense(); }
1527 1527

	
1528 1528
    ///Set the sense to maximization
1529 1529
    void max() { _setSense(MAX); }
1530 1530

	
1531 1531
    ///Set the sense to maximization
1532 1532
    void min() { _setSense(MIN); }
1533 1533

	
1534 1534
    ///Clears the problem
1535 1535
    void clear() { _clear(); }
1536 1536

	
1537 1537
    ///@}
1538 1538

	
1539 1539
  };
1540 1540

	
1541 1541
  /// Addition
1542 1542

	
1543 1543
  ///\relates LpBase::Expr
1544 1544
  ///
1545 1545
  inline LpBase::Expr operator+(const LpBase::Expr &a, const LpBase::Expr &b) {
1546 1546
    LpBase::Expr tmp(a);
1547 1547
    tmp+=b;
1548 1548
    return tmp;
0 comments (0 inline)