Scippy

SCIP

Solving Constraint Integer Programs

scip_branch.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_branch.h
26 * @ingroup PUBLICCOREAPI
27 * @brief public methods for branching rule plugins and branching
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_BRANCH_H__
41#define __SCIP_SCIP_BRANCH_H__
42
43
44#include "scip/def.h"
45#include "scip/type_branch.h"
46#include "scip/type_history.h"
47#include "scip/type_result.h"
48#include "scip/type_retcode.h"
49#include "scip/type_scip.h"
50#include "scip/type_tree.h"
51#include "scip/type_var.h"
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
57/**@addtogroup PublicBranchRuleMethods
58 *
59 * @{
60 */
61
62/** creates a branching rule and includes it in SCIP
63 * @pre This method can be called if SCIP is in one of the following stages:
64 * - \ref SCIP_STAGE_INIT
65 * - \ref SCIP_STAGE_PROBLEM
66 *
67 * @note method has all branching rule callbacks as arguments and is thus changed every time a new
68 * callback is added in future releases; consider using SCIPincludeBranchruleBasic() and setter functions
69 * if you seek for a method which is less likely to change in future releases
70 */
71SCIP_EXPORT
73 SCIP* scip, /**< SCIP data structure */
74 const char* name, /**< name of branching rule */
75 const char* desc, /**< description of branching rule */
76 int priority, /**< priority of the branching rule */
77 int maxdepth, /**< maximal depth level, up to which this branching rule should be used (or -1) */
78 SCIP_Real maxbounddist, /**< maximal relative distance from current node's dual bound to primal bound
79 * compared to best node's dual bound for applying branching rule
80 * (0.0: only on current best node, 1.0: on all nodes) */
81 SCIP_DECL_BRANCHCOPY ((*branchcopy)), /**< copy method of branching rule or NULL if you don't want to copy your plugin into sub-SCIPs */
82 SCIP_DECL_BRANCHFREE ((*branchfree)), /**< destructor of branching rule */
83 SCIP_DECL_BRANCHINIT ((*branchinit)), /**< initialize branching rule */
84 SCIP_DECL_BRANCHEXIT ((*branchexit)), /**< deinitialize branching rule */
85 SCIP_DECL_BRANCHINITSOL((*branchinitsol)),/**< solving process initialization method of branching rule */
86 SCIP_DECL_BRANCHEXITSOL((*branchexitsol)),/**< solving process deinitialization method of branching rule */
87 SCIP_DECL_BRANCHEXECLP((*branchexeclp)), /**< branching execution method for fractional LP solutions */
88 SCIP_DECL_BRANCHEXECEXT((*branchexecext)),/**< branching execution method for external candidates */
89 SCIP_DECL_BRANCHEXECPS((*branchexecps)), /**< branching execution method for not completely fixed pseudo solutions */
90 SCIP_BRANCHRULEDATA* branchruledata /**< branching rule data */
91 );
92
93/** creates a branching rule and includes it in SCIP. All non-fundamental (or optional) callbacks will be set to NULL.
94 * Optional callbacks can be set via specific setter functions, see SCIPsetBranchruleInit(), SCIPsetBranchruleExit(),
95 * SCIPsetBranchruleCopy(), SCIPsetBranchruleFree(), SCIPsetBranchruleInitsol(), SCIPsetBranchruleExitsol(),
96 * SCIPsetBranchruleExecLp(), SCIPsetBranchruleExecExt(), and SCIPsetBranchruleExecPs().
97 *
98 * @pre This method can be called if SCIP is in one of the following stages:
99 * - \ref SCIP_STAGE_INIT
100 * - \ref SCIP_STAGE_PROBLEM
101 *
102 * @note if you want to set all callbacks with a single method call, consider using SCIPincludeBranchrule() instead
103 */
104SCIP_EXPORT
106 SCIP* scip, /**< SCIP data structure */
107 SCIP_BRANCHRULE** branchruleptr, /**< pointer to branching rule, or NULL */
108 const char* name, /**< name of branching rule */
109 const char* desc, /**< description of branching rule */
110 int priority, /**< priority of the branching rule */
111 int maxdepth, /**< maximal depth level, up to which this branching rule should be used (or -1) */
112 SCIP_Real maxbounddist, /**< maximal relative distance from current node's dual bound to primal bound
113 * compared to best node's dual bound for applying branching rule
114 * (0.0: only on current best node, 1.0: on all nodes) */
115 SCIP_BRANCHRULEDATA* branchruledata /**< branching rule data */
116 );
117
118/** sets copy method of branching rule */
119SCIP_EXPORT
121 SCIP* scip, /**< SCIP data structure */
122 SCIP_BRANCHRULE* branchrule, /**< branching rule */
123 SCIP_DECL_BRANCHCOPY ((*branchcopy)) /**< copy method of branching rule or NULL if you don't want to copy your plugin into sub-SCIPs */
124 );
125
126/** sets destructor method of branching rule */
127SCIP_EXPORT
129 SCIP* scip, /**< SCIP data structure */
130 SCIP_BRANCHRULE* branchrule, /**< branching rule */
131 SCIP_DECL_BRANCHFREE ((*branchfree)) /**< destructor of branching rule */
132 );
133
134/** sets initialization method of branching rule */
135SCIP_EXPORT
137 SCIP* scip, /**< SCIP data structure */
138 SCIP_BRANCHRULE* branchrule, /**< branching rule */
139 SCIP_DECL_BRANCHINIT ((*branchinit)) /**< initialize branching rule */
140 );
141
142/** sets deinitialization method of branching rule */
143SCIP_EXPORT
145 SCIP* scip, /**< SCIP data structure */
146 SCIP_BRANCHRULE* branchrule, /**< branching rule */
147 SCIP_DECL_BRANCHEXIT ((*branchexit)) /**< deinitialize branching rule */
148 );
149
150/** sets solving process initialization method of branching rule */
151SCIP_EXPORT
153 SCIP* scip, /**< SCIP data structure */
154 SCIP_BRANCHRULE* branchrule, /**< branching rule */
155 SCIP_DECL_BRANCHINITSOL((*branchinitsol)) /**< solving process initialization method of branching rule */
156 );
157
158/** sets solving process deinitialization method of branching rule */
159SCIP_EXPORT
161 SCIP* scip, /**< SCIP data structure */
162 SCIP_BRANCHRULE* branchrule, /**< branching rule */
163 SCIP_DECL_BRANCHEXITSOL((*branchexitsol)) /**< solving process deinitialization method of branching rule */
164 );
165
166/** sets branching execution method for fractional LP solutions */
167SCIP_EXPORT
169 SCIP* scip, /**< SCIP data structure */
170 SCIP_BRANCHRULE* branchrule, /**< branching rule */
171 SCIP_DECL_BRANCHEXECLP((*branchexeclp)) /**< branching execution method for fractional LP solutions */
172 );
173
174/** sets branching execution method for external candidates */
175SCIP_EXPORT
177 SCIP* scip, /**< SCIP data structure */
178 SCIP_BRANCHRULE* branchrule, /**< branching rule */
179 SCIP_DECL_BRANCHEXECEXT((*branchexecext)) /**< branching execution method for external candidates */
180 );
181
182/** sets branching execution method for not completely fixed pseudo solutions */
183SCIP_EXPORT
185 SCIP* scip, /**< SCIP data structure */
186 SCIP_BRANCHRULE* branchrule, /**< branching rule */
187 SCIP_DECL_BRANCHEXECPS((*branchexecps)) /**< branching execution method for not completely fixed pseudo solutions */
188 );
189
190/** returns the branching rule of the given name, or NULL if not existing */
191SCIP_EXPORT
193 SCIP* scip, /**< SCIP data structure */
194 const char* name /**< name of branching rule */
195 );
196
197/** returns the array of currently available branching rules */
198SCIP_EXPORT
200 SCIP* scip /**< SCIP data structure */
201 );
202
203/** returns the number of currently available branching rules */
204SCIP_EXPORT
206 SCIP* scip /**< SCIP data structure */
207 );
208
209/** sets the priority of a branching rule */
210SCIP_EXPORT
212 SCIP* scip, /**< SCIP data structure */
213 SCIP_BRANCHRULE* branchrule, /**< branching rule */
214 int priority /**< new priority of the branching rule */
215 );
216
217/** sets maximal depth level, up to which this branching rule should be used (-1 for no limit) */
218SCIP_EXPORT
220 SCIP* scip, /**< SCIP data structure */
221 SCIP_BRANCHRULE* branchrule, /**< branching rule */
222 int maxdepth /**< new maxdepth of the branching rule */
223 );
224
225/** sets maximal relative distance from current node's dual bound to primal bound for applying branching rule */
226SCIP_EXPORT
228 SCIP* scip, /**< SCIP data structure */
229 SCIP_BRANCHRULE* branchrule, /**< branching rule */
230 SCIP_Real maxbounddist /**< new maxbounddist of the branching rule */
231 );
232
233/** @} */
234
235/**@addtogroup PublicBranchingMethods
236 *
237 * @{
238 */
239
240/** gets branching candidates for LP solution branching (fractional variables) along with solution values,
241 * fractionalities, and number of branching candidates; the number of branching candidates does not
242 * account for fractional continuous implied integral variables, which should not be used for branching
243 *
244 * fractional continuous implied integral variables are stored from *nlpcands to *nlpcands + *nfracimplvars - 1
245 *
246 * branching rules should always select the branching candidate among the first npriolpcands of the candidate
247 * list
248 *
249 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
250 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
251 *
252 * @pre This method can be called if @p scip is in one of the following stages:
253 * - \ref SCIP_STAGE_SOLVING
254 *
255 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
256 */
257SCIP_EXPORT
259 SCIP* scip, /**< SCIP data structure */
260 SCIP_VAR*** lpcands, /**< pointer to store the array of LP branching candidates, or NULL */
261 SCIP_Real** lpcandssol, /**< pointer to store the array of LP candidate solution values, or NULL */
262 SCIP_Real** lpcandsfrac, /**< pointer to store the array of LP candidate fractionalities, or NULL */
263 int* nlpcands, /**< pointer to store the number of LP branching candidates, or NULL */
264 int* npriolpcands, /**< pointer to store the number of candidates with maximal priority, or NULL */
265 int* nfracimplvars /**< pointer to store the number of fractional continuous implied integral variables, or NULL */
266 );
267
268/** gets number of branching candidates for LP solution branching (number of fractional variables); implied integral
269 * variables with integrality constraints are included
270 *
271 * @return the number of branching candidates for LP solution branching (number of fractional variables).
272 *
273 * @pre This method can be called if @p scip is in one of the following stages:
274 * - \ref SCIP_STAGE_SOLVING
275 *
276 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
277 */
278SCIP_EXPORT
280 SCIP* scip /**< SCIP data structure */
281 );
282
283/** gets number of branching candidates with maximal priority for LP solution branching
284 *
285 * @return the number of branching candidates with maximal priority for LP solution branching.
286 *
287 * @pre This method can be called if @p scip is in one of the following stages:
288 * - \ref SCIP_STAGE_SOLVING
289 *
290 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
291 */
292SCIP_EXPORT
294 SCIP* scip /**< SCIP data structure */
295 );
296
297/** gets external branching candidates along with solution values, scores, and number of branching candidates;
298 * these branching candidates can be used by relaxations or nonlinear constraint handlers;
299 * branching rules should always select the branching candidate among the first nprioexterncands of the candidate
300 * list
301 *
302 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
303 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
304 *
305 * @pre This method can be called if @p scip is in one of the following stages:
306 * - \ref SCIP_STAGE_SOLVING
307 *
308 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
309 *
310 * @note Candidate variables with maximal priority are ordered: binaries first, then integers, implicit integers and
311 * continuous last.
312 */
313SCIP_EXPORT
315 SCIP* scip, /**< SCIP data structure */
316 SCIP_VAR*** externcands, /**< pointer to store the array of extern branching candidates, or NULL */
317 SCIP_Real** externcandssol, /**< pointer to store the array of extern candidate solution values, or NULL */
318 SCIP_Real** externcandsscore, /**< pointer to store the array of extern candidate scores, or NULL */
319 int* nexterncands, /**< pointer to store the number of extern branching candidates, or NULL */
320 int* nprioexterncands, /**< pointer to store the number of candidates with maximal priority, or NULL */
321 int* nprioexternbins, /**< pointer to store the number of binary candidates with maximal priority, or NULL */
322 int* nprioexternints, /**< pointer to store the number of integer candidates with maximal priority, or NULL */
323 int* nprioexternimpls /**< pointer to store the number of implicit integer candidates with maximal priority,
324 * or NULL */
325 );
326
327/** gets number of external branching candidates
328 *
329 * @return the number of external branching candidates.
330 *
331 * @pre This method can be called if @p scip is in one of the following stages:
332 * - \ref SCIP_STAGE_SOLVING
333 *
334 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
335 */
336SCIP_EXPORT
338 SCIP* scip /**< SCIP data structure */
339 );
340
341/** gets number of external branching candidates with maximal branch priority
342 *
343 * @return the number of external branching candidates with maximal branch priority.
344 *
345 * @pre This method can be called if @p scip is in one of the following stages:
346 * - \ref SCIP_STAGE_SOLVING
347 *
348 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
349 */
350SCIP_EXPORT
352 SCIP* scip /**< SCIP data structure */
353 );
354
355/** gets number of binary external branching candidates with maximal branch priority
356 *
357 * @return the number of binary external branching candidates with maximal branch priority.
358 *
359 * @pre This method can be called if @p scip is in one of the following stages:
360 * - \ref SCIP_STAGE_SOLVING
361 *
362 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
363 */
364SCIP_EXPORT
366 SCIP* scip /**< SCIP data structure */
367 );
368
369/** gets number of integer external branching candidates with maximal branch priority
370 *
371 * @return the number of integer external branching candidates with maximal branch priority.
372 *
373 * @pre This method can be called if @p scip is in one of the following stages:
374 * - \ref SCIP_STAGE_SOLVING
375 *
376 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
377 */
378SCIP_EXPORT
380 SCIP* scip /**< SCIP data structure */
381 );
382
383/** gets number of implicit integer external branching candidates with maximal branch priority
384 *
385 * @return the number of implicit integer external branching candidates with maximal branch priority.
386 *
387 * @pre This method can be called if @p scip is in one of the following stages:
388 * - \ref SCIP_STAGE_SOLVING
389 *
390 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
391 */
392SCIP_EXPORT
394 SCIP* scip /**< SCIP data structure */
395 );
396
397/** gets number of continuous external branching candidates with maximal branch priority
398 *
399 * @return the number of continuous external branching candidates with maximal branch priority.
400 *
401 * @pre This method can be called if @p scip is in one of the following stages:
402 * - \ref SCIP_STAGE_SOLVING
403 *
404 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
405 */
406SCIP_EXPORT
408 SCIP* scip /**< SCIP data structure */
409 );
410
411/** insert variable, its score and its solution value into the external branching candidate storage
412 * the relative difference of the current lower and upper bounds of a continuous variable must be at least epsilon
413 *
414 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
415 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
416 *
417 * @pre This method can be called if @p scip is in one of the following stages:
418 * - \ref SCIP_STAGE_SOLVING
419 *
420 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
421 */
422SCIP_EXPORT
424 SCIP* scip, /**< SCIP data structure */
425 SCIP_VAR* var, /**< variable to insert */
426 SCIP_Real score, /**< score of external candidate, e.g. infeasibility */
427 SCIP_Real solval /**< value of the variable in the current solution */
428 );
429
430/** removes all external candidates from the storage for external branching
431 *
432 * @pre This method can be called if @p scip is in one of the following stages:
433 * - \ref SCIP_STAGE_SOLVING
434 *
435 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
436 */
437SCIP_EXPORT
439 SCIP* scip /**< SCIP data structure */
440 );
441
442/** checks whether the given variable is contained in the candidate storage for external branching
443 *
444 * @return whether the given variable is contained in the candidate storage for external branching.
445 *
446 * @pre This method can be called if @p scip is in one of the following stages:
447 * - \ref SCIP_STAGE_SOLVING
448 *
449 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
450 */
451SCIP_EXPORT
453 SCIP* scip, /**< SCIP data structure */
454 SCIP_VAR* var /**< variable to look for */
455 );
456
457/** gets branching candidates for pseudo solution branching (non-fixed variables) along with the number of candidates
458 *
459 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
460 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
461 *
462 * @pre This method can be called if @p scip is in one of the following stages:
463 * - \ref SCIP_STAGE_PRESOLVING
464 * - \ref SCIP_STAGE_SOLVING
465 *
466 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
467 */
468SCIP_EXPORT
470 SCIP* scip, /**< SCIP data structure */
471 SCIP_VAR*** pseudocands, /**< pointer to store the array of pseudo branching candidates, or NULL */
472 int* npseudocands, /**< pointer to store the number of pseudo branching candidates, or NULL */
473 int* npriopseudocands /**< pointer to store the number of candidates with maximal priority, or NULL */
474 );
475
476/** gets number of branching candidates for pseudo solution branching (non-fixed variables)
477 *
478 * @return the number branching candidates for pseudo solution branching (non-fixed variables).
479 *
480 * @pre This method can be called if @p scip is in one of the following stages:
481 * - \ref SCIP_STAGE_PRESOLVING
482 * - \ref SCIP_STAGE_SOLVING
483 *
484 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
485 */
486SCIP_EXPORT
488 SCIP* scip /**< SCIP data structure */
489 );
490
491/** gets number of branching candidates with maximal branch priority for pseudo solution branching
492 *
493 * @return the number of branching candidates with maximal branch priority for pseudo solution branching.
494 *
495 * @pre This method can be called if @p scip is in one of the following stages:
496 * - \ref SCIP_STAGE_PRESOLVING
497 * - \ref SCIP_STAGE_SOLVING
498 *
499 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
500 */
501SCIP_EXPORT
503 SCIP* scip /**< SCIP data structure */
504 );
505
506/** gets number of binary branching candidates with maximal branch priority for pseudo solution branching
507 *
508 * @return the number of binary branching candidates with maximal branch priority for pseudo solution branching.
509 *
510 * @pre This method can be called if @p scip is in one of the following stages:
511 * - \ref SCIP_STAGE_SOLVING
512 *
513 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
514 */
515SCIP_EXPORT
517 SCIP* scip /**< SCIP data structure */
518 );
519
520/** gets number of integer branching candidates with maximal branch priority for pseudo solution branching
521 *
522 * @return the number of integer branching candidates with maximal branch priority for pseudo solution branching.
523 *
524 * @pre This method can be called if @p scip is in one of the following stages:
525 * - \ref SCIP_STAGE_SOLVING
526 *
527 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
528 */
529SCIP_EXPORT
531 SCIP* scip /**< SCIP data structure */
532 );
533
534/** gets number of implicit integer branching candidates with maximal branch priority for pseudo solution branching
535 *
536 * @return the number of implicit integer branching candidates with maximal branch priority for pseudo solution branching.
537 *
538 * @pre This method can be called if @p scip is in one of the following stages:
539 * - \ref SCIP_STAGE_SOLVING
540 *
541 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
542 */
543SCIP_EXPORT
545 SCIP* scip /**< SCIP data structure */
546 );
547
548/** calculates the branching score out of the gain predictions for a binary branching
549 *
550 * @return the branching score out of the gain predictions for a binary branching.
551 *
552 * @pre This method can be called if @p scip is in one of the following stages:
553 * - \ref SCIP_STAGE_SOLVING
554 *
555 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
556 */
557SCIP_EXPORT
559 SCIP* scip, /**< SCIP data structure */
560 SCIP_VAR* var, /**< variable, of which the branching factor should be applied, or NULL */
561 SCIP_Real downgain, /**< prediction of objective gain for rounding downwards */
562 SCIP_Real upgain /**< prediction of objective gain for rounding upwards */
563 );
564
565/** calculates the branching score out of the gain predictions for a branching with arbitrary many children
566 *
567 * @return the branching score out of the gain predictions for a branching with arbitrary many children.
568 *
569 * @pre This method can be called if @p scip is in one of the following stages:
570 * - \ref SCIP_STAGE_SOLVING
571 *
572 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
573 */
574SCIP_EXPORT
576 SCIP* scip, /**< SCIP data structure */
577 SCIP_VAR* var, /**< variable, of which the branching factor should be applied, or NULL */
578 int nchildren, /**< number of children that the branching will create */
579 SCIP_Real* gains /**< prediction of objective gain for each child */
580 );
581
582/** computes a branching point for a continuous or discrete variable
583 *
584 * @see SCIPbranchGetBranchingPoint
585 *
586 * @return the branching point for a continuous or discrete variable.
587 *
588 * @pre This method can be called if @p scip is in one of the following stages:
589 * - \ref SCIP_STAGE_SOLVING
590 *
591 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
592 */
593SCIP_EXPORT
595 SCIP* scip, /**< SCIP data structure */
596 SCIP_VAR* var, /**< variable, of which the branching point should be computed */
597 SCIP_Real suggestion /**< suggestion for branching point, or SCIP_INVALID if no suggestion */
598 );
599
600/** calculates the node selection priority for moving the given variable's LP value to the given target value;
601 * this node selection priority can be given to the SCIPcreateChild() call
602 *
603 * @return the node selection priority for moving the given variable's LP value to the given target value.
604 *
605 * @pre This method can be called if @p scip is in one of the following stages:
606 * - \ref SCIP_STAGE_SOLVING
607 *
608 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
609 */
610SCIP_EXPORT
612 SCIP* scip, /**< SCIP data structure */
613 SCIP_VAR* var, /**< variable on which the branching is applied */
614 SCIP_BRANCHDIR branchdir, /**< type of branching that was performed: upwards, downwards, or fixed;
615 * fixed should only be used, when both bounds changed
616 */
617 SCIP_Real targetvalue /**< new value of the variable in the child node */
618 );
619
620/** calculates an estimate for the objective of the best feasible solution contained in the subtree after applying the given
621 * branching; this estimate can be given to the SCIPcreateChild() call
622 *
623 * @return the estimate for the objective of the best feasible solution contained in the subtree after applying the given
624 * branching.
625 *
626 * @pre This method can be called if @p scip is in one of the following stages:
627 * - \ref SCIP_STAGE_SOLVING
628 *
629 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
630 */
631SCIP_EXPORT
633 SCIP* scip, /**< SCIP data structure */
634 SCIP_VAR* var, /**< variable on which the branching is applied */
635 SCIP_Real targetvalue /**< new value of the variable in the child node */
636 );
637
638/** calculates the increase of the estimate for the objective of the best feasible solution contained in the subtree
639 * after applying the given branching
640 *
641 * @return the increase of the estimate for the objective of the best feasible solution contained in the subtree after
642 * applying the given branching.
643 *
644 * @pre This method can be called if @p scip is in one of the following stages:
645 * - \ref SCIP_STAGE_SOLVING
646 *
647 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
648 */
649SCIP_EXPORT
651 SCIP* scip, /**< SCIP data structure */
652 SCIP_VAR* var, /**< variable on which the branching is applied */
653 SCIP_Real varsol, /**< solution value of variable */
654 SCIP_Real targetvalue /**< new value of the variable in the child node */
655 );
656
657/** creates a child node of the focus node
658 *
659 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
660 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
661 *
662 * @pre This method can be called if @p scip is in one of the following stages:
663 * - \ref SCIP_STAGE_SOLVING
664 *
665 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
666 */
667SCIP_EXPORT
669 SCIP* scip, /**< SCIP data structure */
670 SCIP_NODE** node, /**< pointer to node data structure */
671 SCIP_Real nodeselprio, /**< node selection priority of new node */
672 SCIP_Real estimate /**< estimate for (transformed) objective value of best feasible solution in subtree */
673 );
674
675/** branches on a non-continuous variable v using the current LP or pseudo solution;
676 * if solution value x' is fractional, two child nodes will be created
677 * (x <= floor(x'), x >= ceil(x')),
678 * if solution value is integral, the x' is equal to lower or upper bound of the branching
679 * variable and the bounds of v are finite, then two child nodes will be created
680 * (x <= x'', x >= x''+1 with x'' = floor((lb + ub)/2)),
681 * otherwise (up to) three child nodes will be created
682 * (x <= x'-1, x == x', x >= x'+1)
683 *
684 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
685 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
686 *
687 * @pre This method can be called if @p scip is in one of the following stages:
688 * - \ref SCIP_STAGE_SOLVING
689 *
690 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
691 */
692SCIP_EXPORT
694 SCIP* scip, /**< SCIP data structure */
695 SCIP_VAR* var, /**< variable to branch on */
696 SCIP_NODE** downchild, /**< pointer to return the left child with variable rounded down, or NULL */
697 SCIP_NODE** eqchild, /**< pointer to return the middle child with variable fixed, or NULL */
698 SCIP_NODE** upchild /**< pointer to return the right child with variable rounded up, or NULL */
699 );
700
701/** branches a variable x using a given domain hole; two child nodes (x <= left, x >= right) are created
702 *
703 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
704 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
705 *
706 * @pre This method can be called if @p scip is in one of the following stages:
707 * - \ref SCIP_STAGE_SOLVING
708 *
709 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
710 */
711SCIP_EXPORT
713 SCIP* scip, /**< SCIP data structure */
714 SCIP_VAR* var, /**< variable to branch on */
715 SCIP_Real left, /**< left side of the domain hole */
716 SCIP_Real right, /**< right side of the domain hole */
717 SCIP_NODE** downchild, /**< pointer to return the left child (x <= left), or NULL */
718 SCIP_NODE** upchild /**< pointer to return the right child (x >= right), or NULL */
719 );
720
721/** branches on a variable x using a given value x';
722 * for continuous variables with relative domain width larger epsilon, x' must not be one of the bounds;
723 * two child nodes (x <= x', x >= x') are created;
724 * for integer variables, if solution value x' is fractional, two child nodes are created
725 * (x <= floor(x'), x >= ceil(x')),
726 * if x' is integral, three child nodes are created
727 * (x <= x'-1, x == x', x >= x'+1)
728 *
729 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
730 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
731 *
732 * @pre This method can be called if @p scip is in one of the following stages:
733 * - \ref SCIP_STAGE_SOLVING
734 *
735 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
736 */
737SCIP_EXPORT
739 SCIP* scip, /**< SCIP data structure */
740 SCIP_VAR* var, /**< variable to branch on */
741 SCIP_Real val, /**< value to branch on */
742 SCIP_NODE** downchild, /**< pointer to return the left child with variable rounded down, or NULL */
743 SCIP_NODE** eqchild, /**< pointer to return the middle child with variable fixed, or NULL */
744 SCIP_NODE** upchild /**< pointer to return the right child with variable rounded up, or NULL */
745 );
746
747/** n-ary branching on a variable x using a given value
748 *
749 * Branches on variable x such that up to n/2 children are created on each side of the usual branching value.
750 * The branching value is selected as in SCIPbranchVarVal().
751 * The parameters minwidth and widthfactor determine the domain width of the branching variable in the child nodes.
752 * If n is odd, one child with domain width 'width' and having the branching value in the middle is created.
753 * Otherwise, two children with domain width 'width' and being left and right of the branching value are created.
754 * Next further nodes to the left and right are created, where width is multiplied by widthfactor with increasing distance
755 * from the first nodes.
756 * The initial width is calculated such that n/2 nodes are created to the left and to the right of the branching value.
757 * If this value is below minwidth, the initial width is set to minwidth, which may result in creating less than n nodes.
758 *
759 * Giving a large value for widthfactor results in creating children with small domain when close to the branching value
760 * and large domain when closer to the current variable bounds. That is, setting widthfactor to a very large value and n to 3
761 * results in a ternary branching where the branching variable is mostly fixed in the middle child.
762 * Setting widthfactor to 1.0 results in children where the branching variable always has the same domain width
763 * (except for one child if the branching value is not in the middle).
764 *
765 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
766 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
767 *
768 * @pre This method can be called if @p scip is in one of the following stages:
769 * - \ref SCIP_STAGE_SOLVING
770 *
771 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
772 */
773SCIP_EXPORT
775 SCIP* scip, /**< SCIP data structure */
776 SCIP_VAR* var, /**< variable to branch on */
777 SCIP_Real val, /**< value to branch on */
778 int n, /**< attempted number of children to be created, must be >= 2 */
779 SCIP_Real minwidth, /**< minimal domain width in children */
780 SCIP_Real widthfactor, /**< multiplier for children domain width with increasing distance from val, must be >= 1.0 */
781 int* nchildren /**< pointer to store number of created children, or NULL */
782 );
783
784/** calls branching rules to branch on an LP solution; if no fractional variables exist, the result is SCIP_DIDNOTRUN;
785 * if the branch priority of an unfixed variable is larger than the maximal branch priority of the fractional
786 * variables, pseudo solution branching is applied on the unfixed variables with maximal branch priority
787 *
788 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
789 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
790 *
791 * @pre This method can be called if @p scip is in one of the following stages:
792 * - \ref SCIP_STAGE_SOLVING
793 *
794 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
795 */
796SCIP_EXPORT
798 SCIP* scip, /**< SCIP data structure */
799 SCIP_RESULT* result /**< pointer to store the result of the branching (s. branch.h) */
800 );
801
802/** calls branching rules to branch on a external candidates; if no such candidates exist, the result is SCIP_DIDNOTRUN
803 *
804 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
805 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
806 *
807 * @pre This method can be called if @p scip is in one of the following stages:
808 * - \ref SCIP_STAGE_SOLVING
809 *
810 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
811 */
812SCIP_EXPORT
814 SCIP* scip, /**< SCIP data structure */
815 SCIP_RESULT* result /**< pointer to store the result of the branching (s. branch.h) */
816 );
817
818/** calls branching rules to branch on a pseudo solution; if no unfixed variables exist, the result is SCIP_DIDNOTRUN
819 *
820 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
821 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
822 *
823 * @pre This method can be called if @p scip is in one of the following stages:
824 * - \ref SCIP_STAGE_SOLVING
825 *
826 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
827 */
828SCIP_EXPORT
830 SCIP* scip, /**< SCIP data structure */
831 SCIP_RESULT* result /**< pointer to store the result of the branching (s. branch.h) */
832 );
833
834/**@} */
835
836#ifdef __cplusplus
837}
838#endif
839
840#endif
common defines and data types used in all packages of SCIP
#define SCIP_Bool
Definition: def.h:91
#define SCIP_Real
Definition: def.h:156
SCIP_RETCODE SCIPsetBranchruleExecExt(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXECEXT((*branchexecext)))
Definition: scip_branch.c:272
SCIP_RETCODE SCIPsetBranchruleExit(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXIT((*branchexit)))
Definition: scip_branch.c:208
SCIP_RETCODE SCIPsetBranchruleExecLp(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXECLP((*branchexeclp)))
Definition: scip_branch.c:256
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
Definition: scip_branch.c:304
SCIP_RETCODE SCIPsetBranchruleCopy(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHCOPY((*branchcopy)))
Definition: scip_branch.c:160
SCIP_RETCODE SCIPincludeBranchruleBasic(SCIP *scip, SCIP_BRANCHRULE **branchruleptr, const char *name, const char *desc, int priority, int maxdepth, SCIP_Real maxbounddist, SCIP_BRANCHRULEDATA *branchruledata)
Definition: scip_branch.c:123
SCIP_BRANCHRULE ** SCIPgetBranchrules(SCIP *scip)
Definition: scip_branch.c:319
SCIP_RETCODE SCIPsetBranchruleExecPs(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXECPS((*branchexecps)))
Definition: scip_branch.c:288
SCIP_RETCODE SCIPsetBranchruleFree(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHFREE((*branchfree)))
Definition: scip_branch.c:176
SCIP_RETCODE SCIPsetBranchruleExitsol(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXITSOL((*branchexitsol)))
Definition: scip_branch.c:240
SCIP_RETCODE SCIPsetBranchruleInit(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHINIT((*branchinit)))
Definition: scip_branch.c:192
SCIP_RETCODE SCIPsetBranchrulePriority(SCIP *scip, SCIP_BRANCHRULE *branchrule, int priority)
Definition: scip_branch.c:341
SCIP_RETCODE SCIPincludeBranchrule(SCIP *scip, const char *name, const char *desc, int priority, int maxdepth, SCIP_Real maxbounddist, SCIP_DECL_BRANCHCOPY((*branchcopy)), SCIP_DECL_BRANCHFREE((*branchfree)), SCIP_DECL_BRANCHINIT((*branchinit)), SCIP_DECL_BRANCHEXIT((*branchexit)), SCIP_DECL_BRANCHINITSOL((*branchinitsol)), SCIP_DECL_BRANCHEXITSOL((*branchexitsol)), SCIP_DECL_BRANCHEXECLP((*branchexeclp)), SCIP_DECL_BRANCHEXECEXT((*branchexecext)), SCIP_DECL_BRANCHEXECPS((*branchexecps)), SCIP_BRANCHRULEDATA *branchruledata)
Definition: scip_branch.c:71
SCIP_RETCODE SCIPsetBranchruleInitsol(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHINITSOL((*branchinitsol)))
Definition: scip_branch.c:224
SCIP_RETCODE SCIPsetBranchruleMaxbounddist(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_Real maxbounddist)
Definition: scip_branch.c:371
int SCIPgetNBranchrules(SCIP *scip)
Definition: scip_branch.c:330
SCIP_RETCODE SCIPsetBranchruleMaxdepth(SCIP *scip, SCIP_BRANCHRULE *branchrule, int maxdepth)
Definition: scip_branch.c:356
int SCIPgetNPrioExternBranchConts(SCIP *scip)
Definition: scip_branch.c:651
SCIP_RETCODE SCIPgetExternBranchCands(SCIP *scip, SCIP_VAR ***externcands, SCIP_Real **externcandssol, SCIP_Real **externcandsscore, int *nexterncands, int *nprioexterncands, int *nprioexternbins, int *nprioexternints, int *nprioexternimpls)
Definition: scip_branch.c:519
SCIP_Real SCIPcalcNodeselPriority(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR branchdir, SCIP_Real targetvalue)
Definition: scip_branch.c:928
SCIP_RETCODE SCIPaddExternBranchCand(SCIP *scip, SCIP_VAR *var, SCIP_Real score, SCIP_Real solval)
Definition: scip_branch.c:673
int SCIPgetNPrioPseudoBranchInts(SCIP *scip)
Definition: scip_branch.c:821
SCIP_Real SCIPgetBranchingPoint(SCIP *scip, SCIP_VAR *var, SCIP_Real suggestion)
Definition: scip_branch.c:905
SCIP_Real SCIPcalcChildEstimate(SCIP *scip, SCIP_VAR *var, SCIP_Real targetvalue)
Definition: scip_branch.c:955
SCIP_Real SCIPcalcChildEstimateIncrease(SCIP *scip, SCIP_VAR *var, SCIP_Real varsol, SCIP_Real targetvalue)
Definition: scip_branch.c:979
int SCIPgetNPrioPseudoBranchBins(SCIP *scip)
Definition: scip_branch.c:803
SCIP_RETCODE SCIPbranchExtern(SCIP *scip, SCIP_RESULT *result)
Definition: scip_branch.c:1264
SCIP_RETCODE SCIPbranchVarValNary(SCIP *scip, SCIP_VAR *var, SCIP_Real val, int n, SCIP_Real minwidth, SCIP_Real widthfactor, int *nchildren)
Definition: scip_branch.c:1196
int SCIPgetNPrioPseudoBranchImpls(SCIP *scip)
Definition: scip_branch.c:839
SCIP_RETCODE SCIPbranchVarVal(SCIP *scip, SCIP_VAR *var, SCIP_Real val, SCIP_NODE **downchild, SCIP_NODE **eqchild, SCIP_NODE **upchild)
Definition: scip_branch.c:1134
SCIP_RETCODE SCIPbranchVarHole(SCIP *scip, SCIP_VAR *var, SCIP_Real left, SCIP_Real right, SCIP_NODE **downchild, SCIP_NODE **upchild)
Definition: scip_branch.c:1099
void SCIPclearExternBranchCands(SCIP *scip)
Definition: scip_branch.c:697
int SCIPgetNPrioPseudoBranchCands(SCIP *scip)
Definition: scip_branch.c:785
int SCIPgetNPrioExternBranchInts(SCIP *scip)
Definition: scip_branch.c:611
SCIP_RETCODE SCIPgetLPBranchCands(SCIP *scip, SCIP_VAR ***lpcands, SCIP_Real **lpcandssol, SCIP_Real **lpcandsfrac, int *nlpcands, int *npriolpcands, int *nfracimplvars)
Definition: scip_branch.c:402
int SCIPgetNPrioExternBranchBins(SCIP *scip)
Definition: scip_branch.c:591
SCIP_RETCODE SCIPbranchVar(SCIP *scip, SCIP_VAR *var, SCIP_NODE **downchild, SCIP_NODE **eqchild, SCIP_NODE **upchild)
Definition: scip_branch.c:1058
int SCIPgetNExternBranchCands(SCIP *scip)
Definition: scip_branch.c:551
int SCIPgetNPrioExternBranchCands(SCIP *scip)
Definition: scip_branch.c:571
int SCIPgetNPrioExternBranchImpls(SCIP *scip)
Definition: scip_branch.c:631
int SCIPgetNLPBranchCands(SCIP *scip)
Definition: scip_branch.c:436
SCIP_RETCODE SCIPbranchLP(SCIP *scip, SCIP_RESULT *result)
Definition: scip_branch.c:1240
int SCIPgetNPrioLPBranchCands(SCIP *scip)
Definition: scip_branch.c:474
SCIP_RETCODE SCIPgetPseudoBranchCands(SCIP *scip, SCIP_VAR ***pseudocands, int *npseudocands, int *npriopseudocands)
Definition: scip_branch.c:741
SCIP_Real SCIPgetBranchScoreMultiple(SCIP *scip, SCIP_VAR *var, int nchildren, SCIP_Real *gains)
Definition: scip_branch.c:880
SCIP_RETCODE SCIPcreateChild(SCIP *scip, SCIP_NODE **node, SCIP_Real nodeselprio, SCIP_Real estimate)
Definition: scip_branch.c:1025
SCIP_Real SCIPgetBranchScore(SCIP *scip, SCIP_VAR *var, SCIP_Real downgain, SCIP_Real upgain)
Definition: scip_branch.c:857
SCIP_RETCODE SCIPbranchPseudo(SCIP *scip, SCIP_RESULT *result)
Definition: scip_branch.c:1288
SCIP_Bool SCIPcontainsExternBranchCand(SCIP *scip, SCIP_VAR *var)
Definition: scip_branch.c:717
int SCIPgetNPseudoBranchCands(SCIP *scip)
Definition: scip_branch.c:766
type definitions for branching rules
#define SCIP_DECL_BRANCHEXECPS(x)
Definition: type_branch.h:176
#define SCIP_DECL_BRANCHEXECLP(x)
Definition: type_branch.h:134
#define SCIP_DECL_BRANCHEXECEXT(x)
Definition: type_branch.h:155
#define SCIP_DECL_BRANCHINITSOL(x)
Definition: type_branch.h:102
#define SCIP_DECL_BRANCHINIT(x)
Definition: type_branch.h:83
#define SCIP_DECL_BRANCHCOPY(x)
Definition: type_branch.h:67
#define SCIP_DECL_BRANCHEXIT(x)
Definition: type_branch.h:91
#define SCIP_DECL_BRANCHFREE(x)
Definition: type_branch.h:75
struct SCIP_BranchruleData SCIP_BRANCHRULEDATA
Definition: type_branch.h:57
#define SCIP_DECL_BRANCHEXITSOL(x)
Definition: type_branch.h:113
type definitions for branching and inference history
enum SCIP_BranchDir SCIP_BRANCHDIR
Definition: type_history.h:48
result codes for SCIP callback methods
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:61
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
type definitions for problem variables