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

better LB for expansion

parent 24028027
......@@ -14,7 +14,7 @@
#include "heuristic.h"
/*Option de sortie et debug*/
#define DEBUG_MODE true
#define DEBUG_MODE false
#define DISPLAY_ALL false // each iteration
......@@ -512,7 +512,7 @@ int expand(const State& s, std::vector<Node>& node_vector, SparseSet& node_set,
int added_nodes = 0;
// Need available actions and probability distribution in order to expand
std::vector<int> actions = s.get_actions();
std::vector<int> actions = s.get_actions(true); //get all actions, also those breaking the ressource constraint
std::vector<double> action_distribution = get_distribution(s, actions, EXPAND_TEMPERATURE);
Node& current_node(node_vector[current_node_idx]);
......@@ -526,6 +526,10 @@ int expand(const State& s, std::vector<Node>& node_vector, SparseSet& node_set,
added_nodes = 0;
break;
}
if(s.train_size + s.data->train_use(actions[i]) > s.data->T_max){
continue;
}
// Check precedences between siblings
bool precedence = false;
for(size_t j = 0; j < actions.size(); ++j){
......
......@@ -432,7 +432,7 @@ int State::lst(int task) const
return _lst[data->component(task)];
}
std::vector<int> State::get_actions() const
std::vector<int> State::get_actions(bool all) const
{
std::vector<int> actions;
for(int comp = 0; comp < data->nb_components; ++comp)
......@@ -440,13 +440,13 @@ std::vector<int> State::get_actions() const
if(nexts[comp] == NEW_PERIOD)
{
int pick = data->get_pickfull_idx(comp, curr_period[comp]);
if(train_size + data->train_use(pick) <= data->T_max){
if(all || train_size + data->train_use(pick) <= data->T_max){
actions.push_back(pick);
actions.push_back(data->get_pickempty_idx(comp, curr_period[comp]));
}
}else if(nexts[comp] != ENDED)
{
if(train_size + data->train_use(nexts[comp]) <= data->T_max){
if(all || train_size + data->train_use(nexts[comp]) <= data->T_max){
actions.push_back(nexts[comp]);
}
}
......
......@@ -109,7 +109,7 @@ class State
void update(int action);
void rewind(const Solution& sol);
int lst(int task) const;
std::vector<int> get_actions() const;
std::vector<int> get_actions(bool all=false) const;
friend std::ostream& operator << (std::ostream& out, const State& s);
......
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