28 #ifndef CASTARALGORITHM_H
29 #define CASTARALGORITHM_H
80 virtual double getCost(
const T &sol)=0;
93 int getOptimalSolution(
const T &initialSol,T &finalSol,
double upperLevel=HUGE_VAL,
double maxComputationTime=HUGE_VAL) {
98 std::multimap<double,T> partialSols;
99 partialSols.insert(std::pair<double,T>(
getTotalCost(initialSol),initialSol));
101 double currentOptimal=upperLevel;
103 std::vector<T> children;
105 while (!partialSols.empty()) {
107 if (time.
Tac()>=maxComputationTime)
return found?2:0;
109 double tempCost=it->first;
111 if (tempCost>=currentOptimal)
return found?1:0;
112 T tempSol=it->second;
113 partialSols.erase(it);
116 currentOptimal=tempCost;
124 bool alreadyPresent=
false;
131 if (!alreadyPresent) partialSols.insert(std::pair<double,T>(
getTotalCost(*it2),*it2));