Scippy

    SCIP

    Solving Constraint Integer Programs

    scip_tree.h
    Go to the documentation of this file.
    1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    2/* */
    3/* This file is part of the program and library */
    4/* SCIP --- Solving Constraint Integer Programs */
    5/* */
    6/* Copyright (c) 2002-2025 Zuse Institute Berlin (ZIB) */
    7/* */
    8/* Licensed under the Apache License, Version 2.0 (the "License"); */
    9/* you may not use this file except in compliance with the License. */
    10/* You may obtain a copy of the License at */
    11/* */
    12/* http://www.apache.org/licenses/LICENSE-2.0 */
    13/* */
    14/* Unless required by applicable law or agreed to in writing, software */
    15/* distributed under the License is distributed on an "AS IS" BASIS, */
    16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
    17/* See the License for the specific language governing permissions and */
    18/* limitations under the License. */
    19/* */
    20/* You should have received a copy of the Apache-2.0 license */
    21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
    22/* */
    23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    24
    25/**@file scip_tree.h
    26 * @ingroup PUBLICCOREAPI
    27 * @brief public methods for the branch-and-bound tree
    28 * @author Tobias Achterberg
    29 * @author Timo Berthold
    30 * @author Thorsten Koch
    31 * @author Alexander Martin
    32 * @author Marc Pfetsch
    33 * @author Kati Wolter
    34 * @author Gregor Hendel
    35 * @author Leona Gottwald
    36 */
    37
    38/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
    39
    40#ifndef __SCIP_SCIP_TREE_H__
    41#define __SCIP_SCIP_TREE_H__
    42
    43
    44#include "scip/def.h"
    45#include "scip/type_retcode.h"
    46#include "scip/type_scip.h"
    47#include "scip/type_tree.h"
    48
    49#ifdef __cplusplus
    50extern "C" {
    51#endif
    52
    53/**@addtogroup PublicTreeMethods
    54 *
    55 * @{
    56 */
    57
    58/** gets focus node in the tree
    59 *
    60 * if we are in probing/diving mode this method returns the node in the tree where the probing/diving mode was started.
    61 *
    62 * @return the current node of the search tree
    63 *
    64 * @pre This method can be called if @p scip is in one of the following stages:
    65 * - \ref SCIP_STAGE_INITPRESOLVE
    66 * - \ref SCIP_STAGE_PRESOLVING
    67 * - \ref SCIP_STAGE_EXITPRESOLVE
    68 * - \ref SCIP_STAGE_SOLVING
    69 */
    70SCIP_EXPORT
    72 SCIP* scip /**< SCIP data structure */
    73 );
    74
    75/** gets current node in the tree
    76 *
    77 * @return the current node of the search tree
    78 *
    79 * @pre This method can be called if @p scip is in one of the following stages:
    80 * - \ref SCIP_STAGE_INITPRESOLVE
    81 * - \ref SCIP_STAGE_PRESOLVING
    82 * - \ref SCIP_STAGE_EXITPRESOLVE
    83 * - \ref SCIP_STAGE_SOLVING
    84 */
    85SCIP_EXPORT
    87 SCIP* scip /**< SCIP data structure */
    88 );
    89
    90/** gets depth of current node, or -1 if no current node exists; in probing, the current node is the last probing node,
    91 * such that the depth includes the probing path
    92 *
    93 * @return the depth of current node, or -1 if no current node exists; in probing, the current node is the last probing node,
    94 * such that the depth includes the probing path
    95 *
    96 * @pre This method can be called if SCIP is in one of the following stages:
    97 * - \ref SCIP_STAGE_TRANSFORMED
    98 * - \ref SCIP_STAGE_INITPRESOLVE
    99 * - \ref SCIP_STAGE_PRESOLVING
    100 * - \ref SCIP_STAGE_EXITPRESOLVE
    101 * - \ref SCIP_STAGE_PRESOLVED
    102 * - \ref SCIP_STAGE_INITSOLVE
    103 * - \ref SCIP_STAGE_SOLVING
    104 * - \ref SCIP_STAGE_SOLVED
    105 * - \ref SCIP_STAGE_EXITSOLVE
    106 */
    107SCIP_EXPORT
    108int SCIPgetDepth(
    109 SCIP* scip /**< SCIP data structure */
    110 );
    111
    112/** gets depth of the focus node, or -1 if no focus node exists; the focus node is the currently processed node in the
    113 * branching tree, excluding the nodes of the probing path
    114 *
    115 * @return the depth of the focus node, or -1 if no focus node exists; the focus node is the currently processed node in the
    116 * branching tree, excluding the nodes of the probing path
    117 *
    118 * @pre This method can be called if SCIP is in one of the following stages:
    119 * - \ref SCIP_STAGE_TRANSFORMED
    120 * - \ref SCIP_STAGE_INITPRESOLVE
    121 * - \ref SCIP_STAGE_PRESOLVING
    122 * - \ref SCIP_STAGE_EXITPRESOLVE
    123 * - \ref SCIP_STAGE_PRESOLVED
    124 * - \ref SCIP_STAGE_INITSOLVE
    125 * - \ref SCIP_STAGE_SOLVING
    126 * - \ref SCIP_STAGE_SOLVED
    127 * - \ref SCIP_STAGE_EXITSOLVE
    128 */
    129SCIP_EXPORT
    131 SCIP* scip /**< SCIP data structure */
    132 );
    133
    134/** gets current plunging depth (successive times, a child was selected as next node)
    135 *
    136 * @return the current plunging depth (successive times, a child was selected as next node)
    137 *
    138 * @pre This method can be called if SCIP is in one of the following stages:
    139 * - \ref SCIP_STAGE_PRESOLVED
    140 * - \ref SCIP_STAGE_SOLVING
    141 */
    142SCIP_EXPORT
    144 SCIP* scip /**< SCIP data structure */
    145 );
    146
    147/** gets the root node of the tree
    148 *
    149 * @return the root node of the search tree
    150 *
    151 * @pre This method can be called if @p scip is in one of the following stages:
    152 * - \ref SCIP_STAGE_INITPRESOLVE
    153 * - \ref SCIP_STAGE_PRESOLVING
    154 * - \ref SCIP_STAGE_EXITPRESOLVE
    155 * - \ref SCIP_STAGE_SOLVING
    156 */
    157SCIP_EXPORT
    159 SCIP* scip /**< SCIP data structure */
    160 );
    161
    162/** gets the effective root depth, i.e., the depth of the deepest node which is part of all paths from the root node
    163 * to the unprocessed nodes.
    164 *
    165 * @return effective root depth
    166 *
    167 * @pre This method can be called if @p scip is in one of the following stages:
    168 * - \ref SCIP_STAGE_SOLVING
    169 */
    170SCIP_EXPORT
    172 SCIP* scip /**< SCIP data structure */
    173 );
    174
    175/** returns whether the current node is already solved and only propagated again
    176 *
    177 * @return TRUE is returned if \SCIP performance repropagation, otherwise FALSE.
    178 *
    179 * @pre This method can be called if @p scip is in one of the following stages:
    180 * - \ref SCIP_STAGE_INITPRESOLVE
    181 * - \ref SCIP_STAGE_PRESOLVING
    182 * - \ref SCIP_STAGE_EXITPRESOLVE
    183 * - \ref SCIP_STAGE_SOLVING
    184 */
    185SCIP_EXPORT
    187 SCIP* scip /**< SCIP data structure */
    188 );
    189
    190/** gets children of focus node along with the number of children
    191 *
    192 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    193 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    194 *
    195 * @pre This method can be called if @p scip is in one of the following stages:
    196 * - \ref SCIP_STAGE_SOLVING
    197 */
    198SCIP_EXPORT
    200 SCIP* scip, /**< SCIP data structure */
    201 SCIP_NODE*** children, /**< pointer to store children array, or NULL if not needed */
    202 int* nchildren /**< pointer to store number of children, or NULL if not needed */
    203 );
    204
    205/** gets number of children of focus node
    206 *
    207 * @return number of children of the focus node
    208 *
    209 * @pre This method can be called if @p scip is in one of the following stages:
    210 * - \ref SCIP_STAGE_SOLVING
    211 */
    212SCIP_EXPORT
    214 SCIP* scip /**< SCIP data structure */
    215 );
    216
    217/** gets siblings of focus node along with the number of siblings
    218 *
    219 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    220 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    221 *
    222 * @pre This method can be called if @p scip is in one of the following stages:
    223 * - \ref SCIP_STAGE_SOLVING
    224 * - \ref SCIP_STAGE_SOLVED
    225 */
    226SCIP_EXPORT
    228 SCIP* scip, /**< SCIP data structure */
    229 SCIP_NODE*** siblings, /**< pointer to store siblings array, or NULL if not needed */
    230 int* nsiblings /**< pointer to store number of siblings, or NULL if not needed */
    231 );
    232
    233/** gets number of siblings of focus node
    234 *
    235 * @return the number of siblings of focus node
    236 *
    237 * @pre This method can be called if @p scip is in one of the following stages:
    238 * - \ref SCIP_STAGE_SOLVING
    239 * - \ref SCIP_STAGE_SOLVED
    240 */
    241SCIP_EXPORT
    243 SCIP* scip /**< SCIP data structure */
    244 );
    245
    246/** gets leaves of the tree along with the number of leaves
    247 *
    248 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    249 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    250 *
    251 * @pre This method can be called if @p scip is in one of the following stages:
    252 * - \ref SCIP_STAGE_SOLVING
    253 * - \ref SCIP_STAGE_SOLVED
    254 */
    255SCIP_EXPORT
    257 SCIP* scip, /**< SCIP data structure */
    258 SCIP_NODE*** leaves, /**< pointer to store leaves array, or NULL if not needed */
    259 int* nleaves /**< pointer to store number of leaves, or NULL if not needed */
    260 );
    261
    262/** gets number of leaves in the tree
    263 *
    264 * @return the number of leaves in the tree
    265 *
    266 * @pre This method can be called if @p scip is in one of the following stages:
    267 * - \ref SCIP_STAGE_SOLVING
    268 * - \ref SCIP_STAGE_SOLVED
    269 */
    270SCIP_EXPORT
    272 SCIP* scip /**< SCIP data structure */
    273 );
    274
    275/** gets number of nodes left in the tree (children + siblings + leaves)
    276 *
    277 * @return the number of nodes left in the tree (children + siblings + leaves)
    278 *
    279 * @pre This method can be called if SCIP is in one of the following stages:
    280 * - \ref SCIP_STAGE_PRESOLVED
    281 * - \ref SCIP_STAGE_SOLVING
    282 * - \ref SCIP_STAGE_SOLVED
    283 */
    284SCIP_EXPORT
    286 SCIP* scip /**< SCIP data structure */
    287 );
    288
    289/** gets the best child of the focus node w.r.t. the node selection priority assigned by the branching rule
    290 *
    291 * @return the best child of the focus node w.r.t. the node selection priority assigned by the branching rule
    292 *
    293 * @pre This method can be called if @p scip is in one of the following stages:
    294 * - \ref SCIP_STAGE_SOLVING
    295 */
    296SCIP_EXPORT
    298 SCIP* scip /**< SCIP data structure */
    299 );
    300
    301/** gets the best sibling of the focus node w.r.t. the node selection priority assigned by the branching rule
    302 *
    303 * @return the best sibling of the focus node w.r.t. the node selection priority assigned by the branching rule
    304 *
    305 * @pre This method can be called if @p scip is in one of the following stages:
    306 * - \ref SCIP_STAGE_SOLVING
    307 */
    308SCIP_EXPORT
    310 SCIP* scip /**< SCIP data structure */
    311 );
    312
    313/** gets the best child of the focus node w.r.t. the node selection strategy
    314 *
    315 * @return the best child of the focus node w.r.t. the node selection strategy
    316 *
    317 * @pre This method can be called if @p scip is in one of the following stages:
    318 * - \ref SCIP_STAGE_SOLVING
    319 */
    320SCIP_EXPORT
    322 SCIP* scip /**< SCIP data structure */
    323 );
    324
    325/** gets the best sibling of the focus node w.r.t. the node selection strategy
    326 *
    327 * @return the best sibling of the focus node w.r.t. the node selection strategy
    328 *
    329 * @pre This method can be called if @p scip is in one of the following stages:
    330 * - \ref SCIP_STAGE_SOLVING
    331 */
    332SCIP_EXPORT
    334 SCIP* scip /**< SCIP data structure */
    335 );
    336
    337/** gets the best leaf from the node queue w.r.t. the node selection strategy
    338 *
    339 * @return the best leaf from the node queue w.r.t. the node selection strategy
    340 *
    341 * @pre This method can be called if @p scip is in one of the following stages:
    342 * - \ref SCIP_STAGE_SOLVING
    343 */
    344SCIP_EXPORT
    346 SCIP* scip /**< SCIP data structure */
    347 );
    348
    349/** gets the best node from the tree (child, sibling, or leaf) w.r.t. the node selection strategy
    350 *
    351 * @return the best node from the tree (child, sibling, or leaf) w.r.t. the node selection strategy
    352 *
    353 * @pre This method can be called if @p scip is in one of the following stages:
    354 * - \ref SCIP_STAGE_SOLVING
    355 */
    356SCIP_EXPORT
    358 SCIP* scip /**< SCIP data structure */
    359 );
    360
    361/** gets the node with smallest lower bound from the tree (child, sibling, or leaf)
    362 *
    363 * @return the node with smallest lower bound from the tree (child, sibling, or leaf)
    364 *
    365 * @pre This method can be called if @p scip is in one of the following stages:
    366 * - \ref SCIP_STAGE_SOLVING
    367 */
    368SCIP_EXPORT
    370 SCIP* scip /**< SCIP data structure */
    371 );
    372
    373/** access to all data of open nodes (leaves, children, and siblings)
    374 *
    375 * @pre This method can be called if @p scip is in one of the following stages:
    376 * - \ref SCIP_STAGE_SOLVING
    377 */
    378SCIP_EXPORT
    380 SCIP* scip, /**< SCIP data structure */
    381 SCIP_NODE*** leaves, /**< pointer to store the leaves, or NULL if not needed */
    382 SCIP_NODE*** children, /**< pointer to store the children, or NULL if not needed */
    383 SCIP_NODE*** siblings, /**< pointer to store the siblings, or NULL if not needed */
    384 int* nleaves, /**< pointer to store the number of leaves, or NULL */
    385 int* nchildren, /**< pointer to store the number of children, or NULL */
    386 int* nsiblings /**< pointer to store the number of siblings, or NULL */
    387 );
    388
    389/** marks node and whole sub tree to be cut off from branch and bound tree
    390 *
    391 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    392 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    393 *
    394 * @pre This method can be called if @p scip is in one of the following stages:
    395 * - \ref SCIP_STAGE_SOLVING
    396 */
    397SCIP_EXPORT
    399 SCIP* scip, /**< SCIP data structure */
    400 SCIP_NODE* node /**< node that should be cut off */
    401 );
    402
    403/** removes all nodes from branch and bound tree that were marked to be cut off via SCIPcutoffNode()
    404 *
    405 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    406 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    407 *
    408 * @pre This method can be called if @p scip is in one of the following stages:
    409 * - \ref SCIP_STAGE_SOLVING
    410 *
    411 * @note In diving mode, the removal of nodes is delayed until diving ends.
    412 */
    413SCIP_EXPORT
    415 SCIP* scip /**< SCIP data structure */
    416 );
    417
    418/** marks the given node to be propagated again the next time a node of its subtree is processed
    419 *
    420 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    421 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    422 *
    423 * @pre This method can be called if @p scip is in one of the following stages:
    424 * - \ref SCIP_STAGE_SOLVING
    425 */
    426SCIP_EXPORT
    428 SCIP* scip, /**< SCIP data structure */
    429 SCIP_NODE* node /**< node that should be propagated again */
    430 );
    431
    432/** returns depth of first node in active path that is marked being cutoff
    433 *
    434 * @return depth of first node in active path that is marked being cutoff
    435 *
    436 * @pre This method can be called if @p scip is in one of the following stages:
    437 * - \ref SCIP_STAGE_SOLVING
    438 */
    439SCIP_EXPORT
    441 SCIP* scip /**< SCIP data structure */
    442 );
    443
    444/** returns depth of first node in active path that has to be propagated again
    445 *
    446 * @return depth of first node in active path that has to be propagated again
    447 *
    448 * @pre This method can be called if @p scip is in one of the following stages:
    449 * - \ref SCIP_STAGE_SOLVING
    450 */
    451SCIP_EXPORT
    453 SCIP* scip /**< SCIP data structure */
    454 );
    455
    456/** prints all branching decisions on variables from the root to the given node
    457 *
    458 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    459 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    460 *
    461 * @pre This method can be called if @p scip is in one of the following stages:
    462 * - \ref SCIP_STAGE_SOLVING
    463 */
    464SCIP_EXPORT
    466 SCIP* scip, /**< SCIP data structure */
    467 SCIP_NODE* node, /**< node data */
    468 FILE* file /**< output file (or NULL for standard output) */
    469 );
    470
    471/** sets whether the LP should be solved at the focus node
    472 *
    473 * @note In order to have an effect, this method needs to be called after a node is focused but before the LP is
    474 * solved.
    475 *
    476 * @pre This method can be called if @p scip is in one of the following stages:
    477 * - \ref SCIP_STAGE_SOLVING
    478 */
    479SCIP_EXPORT
    481 SCIP* scip, /**< SCIP data structure */
    482 SCIP_Bool solvelp /**< should the LP be solved? */
    483 );
    484
    485
    486/** query if node was the last parent of a branching of the tree
    487 *
    488 * @return TRUE if node was the last parent of a branching of the tree
    489 *
    490 * @pre This method can be called if SCIP is in one of the following stages:
    491 * - \ref SCIP_STAGE_PRESOLVED
    492 * - \ref SCIP_STAGE_SOLVING
    493 * - \ref SCIP_STAGE_SOLVED
    494 */
    495SCIP_EXPORT
    497 SCIP* scip, /**< SCIP data structure */
    498 SCIP_NODE* node /**< tree node, or NULL to check focus node */
    499 );
    500
    501/**@} */
    502
    503#ifdef __cplusplus
    504}
    505#endif
    506
    507#endif
    common defines and data types used in all packages of SCIP
    #define SCIP_Bool
    Definition: def.h:91
    SCIP_RETCODE SCIPpruneTree(SCIP *scip)
    Definition: scip_tree.c:459
    int SCIPgetEffectiveRootDepth(SCIP *scip)
    Definition: scip_tree.c:127
    int SCIPgetNSiblings(SCIP *scip)
    Definition: scip_tree.c:230
    SCIP_RETCODE SCIPrepropagateNode(SCIP *scip, SCIP_NODE *node)
    Definition: scip_tree.c:479
    SCIP_NODE * SCIPgetBestSibling(SCIP *scip)
    Definition: scip_tree.c:336
    int SCIPgetNChildren(SCIP *scip)
    Definition: scip_tree.c:188
    SCIP_RETCODE SCIPgetOpenNodesData(SCIP *scip, SCIP_NODE ***leaves, SCIP_NODE ***children, SCIP_NODE ***siblings, int *nleaves, int *nchildren, int *nsiblings)
    Definition: scip_tree.c:398
    SCIP_Bool SCIPinRepropagation(SCIP *scip)
    Definition: scip_tree.c:146
    void SCIPsetFocusnodeLP(SCIP *scip, SCIP_Bool solvelp)
    Definition: scip_tree.c:627
    SCIP_RETCODE SCIPgetChildren(SCIP *scip, SCIP_NODE ***children, int *nchildren)
    Definition: scip_tree.c:164
    int SCIPgetNNodesLeft(SCIP *scip)
    Definition: scip_tree.c:646
    int SCIPgetFocusDepth(SCIP *scip)
    Definition: scip_tree.c:698
    SCIP_NODE * SCIPgetFocusNode(SCIP *scip)
    Definition: scip_tree.c:72
    SCIP_RETCODE SCIPgetLeaves(SCIP *scip, SCIP_NODE ***leaves, int *nleaves)
    Definition: scip_tree.c:248
    SCIP_NODE * SCIPgetBestChild(SCIP *scip)
    Definition: scip_tree.c:320
    SCIP_NODE * SCIPgetPrioSibling(SCIP *scip)
    Definition: scip_tree.c:304
    int SCIPgetCutoffdepth(SCIP *scip)
    Definition: scip_tree.c:498
    SCIP_RETCODE SCIPprintNodeRootPath(SCIP *scip, SCIP_NODE *node, FILE *file)
    Definition: scip_tree.c:531
    int SCIPgetDepth(SCIP *scip)
    Definition: scip_tree.c:672
    int SCIPgetNLeaves(SCIP *scip)
    Definition: scip_tree.c:272
    SCIP_Bool SCIPwasNodeLastBranchParent(SCIP *scip, SCIP_NODE *node)
    Definition: scip_tree.c:733
    SCIP_NODE * SCIPgetBestNode(SCIP *scip)
    Definition: scip_tree.c:368
    SCIP_RETCODE SCIPgetSiblings(SCIP *scip, SCIP_NODE ***siblings, int *nsiblings)
    Definition: scip_tree.c:206
    int SCIPgetPlungeDepth(SCIP *scip)
    Definition: scip_tree.c:715
    SCIP_NODE * SCIPgetBestboundNode(SCIP *scip)
    Definition: scip_tree.c:384
    SCIP_NODE * SCIPgetPrioChild(SCIP *scip)
    Definition: scip_tree.c:288
    int SCIPgetRepropdepth(SCIP *scip)
    Definition: scip_tree.c:514
    SCIP_RETCODE SCIPcutoffNode(SCIP *scip, SCIP_NODE *node)
    Definition: scip_tree.c:436
    SCIP_NODE * SCIPgetBestLeaf(SCIP *scip)
    Definition: scip_tree.c:352
    SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
    Definition: scip_tree.c:91
    SCIP_NODE * SCIPgetRootNode(SCIP *scip)
    Definition: scip_tree.c:110
    type definitions for return codes for SCIP methods
    enum SCIP_Retcode SCIP_RETCODE
    Definition: type_retcode.h:63
    type definitions for SCIP's main datastructure
    type definitions for branch and bound tree