Branching
Functionality by programming task » Programming models » Using integer variables and constraints

## Topics

| Variable selection for integer and Boolean variables
| Value selection for integer and Boolean variables
| Value selection for assigning integer variables
| Symmetry declarations

## Classes

class | Gecode::IntAFC
| Recording AFC information for integer variables. More...
class | Gecode::BoolAFC
| Recording AFC information for Boolean variables. More...
class | Gecode::IntAction
| Recording actions for integer variables. More...
class | Gecode::BoolAction
| Recording actions for Boolean variables. More...
class | Gecode::IntCHB
| Recording CHB for integer variables. More...
class | Gecode::BoolCHB
| Recording CHB for Boolean variables. More...
class | Gecode::IntVarBranch
| Which integer variable to select for branching. More...
class | Gecode::BoolVarBranch
| Which Boolean variable to select for branching. More...
class | Gecode::IntValBranch
| Which values to select for branching first. More...
class | Gecode::BoolValBranch
| Which values to select for branching first. More...
class | Gecode::IntAssign
| Which values to select for assignment. More...
class | Gecode::BoolAssign
| Which values to select for assignment. More...
class | Gecode::SymmetryHandle
| A reference-counted pointer to a SymmetryObject. More...

## Typedefs

typedef std::function< bool(const Space &home, IntVar x, int i)> | Gecode::IntBranchFilter
| Branch filter function type for integer variables.
typedef std::function< bool(const Space &home, BoolVar x, int i)> | Gecode::BoolBranchFilter
| Branch filter function type for Boolean variables.
typedef std::function< double(const Space &home, IntVar x, int i)> | Gecode::IntBranchMerit
| Branch merit function type for integer variables.
typedef std::function< double(const Space &home, BoolVar x, int i)> | Gecode::BoolBranchMerit
| Branch merit function type for Boolean variables.
typedef std::function< int(const Space &home, IntVar x, int i)> | Gecode::IntBranchVal
| Branch value function type for integer variables.
typedef std::function< int(const Space &home, BoolVar x, int i)> | Gecode::BoolBranchVal
| Branch value function type for Boolean variables.
typedef std::function< void(Space &home, unsigned int a, IntVar x, int i, int n)> | Gecode::IntBranchCommit
| Branch commit function type for integer variables.
typedef std::function< void(Space &home, unsigned int a, BoolVar x, int i, int n)> | Gecode::BoolBranchCommit
| Branch commit function type for Boolean variables.

## Functions

