00001 #ifndef SCIL_SOLUTION_CC 00002 #define SCIL_SOLUTION_CC 00003 00004 #include<scil/solution.h> 00005 #include<scil/subproblem.h> 00006 #include<scil/variable.h> 00007 00008 using namespace SCIL; 00009 00010 void solution::save_solution(subproblem& s) { 00011 var v; 00012 sp=&s; 00013 _has_os = true; 00014 forall_variables(v, s) { 00015 if(s.value(v.var_pointer())!=0) { 00016 S[v.var_pointer()]=s.value(v); 00017 } 00018 } 00019 }; 00020 00021 subproblem* solution::originating_subproblem() { 00022 return sp; 00023 }; 00024 00025 void solution::round_to_integer(var v) { 00026 S[v.var_pointer()]=floor(S[v.var_pointer()]+0.5); 00027 }; 00028 00029 double solution::value(var v) { 00030 return S[v.var_pointer()]; 00031 }; 00032 00033 double solution::value(row& r) { 00034 row_entry::list_constiterator re; 00035 double d=0; 00036 foreach(re, r) { 00037 if(re->Var == NULL) 00038 d+=re->coeff; 00039 else 00040 d+=re->coeff*value(re->Var); 00041 } 00042 return d; 00043 }; 00044 00045 #endif