What is the meaning of ecole.rewards.NNodes, and can we fully access the underlying SCIP search tree? #34
-
|
Hi, I have 2 questions which would be great to have answers for to understand Q1In the documentation, Q2Is it possible to fully access the underlying search tree being evolved by import ecole
import pyscipopt
import numpy as npInitialising the problem instance with # init instance
pyscipopt_instance = pyscipopt.Model('example_1') # pyscipmodel
# register decision variables w/ category and bounds
variables = {f'x{i}': pyscipopt_instance.addVar(name=f'x{i}', vtype='I', lb=0, ub=None) for i in range(1, 3)}
# register non-category and non-bounds constraints
pyscipopt_instance.addCons(8000*variables['x1'] + 4000*variables['x2'] <= 40000)
pyscipopt_instance.addCons(15*variables['x1'] + 30*variables['x2'] <= 200)
# register objective
pyscipopt_instance.setObjective(100*variables['x1'] + 150*variables['x2'], sense='maximize')
# turn off helpers so don't instantly solve on env.reset()
pyscipopt_instance.setPresolve(pyscipopt.SCIP_PARAMSETTING.OFF)
pyscipopt_instance.setHeuristics(pyscipopt.SCIP_PARAMSETTING.OFF)
pyscipopt_instance.disablePropagation()
pyscipopt_instance.setSeparating(pyscipopt.SCIP_PARAMSETTING.OFF)Create an ecole branching environment: env = ecole.environment.Branching(
observation_function=(
ecole.observation.NodeBipartite()
),
information_function=({}),
reward_function=({}),
)
env.seed(0) # seed the environment for reproducibilityRun a random brancher in the max_step = 100
n_step = 0
observation, action_set, reward_offset, done, info = env.reset(ecole_instance)
while (not done and n_step<max_step):
print(f'\nStep {n_step}')
print_env_params(env)
# select action and move to next step
action = np.random.choice(action_set)
observation, action_set, reward, done, info = env.step(action)
n_step += 1This results in the following output at each step: What I find is that although there seem to be 2 nodes being added at each branching step (the node ID of Any help in understanding how |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi @cwfparsonson , Here is my understanding of the B&B process and the counting of nodes in SCIP (see also this discussion in SCIP's mailing list). During the solving process, at any point in time the B&B tree consists of:
Processed nodesProcessed really means that a node has already been selected by the node selection strategy. This includes previously processed nodes, and also the currently focused node (see
Open nodesThe open nodes constitute the boundary of the open B&B search space. They are the nodes that are left to be processed (see For practical reasons, SCIP further partitions the open nodes into three sets:
The reason for SCIP to use this partitioning to store the open nodes is I think related to diving. Indeed, it is much more efficient to process immediate siblings or children of the currently focused node next, as a lot of the data structures can be reused efficiently. Hence, node selection rules usually consider child and sibling nodes differently from the rest of the leaf nodes. A final remark: some open nodes sometimes are just discarded by SCIP, and do not appear in any particular counter. This might happen when SCIP finds a new best primal solution, which immediately improve the current global upper bound. Any open node whose value estimate (basically the LP solution value of the parent node) falls above the new global upper bound can be safely pruned by SCIP. Those nodes could be considered objective limit nodes, but are not registered as such by SCIP since they have not been processed. The only way that I am aware of to account for those nodes, assuming that SCIP did not do a restart, is with the following formula: If you unfold this process, you'll realize that in-between two branching calls, usually only there is one additional processed node, as well as one additional open node (two children get in, one selected node gets out). But in some cases SCIP does not branch (infeasible node or objective limit node), which results in 2 or more additional processed node, and no change or a decrease in the number of open nodes. This is supposed to happen, and is actually required for SCIP to prove optimality or infeasibility (when no open node is left). Hope that helps clarify things. @ambros-gleixner, @antoniach or @CGraczyk, please feel free to chime in and correct me if there is any mistake above. Best, |
Beta Was this translation helpful? Give feedback.
Hi @cwfparsonson ,
Here is my understanding of the B&B process and the counting of nodes in SCIP (see also this discussion in SCIP's mailing list).
During the solving process, at any point in time the B&B tree consists of:
Processed nodes
Processed really means that a node has already been selected by the node selection strategy. This includes previously processed nodes, and also the currently focused node (see
SCIPgetNNodes()). Assuming SCIP does no…