void | Gecode::branch (Home home, const IntVarArgs &x, IntVarBranch vars, IntValBranch vals, IntBranchFilter bf=nullptr, IntVarValPrint vvp=nullptr)
| Branch over x with variable selection vars and value selection vals.
void | Gecode::branch (Home home, const IntVarArgs &x, TieBreak< IntVarBranch > vars, IntValBranch vals, IntBranchFilter bf=nullptr, IntVarValPrint vvp=nullptr)
| Branch over x with tie-breaking variable selection vars and value selection vals.
void | Gecode::branch (Home home, IntVar x, IntValBranch vals, IntVarValPrint vvp=nullptr)
| Branch over x with value selection vals.
void | Gecode::branch (Home home, const BoolVarArgs &x, BoolVarBranch vars, BoolValBranch vals, BoolBranchFilter bf=nullptr, BoolVarValPrint vvp=nullptr)
| Branch over x with variable selection vars and value selection vals.
void | Gecode::branch (Home home, const BoolVarArgs &x, TieBreak< BoolVarBranch > vars, BoolValBranch vals, BoolBranchFilter bf=nullptr, BoolVarValPrint vvp=nullptr)
| Branch over x with tie-breaking variable selection vars and value selection vals.
void | Gecode::branch (Home home, BoolVar x, BoolValBranch vals, BoolVarValPrint vvp=nullptr)
| Branch over x with value selection vals.
void | Gecode::assign (Home home, const IntVarArgs &x, IntVarBranch vars, IntAssign vals, IntBranchFilter bf=nullptr, IntVarValPrint vvp=nullptr)
| Assign all x with variable selection vars with value selection vals.
void | Gecode::assign (Home home, const IntVarArgs &x, TieBreak< IntVarBranch > vars, IntAssign vals, IntBranchFilter bf=nullptr, IntVarValPrint vvp=nullptr)
| Assign all x with tie-breaking variable selection vars and value selection vals.
void | Gecode::assign (Home home, IntVar x, IntAssign vals, IntVarValPrint vvp=nullptr)
| Assign x with value selection vals.
void | Gecode::assign (Home home, const BoolVarArgs &x, BoolVarBranch vars, BoolAssign vals, BoolBranchFilter bf=nullptr, BoolVarValPrint vvp=nullptr)
| Assign all x with variable selection vars with value selection vals.
void | Gecode::assign (Home home, const BoolVarArgs &x, TieBreak< BoolVarBranch > vars, BoolAssign vals, IntBranchFilter bf=nullptr, IntVarValPrint vvp=nullptr)
| Assign all x with tie-breaking variable selection vars and value selection vals.
void | Gecode::assign (Home home, BoolVar x, BoolAssign vals, BoolVarValPrint vvp=nullptr)
| Assign x with value selection vals.
void | Gecode::branch (Home home, const IntVarArgs &x, IntValBranch vals, IntBranchFilter bf=nullptr, IntVarValPrint vvp=nullptr)
| Branch over x with value selection vals.
void | Gecode::branch (Home home, const BoolVarArgs &x, BoolValBranch vals, BoolBranchFilter bf=nullptr, BoolVarValPrint vvp=nullptr)
| Branch over x with value selection vals.
void | Gecode::assign (Home home, const IntVarArgs &x, IntAssign vals, IntBranchFilter bf=nullptr, IntVarValPrint vvp=nullptr)
| Assign all x with value selection vals.
void | Gecode::assign (Home home, const BoolVarArgs &x, BoolAssign vals, BoolBranchFilter bf=nullptr, BoolVarValPrint vvp=nullptr)
| Assign all x with value selection vals.
void | Gecode::branch (Home home, const IntVarArgs &x, IntVarBranch vars, IntValBranch vals, const Symmetries &syms, IntBranchFilter bf=nullptr, IntVarValPrint vvp=nullptr)
| Branch over x with variable selection vars and value selection vals with symmetry breaking.
void | Gecode::branch (Home home, const IntVarArgs &x, TieBreak< IntVarBranch > vars, IntValBranch vals, const Symmetries &syms, IntBranchFilter bf=nullptr, IntVarValPrint vvp=nullptr)
| Branch over x with tie-breaking variable selection vars and value selection vals with symmetry breaking.
void | Gecode::branch (Home home, const BoolVarArgs &x, BoolVarBranch vars, BoolValBranch vals, const Symmetries &syms, BoolBranchFilter bf=nullptr, BoolVarValPrint vvp=nullptr)
| Branch over x with variable selection vars and value selection vals with symmetry breaking.
void | Gecode::branch (Home home, const BoolVarArgs &x, TieBreak< BoolVarBranch > vars, BoolValBranch vals, const Symmetries &syms, BoolBranchFilter bf=nullptr, BoolVarValPrint vvp=nullptr)
| Branch over x with tie-breaking variable selection vars and value selection vals with symmetry breaking.

## Detailed Description

## Typedef Documentation

## IntBranchFilter

typedef std::function<bool(const Space& home, IntVar x, int i)> Gecode::IntBranchFilter

Branch filter function type for integer variables.

The variable x is considered for selection and i refers to the variable's position in the original array passed to the brancher.

Definition at line 4176 of file int.hh.

## BoolBranchFilter

typedef std::function<bool(const Space& home, BoolVar x, int i)> Gecode::BoolBranchFilter

Branch filter function type for Boolean variables.

The variable x is considered for selection and i refers to the variable's position in the original array passed to the brancher.

Definition at line 4186 of file int.hh.

## IntBranchMerit

typedef std::function<double(const Space& home, IntVar x, int i)> Gecode::IntBranchMerit

Branch merit function type for integer variables.

The function must return a merit value for the variable x. The integer i refers to the variable's position in the original array passed to the brancher.

Definition at line 4198 of file int.hh.

## BoolBranchMerit

typedef std::function<double(const Space& home, BoolVar x, int i)> Gecode::BoolBranchMerit

Branch merit function type for Boolean variables.

The function must return a merit value for the variable x. The integer i refers to the variable's position in the original array passed to the brancher.

Definition at line 4209 of file int.hh.

## IntBranchVal

typedef std::function<int(const Space& home, IntVar x, int i)> Gecode::IntBranchVal

Branch value function type for integer variables.

Returns a value for the variable x that is to be used in the corresponding branch commit function. The integer i refers to the variable's position in the original array passed to the brancher.

Definition at line 4222 of file int.hh.

## BoolBranchVal

typedef std::function<int(const Space& home, BoolVar x, int i)> Gecode::BoolBranchVal

Branch value function type for Boolean variables.

Returns a value for the variable x that is to be used in the corresponding branch commit function. The integer i refers to the variable's position in the original array passed to the brancher.

Definition at line 4234 of file int.hh.

## IntBranchCommit

typedef std::function<void(Space& home, unsigned int a, IntVar x, int i, int n)> Gecode::IntBranchCommit

Branch commit function type for integer variables.

