src/work/athos/lp/lp_test.cc
author athos
Fri, 25 Mar 2005 15:24:18 +0000
changeset 1261 9d0deeea8c08
parent 1256 3bb4ed285c39
child 1263 a490938ad0aa
permissions -rw-r--r--
Low level interface for GLPK (Marci ut?n szabadon)
alpar@1254
     1
#include"lp_solver_skeleton.h"
alpar@1254
     2
alpar@1254
     3
using namespace lemon;
alpar@1254
     4
alpar@1254
     5
int main()
alpar@1254
     6
{
alpar@1256
     7
  typedef LpSolverSkeleton LP;
alpar@1256
     8
  LP lp;
alpar@1256
     9
alpar@1256
    10
  std::vector<LP::Col> x;
alpar@1256
    11
  for(int i=0;i<10;i++) x.push_back(lp.addCol());
alpar@1256
    12
alpar@1256
    13
  std::vector<LP::Col> y(10);
alpar@1256
    14
  lp.addColSet(y);
alpar@1256
    15
alpar@1256
    16
  std::map<int,LP::Col> z;
alpar@1256
    17
  
alpar@1256
    18
  z.insert(std::make_pair(12,INVALID));
alpar@1256
    19
  z.insert(std::make_pair(2,INVALID));
alpar@1256
    20
  z.insert(std::make_pair(7,INVALID));
alpar@1256
    21
  z.insert(std::make_pair(5,INVALID));
alpar@1256
    22
  
alpar@1256
    23
  lp.addColSet(z);
alpar@1256
    24
alpar@1256
    25
alpar@1256
    26
  LP::Expr e;
alpar@1256
    27
  e[x[3]]=2;
alpar@1256
    28
  e[x[3]]=4;
alpar@1256
    29
  e[x[3]]=1;
alpar@1256
    30
  e.constComp()=12;
alpar@1259
    31
alpar@1259
    32
  LP::Col p1,p2,p3,p4,p5;
alpar@1259
    33
  
alpar@1256
    34
  lp.addRow(LP::INF,e,23);
alpar@1259
    35
  lp.addRow(LP::INF,3.0*(p1+p2)-p3,23);
alpar@1259
    36
  lp.addRow(LP::INF,3.0*(x[1]+x[2]/2)-x[3],23);
alpar@1259
    37
  lp.addRow(LP::INF,3.0*(p1+p2*2-5*p3+12-p4/3)+2*p4-4,23);
alpar@1259
    38
  lp.addRow(LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23);
alpar@1254
    39
}