Main Page   Class Hierarchy   Compound List   File List   Contact   Download   Symbolic Constraints   Examples  

flow.cc

00001 template <typename Graph>
00002 class FLOW<Graph>::flow_balance : public cons_obj {
00003    private:
00004       typedef typename GraphTraits::vertex_iterator vertex_iterator;
00005       Graph& G;
00006       vertex_iterator v;
00007       scil_map<edge_descriptor>& VM;
00008       row vv;
00009   
00010    public:
00011       flow_balance(Graph& G_, vertex_iterator& v_, 
00012                scil_map<edge_descriptor>& VM_, row vv_)
00013          : cons_obj(Equal, 0), G(G_), 
00014          v(v_), VM(VM_), vv(vv_) {
00015       };
00016 
00017       virtual void non_zero_entries(row& r) {
00018          typename GraphTraits::out_edge_iterator out_i, out_end;
00019          for(tie(out_i,out_end) = out_edges(*v,G); out_i != out_end; out_i++)
00020             r+=VM(*out_i);
00021          typename GraphTraits::in_edge_iterator in_i, in_end;
00022          for(tie(in_i,in_end) = in_edges(*v,G); in_i != in_end; in_i++)
00023             r-=VM(*in_i);
00024          r-=vv;
00025       };
00026 
00027       virtual ~flow_balance() {};
00028 };
00029 
00030  /*{\Mcreate The constraint FLOWs adds the flow preservation constraints for all
00031       nodes, i.e.~
00032       $\sum_{e \in \delta^+(v)} x_e - \sum_{e \in \delta^-(v)} x_e = x_v $.\\
00033       For a demo see: production.}*/
00034 template <typename Graph> 
00035 FLOW<Graph>::FLOW(Graph& G_,
00036    scil_map<vertex_descriptor>& D_,
00037    scil_map<edge_descriptor>& VM_) 
00038    : G(G_), D(D_), VM(VM_) {
00039       //Graph has to provide in_edges() and out_edges()
00040       BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept<Graph>));
00041 };
00042 
00043 template <typename Graph>
00044 void FLOW<Graph>::init(subproblem& S) {
00045    if (S.configuration("FLOW_Debug_Out")=="true")
00046       cerr << "FLOW::init\n";
00047    typename GraphTraits::vertex_iterator v, v_end;
00048    for(tie(v, v_end)=vertices(G); v != v_end; v++)
00049       S.add_basic_constraint(new flow_balance(G, v, VM, D(*v)), Static);
00050 };
00051 
00052 template <typename Graph>
00053 void FLOW<Graph>::info() {
00054    cout<<"Configurations:\n";
00055    cout<<"FLOW_Debug_Out [true|false]\n";
00056 };
Generated on Mon Mar 28 22:03:48 2011 for SCIL by  doxygen 1.6.3