The function must post a constraint on the variable x which corresponds to the alternative a. The integer i refers to the variable's position in the original array passed to the brancher. The value n is the value computed by the corresponding branch value function.

Definition at line 4249 of file int.hh.

## BoolBranchCommit

typedef std::function<void(Space& home, unsigned int a, BoolVar x, int i, int n)> Gecode::BoolBranchCommit

Branch commit function type for Boolean variables.

The function must post a constraint on the variable x which corresponds to the alternative a. The integer i refers to the variable's position in the original array passed to the brancher. The value n is the value computed by the corresponding branch value function.

Definition at line 4263 of file int.hh.

## Function Documentation

## branch() [1/12]

void Gecode::branch | ( | Home | home,
|  | const IntVarArgs & | x,
|  | IntVarBranch | vars,
|  | IntValBranch | vals,
|  | IntBranchFilter | bf = nullptr,
|  | IntVarValPrint | vvp = nullptr )

Branch over x with variable selection vars and value selection vals.

Definition at line 39 of file branch.cpp.

## branch() [2/12]

void Gecode::branch | ( | Home | home,
|  | const IntVarArgs & | x,
|  | TieBreak< IntVarBranch > | vars,
|  | IntValBranch | vals,
|  | IntBranchFilter | bf = nullptr,
|  | IntVarValPrint | vvp = nullptr )

Branch over x with tie-breaking variable selection vars and value selection vals.

Definition at line 65 of file branch.cpp.

## branch() [3/12]

void Gecode::branch | ( | Home | home,
|  | IntVar | x,
|  | IntValBranch | vals,
|  | IntVarValPrint | vvp = nullptr )

Branch over x with value selection vals.

Definition at line 140 of file branch.cpp.

## branch() [4/12]

void Gecode::branch | ( | Home | home,
|  | const BoolVarArgs & | x,
|  | BoolVarBranch | vars,
|  | BoolValBranch | vals,
|  | BoolBranchFilter | bf = nullptr,
|  | BoolVarValPrint | vvp = nullptr )

Branch over x with variable selection vars and value selection vals.

Definition at line 217 of file branch.cpp.

## branch() [5/12]

void Gecode::branch | ( | Home | home,
|  | const BoolVarArgs & | x,
|  | TieBreak< BoolVarBranch > | vars,
|  | BoolValBranch | vals,
|  | BoolBranchFilter | bf = nullptr,
|  | BoolVarValPrint | vvp = nullptr )

Branch over x with tie-breaking variable selection vars and value selection vals.

Definition at line 233 of file branch.cpp.

## branch() [6/12]

void Gecode::branch | ( | Home | home,
|  | BoolVar | x,
|  | BoolValBranch | vals,
|  | BoolVarValPrint | vvp = nullptr )

Branch over x with value selection vals.

Definition at line 280 of file branch.cpp.

## assign() [1/8]

void Gecode::assign | ( | Home | home,
|  | const IntVarArgs & | x,
|  | IntVarBranch | vars,
|  | IntAssign | vals,
|  | IntBranchFilter | bf = nullptr,
|  | IntVarValPrint | vvp = nullptr )

Assign all x with variable selection vars with value selection vals.

Definition at line 147 of file branch.cpp.

## assign() [2/8]

void Gecode::assign | ( | Home | home,
|  | const IntVarArgs & | x,
|  | TieBreak< IntVarBranch > | vars,
|  | IntAssign | vals,
|  | IntBranchFilter | bf = nullptr,
|  | IntVarValPrint | vvp = nullptr )

Assign all x with tie-breaking variable selection vars and value selection vals.

## assign() [3/8]

void Gecode::assign | ( | Home | home,
|  | IntVar | x,
|  | IntAssign | vals,
|  | IntVarValPrint | vvp = nullptr )

Assign x with value selection vals.

Definition at line 210 of file branch.cpp.

## assign() [4/8]

void Gecode::assign | ( | Home | home,
|  | const BoolVarArgs & | x,
|  | BoolVarBranch | vars,
|  | BoolAssign | vals,
|  | BoolBranchFilter | bf = nullptr,
|  | BoolVarValPrint | vvp = nullptr )

Assign all x with variable selection vars with value selection vals.

Definition at line 286 of file branch.cpp.

## assign() [5/8]

void Gecode::assign | ( | Home | home,
|  | const BoolVarArgs & | x,
|  | TieBreak< BoolVarBranch > | vars,
|  | BoolAssign | vals,
|  | IntBranchFilter | bf = nullptr,
|  | IntVarValPrint | vvp = nullptr )

Assign all x with tie-breaking variable selection vars and value selection vals.

## assign() [6/8]

void Gecode::assign | ( | Home | home,
|  | BoolVar | x,
|  | BoolAssign | vals,
|  | BoolVarValPrint | vvp = nullptr )

