Commit ba0112b6 authored by Valentin Antuori's avatar Valentin Antuori
Browse files

fix bug

parent 3c068e56
......@@ -466,7 +466,7 @@ void DFSRollout::extend_rollout() {
bool can_stop = false;
restore_state();
std::cout << "Restored" << std::endl;
// std::cout << "Restored" << std::endl;
if(get_tardiness() > 0)
{
......@@ -512,14 +512,18 @@ void DFSRollout::extend_rollout() {
}
}
void DFSRollout::do_op(const int op) {
compute_distance(op);
void DFSRollout::do_op(const int op, bool restore) {
maximum_tardiness.push_back(tardiness[op]);
maximum_positive_tardiness.push_back(std::max(0,tardiness[op]));
if(restore)
{
get_operations();
compute_distances();
}else{
// maximum_tardiness.push_back(max(maximum_tardiness.back(), tardiness[op]));
// maximum_positive_tardiness.push_back(std::max(maximum_tardiness.back(),0 ));
compute_distance(op);
maximum_tardiness.push_back(max(maximum_tardiness.back(), tardiness[op]));
maximum_positive_tardiness.push_back(std::max(maximum_tardiness.back(),0));
}
// We shouldn't have tardiness
if(get_tardiness() == 0)
......@@ -634,14 +638,18 @@ void DFSRollout::save_state()
void DFSRollout::restore_state()
{
restore_start(start_level);
std::cout << "Restored to start" << std::endl;
// std::cout << "Restored to start" << std::endl;
while(sequence.size() < saved_sequence.size())
{
do_op(saved_sequence[sequence.size()]);
}
for(int i = 0; i < sequence.size(); ++i){
assert(saved_sequence[i] == sequence[i]);
do_op(saved_sequence[sequence.size()], true);
}
// for(int i = 0; i < sequence.size(); ++i){
// assert(saved_sequence[i] == sequence[i]);
// }
// for(auto elt : maximum_positive_tardiness)
// std::cout << elt << " ";
// std::cout << std::endl;
}
void DFSRollout::restore_start(const int lvl)
......
......@@ -38,7 +38,8 @@ public:
// return the number of fail before stop
int search(int ub, int ub_depth=0);
void do_op(const int op);
// restore = true means that we should compute the complete distances things (used when restore a solution with tardiness)
void do_op(const int op, bool restore=false);
void clear();
void print_step() const;
......
......@@ -294,7 +294,7 @@ Solution solve(const Instance& data, double c, int timeout)
mean_fail_iter = mean_fail_iter + (fail - mean_fail_iter)/count_fail;
}
// finished by a greedy, using the best solution found
std::cout << "Extend" << std::endl;
// std::cout << "Extend" << std::endl;
rollout.extend_rollout();
rollout_depth = rollout.first_tard_depth;
rollout_tardiness = rollout.get_tardiness();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment