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

compute_steiner.c

00001 #include<scil/scil.h>
00002 #include<scil/constraints/path.h>
00003 
00004 using namespace SCIL;
00005 
00006 void ComputeSteinerTree(graph& G, edge_array<double>& Cost, node r,
00007                         node_array<bool>& R, list<edge>& T) {
00008 
00009     cout<<"setupm\n";
00010 
00011   ILP_Problem IP(Optsense_Min);
00012 
00013   cout<<"setup problem\n";
00014 
00015   edge e=nil;
00016   var_map<edge> VM;
00017   forall_edges(e,G) { 
00018     //cout<<Cost[e]<<" cost\n";
00019     VM[e]=IP.add_variable(Cost[e], 0, 1, Vartype_Integer);
00020   }
00021 
00022   node u;
00023   forall_nodes(u, G) {
00024     if(R[u]) {
00025       IP.add_sym_constraint(new PATH(G, r, u, VM));
00026       row r;
00027       forall_in_edges(e,u) r+=(row) VM[e];
00028       IP.add_basic_constraint(r==1);
00029     } else if(u!=r) {
00030 <<<<<<< compute_steiner.c
00031       row r;
00032       forall_in_edges(e, u) r+=(row) VM[e];
00033       forall_out_edges(e, u) r-=(row) VM[e];
00034       IP.add_basic_constraint(r<=0);
00035 =======
00036        row r;
00037        forall_in_edges(e, u) r+=VM[e];
00038        forall_out_edges(e, u) r-=VM[e];
00039        IP.add_basic_constraint(r<=0);
00040 >>>>>>> 1.2
00041     }
00042   }
00043 
00044   cout<<"start optimization\n";
00045   IP.optimize();
00046   
00047   forall_edges(e, G) {
00048     if(IP.get_solution(VM[e])==1) T.append(e);
00049   }
00050 } // END_OF_COMPUTE_STEINER
00051 

Generated on Tue Nov 16 15:18:14 2004 for SCIL by doxygen1.2.16