Assign x with value selection vals.

Definition at line 348 of file branch.cpp.

## branch() [7/12]

void Gecode::branch | ( | Home | home,
|  | const IntVarArgs & | x,
|  | IntValBranch | vals,
|  | IntBranchFilter | bf = nullptr,
|  | IntVarValPrint | vvp = nullptr )

inline

Branch over x with value selection vals.

Definition at line 37 of file branch.hpp.

## branch() [8/12]

void Gecode::branch | ( | Home | home,
|  | const BoolVarArgs & | x,
|  | BoolValBranch | vals,
|  | BoolBranchFilter | bf = nullptr,
|  | BoolVarValPrint | vvp = nullptr )

inline

Branch over x with value selection vals.

Definition at line 42 of file branch.hpp.

## assign() [7/8]

void Gecode::assign | ( | Home | home,
|  | const IntVarArgs & | x,
|  | IntAssign | vals,
|  | IntBranchFilter | bf = nullptr,
|  | IntVarValPrint | vvp = nullptr )

inline

Assign all x with value selection vals.

Definition at line 48 of file branch.hpp.

## assign() [8/8]

void Gecode::assign | ( | Home | home,
|  | const BoolVarArgs & | x,
|  | BoolAssign | vals,
|  | BoolBranchFilter | bf = nullptr,
|  | BoolVarValPrint | vvp = nullptr )

inline

Assign all x with value selection vals.

Definition at line 53 of file branch.hpp.

## branch() [9/12]

void Gecode::branch | ( | Home | home,
|  | const IntVarArgs & | x,
|  | IntVarBranch | vars,
|  | IntValBranch | vals,
|  | const Symmetries & | syms,
|  | IntBranchFilter | bf = nullptr,
|  | IntVarValPrint | vvp = nullptr )

Branch over x with variable selection vars and value selection vals with symmetry breaking.

Throws LDSBBadValueSelection exception if vals is any of SEL_SPLIT_MIN, SEL_SPLIT_MAX, SEL_RANGE_MIN, SEL_RANGE_MAX, SEL_VALUES_MIN, and SEL_VALUES_MAX, or if vals is SEL_VAL_COMMIT with a custom commit function.

Definition at line 259 of file ldsb.cpp.

## branch() [10/12]

void Gecode::branch | ( | Home | home,
|  | const IntVarArgs & | x,
|  | TieBreak< IntVarBranch > | vars,
|  | IntValBranch | vals,
|  | const Symmetries & | syms,
|  | IntBranchFilter | bf = nullptr,
|  | IntVarValPrint | vvp = nullptr )

Branch over x with tie-breaking variable selection vars and value selection vals with symmetry breaking.

Throws LDSBBadValueSelection exception if vals is any of SEL_SPLIT_MIN, SEL_SPLIT_MAX, SEL_RANGE_MIN, SEL_RANGE_MAX, SEL_VALUES_MIN, and SEL_VALUES_MAX, or if vals is SEL_VAL_COMMIT with a custom commit function.

Definition at line 308 of file ldsb.cpp.

## branch() [11/12]

void Gecode::branch | ( | Home | home,
|  | const BoolVarArgs & | x,
|  | BoolVarBranch | vars,
|  | BoolValBranch | vals,
|  | const Symmetries & | syms,
|  | BoolBranchFilter | bf = nullptr,
|  | BoolVarValPrint | vvp = nullptr )

Branch over x with variable selection vars and value selection vals with symmetry breaking.

Throws LDSBBadValueSelection exception if vals is any of SEL_SPLIT_MIN, SEL_SPLIT_MAX, SEL_RANGE_MIN, SEL_RANGE_MAX, SEL_VALUES_MIN, and SEL_VALUES_MAX, or if vals is SEL_VAL_COMMIT with a custom commit function.

Definition at line 423 of file ldsb.cpp.

## branch() [12/12]

void Gecode::branch | ( | Home | home,
|  | const BoolVarArgs & | x,
|  | TieBreak< BoolVarBranch > | vars,
|  | BoolValBranch | vals,
|  | const Symmetries & | syms,
|  | BoolBranchFilter | bf = nullptr,
|  | BoolVarValPrint | vvp = nullptr )

Branch over x with tie-breaking variable selection vars and value selection vals with symmetry breaking.

Throws LDSBBadValueSelection exception if vals is any of SEL_SPLIT_MIN, SEL_SPLIT_MAX, SEL_RANGE_MIN, SEL_RANGE_MAX, SEL_VALUES_MIN, and SEL_VALUES_MAX, or if vals is SEL_VAL_COMMIT with a custom commit function.

Definition at line 469 of file ldsb.cpp.