src/work/athos/lp/lp_test.cc
changeset 1275 16980bf77bd3
parent 1272 17be4c5bc6c6
child 1293 8ede2a6b2594
equal deleted inserted replaced
5:7e44cd021661 6:8ab148606123
   114   e[x[3]]=4;
   114   e[x[3]]=4;
   115   e[x[3]]=1;
   115   e[x[3]]=1;
   116   e.constComp()=12;
   116   e.constComp()=12;
   117   
   117   
   118   lp.addRow(LP::INF,e,23);
   118   lp.addRow(LP::INF,e,23);
   119   lp.addRow(LP::INF,3.0*(p1+p2)-p3,23);
       
   120   lp.addRow(LP::INF,3.0*(x[1]+x[2]/2)-x[3],23);
   119   lp.addRow(LP::INF,3.0*(x[1]+x[2]/2)-x[3],23);
   121   lp.addRow(LP::INF,3.0*(p1+p2*2-5*p3+12-p4/3)+2*p4-4,23);
       
   122   lp.addRow(LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23);
   120   lp.addRow(LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23);
   123 
   121 
   124   lp.addRow(x[1]+x[3]<=x[5]-3);
   122   lp.addRow(x[1]+x[3]<=x[5]-3);
   125   lp.addRow(-7<=x[1]+x[3]-12<=3);
   123   lp.addRow(-7<=x[1]+x[3]-12<=3);
   126   //lp.addRow(x[1]<=x[5]);
   124   lp.addRow(x[1]<=x[5]);
   127 
   125 
   128 }
   126 }
   129 
   127 
   130 
   128 
   131 template<class G,class C>
   129 template<class G,class C>
   141   typedef typename G::OutEdgeIt OutEdgeIt;
   139   typedef typename G::OutEdgeIt OutEdgeIt;
   142   typedef typename G::InEdgeIt InEdgeIt;
   140   typedef typename G::InEdgeIt InEdgeIt;
   143   
   141   
   144   typename G::EdgeMap<LpGlpk::Col> x(g);
   142   typename G::EdgeMap<LpGlpk::Col> x(g);
   145   lp.addColSet(x);
   143   lp.addColSet(x);
   146    //for(EdgeIt e(g);e!=INVALID;++e) x[e]=lp.addCol();
       
   147   
   144   
   148   for(EdgeIt e(g);e!=INVALID;++e) {
   145   for(EdgeIt e(g);e!=INVALID;++e) {
   149     lp.setColUpperBound(x[e],cap[e]);
   146     lp.setColUpperBound(x[e],cap[e]);
   150     lp.setColLowerBound(x[e],0);
   147     lp.setColLowerBound(x[e],0);
   151   }
   148   }
   152 
   149 
   153   for(NodeIt n(g);n!=INVALID;++n) if(n!=s&&n!=t) {
   150   for(NodeIt n(g);n!=INVALID;++n) if(n!=s&&n!=t) {
   154     LpGlpk::Expr ex;
   151     LpGlpk::Expr ex;
   155     for(InEdgeIt  e(g,n);e!=INVALID;++e) ex+=x[e];
   152     for(InEdgeIt  e(g,n);e!=INVALID;++e) ex+=x[e];
   156     for(OutEdgeIt e(g,n);e!=INVALID;++e) ex-=x[e];
   153     for(OutEdgeIt e(g,n);e!=INVALID;++e) ex-=x[e];
   157     lp.addRow(0,ex,0);
   154     lp.addRow(ex==0);
   158   }
   155   }
   159   {
   156   {
   160     LpGlpk::Expr ex;
   157     LpGlpk::Expr ex;
   161     for(InEdgeIt  e(g,t);e!=INVALID;++e) ex+=x[e];
   158     for(InEdgeIt  e(g,t);e!=INVALID;++e) ex+=x[e];
   162     for(OutEdgeIt e(g,t);e!=INVALID;++e) ex-=x[e];
   159     for(OutEdgeIt e(g,t);e!=INVALID;++e) ex-=x[e];
   175 
   172 
   176   lpTest(lp_skel);
   173   lpTest(lp_skel);
   177   lpTest(lp_glpk);
   174   lpTest(lp_glpk);
   178 
   175 
   179   ListGraph g;
   176   ListGraph g;
       
   177   ListGraph::Node s=g.addNode();
       
   178   ListGraph::Node t=g.addNode();
       
   179 
   180   ListGraph::EdgeMap<double> cap(g);
   180   ListGraph::EdgeMap<double> cap(g);
   181   
   181   
   182   maxFlow(g,cap,ListGraph::NodeIt(g),ListGraph::NodeIt(g));
   182   maxFlow(g,cap,s,t);
   183 
   183 
   184 }
   184 }