Scippy

    SCIP

    Solving Constraint Integer Programs

    type_var.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 type_var.h
    26 * @ingroup TYPEDEFINITIONS
    27 * @brief type definitions for problem variables
    28 * @author Tobias Achterberg
    29 *
    30 * This file defines the interface for user variable data implemented in C. Each variable can be equipped with a
    31 * variable data struct. This data can be accessed via the function SCIPgetVardata() at any time after it is created
    32 * and before it is deleted.
    33 *
    34 * - \ref scip::ObjVardata "Corresponding C interface"
    35 */
    36
    37/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
    38
    39#ifndef __SCIP_TYPE_VAR_H__
    40#define __SCIP_TYPE_VAR_H__
    41
    42#include "scip/def.h"
    43
    44#ifdef __cplusplus
    45extern "C" {
    46#endif
    47
    48/** status of problem variables */
    50{
    51 SCIP_VARSTATUS_ORIGINAL = 0, /**< variable belongs to original problem */
    52 SCIP_VARSTATUS_LOOSE = 1, /**< variable is a loose variable of the transformed problem */
    53 SCIP_VARSTATUS_COLUMN = 2, /**< variable is a column of the transformed problem */
    54 SCIP_VARSTATUS_FIXED = 3, /**< variable is fixed to specific value in the transformed problem */
    55 SCIP_VARSTATUS_AGGREGATED = 4, /**< variable is aggregated to x = a*y + c in the transformed problem */
    56 SCIP_VARSTATUS_MULTAGGR = 5, /**< variable is aggregated to x = a_1*y_1 + ... + a_k*y_k + c */
    57 SCIP_VARSTATUS_NEGATED = 6 /**< variable is the negation of an original or transformed variable */
    58};
    60
    61/** variable type */
    63{
    64 SCIP_VARTYPE_BINARY = 0, /**< binary variable: \f$ x \in \{0,1\} \f$ */
    65 SCIP_VARTYPE_INTEGER = 1, /**< integer variable: \f$ x \in \{lb, \dots, ub\} \f$ */
    66#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 6) /* _attribute__ ((deprecated)) within enums only supported by selected compilers */
    67 SCIP_VARTYPE_IMPLINT SCIP_DEPRECATED = 2, /**< @deprecated use `SCIPcreateVarImpl()` or `SCIPvarChgImplType()` to control implied integrality */
    68#else
    69 SCIP_VARTYPE_IMPLINT = 2, /**< @deprecated use `SCIPcreateVarImpl()` or `SCIPvarChgImplType()` to control implied integrality */
    70#endif
    71 SCIP_VARTYPE_CONTINUOUS = 3 /**< continuous variable: \f$ lb \leq x \leq ub \f$ */
    72};
    74
    75/** alternative to `SCIP_VARTYPE_IMPLINT` that comes without SCIP_DEPRECATED attribute
    76 * @deprecated still, the use of an implicit integral variable type is deprecated
    77 */
    78/** @todo remove / refactor usages of this macro */
    79#define SCIP_DEPRECATED_VARTYPE_IMPLINT ((SCIP_VARTYPE) 2)
    80
    81/* CIP format variable characters */
    82#define SCIP_VARTYPE_BINARY_CHAR 'B'
    83#define SCIP_VARTYPE_INTEGER_CHAR 'I'
    84#define SCIP_VARTYPE_CONTINUOUS_CHAR 'C'
    85#define SCIP_DEPRECATED_VARTYPE_IMPLINT_CHAR 'M'
    86
    87/** implied integral type */
    89{
    90 SCIP_IMPLINTTYPE_NONE = 0, /**< The variable is not implied integral by other variables */
    91 SCIP_IMPLINTTYPE_WEAK = 1, /**< The constraint handlers enforce that if the problem is relaxed
    92 * to have integrality constraints for the non-implied integral variables
    93 * only, there exists an optimal solution where all weakly and strongly
    94 * implied integral variables have integer solution values.
    95 * For infeasible problems, when relaxing integrality of all implied
    96 * integer variables, the problem remains infeasible.
    97 * For unbounded problems, when enforcing integrality of all implied
    98 * integer variables, the problem remains unbounded.
    99 *
    100 * @note This notion of implied integrality is fragile and may break
    101 * if extra constraints are added.
    102 *
    103 * Example: The variable z is a weakly implied integral if it only occurs
    104 * in the constraint 4x + 3y + z <= 10, where x and y are integer and
    105 * z has objective 0. */
    106 SCIP_IMPLINTTYPE_STRONG = 2 /**< The constraint handlers enforce that if the problem is relaxed
    107 * to have integrality constraints for the non-implied integral variables
    108 * only, in every feasible solution all strongly implied integral
    109 * variables have integer solution values.
    110 *
    111 * @note This notion of implied integrality remains intact under the
    112 * addition of additional constraints to the problem.
    113 *
    114 * Example: The variable z is strongly implied integral if we have the
    115 * constraint: 4x + 3y + z = 10, where x and y are integer variables. */
    118
    119/** domain change data type */
    121{
    122 SCIP_DOMCHGTYPE_DYNAMIC = 0, /**< dynamic bound changes with size information of arrays */
    123 SCIP_DOMCHGTYPE_BOTH = 1, /**< static domain changes: number of entries equals size of arrays */
    124 SCIP_DOMCHGTYPE_BOUND = 2 /**< static domain changes without any hole changes */
    127
    128/** bound change type */
    130{
    131 SCIP_BOUNDCHGTYPE_BRANCHING = 0, /**< bound change was due to a branching decision */
    132 SCIP_BOUNDCHGTYPE_CONSINFER = 1, /**< bound change was due to an inference of a constraint (domain propagation) */
    133 SCIP_BOUNDCHGTYPE_PROPINFER = 2 /**< bound change was due to an inference of a domain propagator */
    136
    137/** types of variable locks */
    138#define NLOCKTYPES 2 /**< number of lock types */
    140{
    141 SCIP_LOCKTYPE_MODEL = 0, /**< variable locks for model and check constraints */
    142 SCIP_LOCKTYPE_CONFLICT = 1 /**< variable locks for conflict constraints */
    145
    146typedef struct SCIP_DomChgBound SCIP_DOMCHGBOUND; /**< static domain change data for bound changes */
    147typedef struct SCIP_DomChgBoth SCIP_DOMCHGBOTH; /**< static domain change data for bound and hole changes */
    148typedef struct SCIP_DomChgDyn SCIP_DOMCHGDYN; /**< dynamic domain change data for bound and hole changes */
    149typedef union SCIP_DomChg SCIP_DOMCHG; /**< changes in domains of variables */
    150typedef struct SCIP_BoundChg SCIP_BOUNDCHG; /**< changes in bounds of variables */
    151typedef struct SCIP_BdChgIdx SCIP_BDCHGIDX; /**< bound change index in path from root to current node */
    152typedef struct SCIP_BdChgInfo SCIP_BDCHGINFO; /**< bound change information to track bound changes from root to current node */
    153typedef struct SCIP_BranchingData SCIP_BRANCHINGDATA; /**< data for branching decision bound changes */
    154typedef struct SCIP_InferenceData SCIP_INFERENCEDATA; /**< data for inferred bound changes */
    155typedef struct SCIP_HoleChg SCIP_HOLECHG; /**< changes in holelist of variables */
    156typedef struct SCIP_Hole SCIP_HOLE; /**< hole in a domain of an integer variable */
    157typedef struct SCIP_Holelist SCIP_HOLELIST; /**< list of holes in a domain of an integer variable */
    158typedef struct SCIP_Dom SCIP_DOM; /**< datastructures for storing domains of variables */
    159typedef struct SCIP_Original SCIP_ORIGINAL; /**< original variable information */
    160typedef struct SCIP_Loose SCIP_LOOSE; /**< loose variable information */
    161typedef struct SCIP_Aggregate SCIP_AGGREGATE; /**< aggregation information */
    162typedef struct SCIP_AggregateExact SCIP_AGGREGATEEXACT; /**< exact aggregation information */
    163typedef struct SCIP_Multaggr SCIP_MULTAGGR; /**< multiple aggregation information */
    164typedef struct SCIP_MultaggrExact SCIP_MULTAGGREXACT; /**< exact multiple aggregation information */
    165typedef struct SCIP_Negate SCIP_NEGATE; /**< negation information */
    166typedef struct SCIP_Var SCIP_VAR; /**< variable of the problem */
    167typedef struct SCIP_VarData SCIP_VARDATA; /**< user variable data */
    168typedef struct SCIP_VarDataExact SCIP_VARDATAEXACT;/**< exact data (obj, bounds, ...) */
    169typedef struct SCIP_DomExact SCIP_DOMEXACT; /**< exact domain (using rationals) */
    170
    171/** frees user data of original variable (called when the original variable is freed)
    172 *
    173 * This method should free the user data of the original variable.
    174 *
    175 * input:
    176 * - scip : SCIP main data structure
    177 * - var : original variable the data to free is belonging to
    178 * - vardata : pointer to the user variable data to free
    179 */
    180#define SCIP_DECL_VARDELORIG(x) SCIP_RETCODE x (SCIP* scip, SCIP_VAR* var, SCIP_VARDATA** vardata)
    181
    182/** creates transformed variable for original user variable
    183 *
    184 * Because the original variable and the user data of the original variable should not be
    185 * modified during the solving process, a transformed variable is created as a copy of
    186 * the original variable. If the user variable data is never modified during the solving
    187 * process anyways, it is enough to simply copy the user data's pointer. This is the
    188 * default implementation, which is used when NULL is given as the VARTRANS method.
    189 * If the user data may be modified during the solving process (e.g. during preprocessing),
    190 * the VARTRANS method must be given and has to copy the user variable data to a different
    191 * memory location.
    192 *
    193 * input:
    194 * - scip : SCIP main data structure
    195 * - sourcevar : original variable
    196 * - sourcedata : source variable data to transform
    197 * - targetvar : transformed variable
    198 * - targetdata : pointer to store created transformed variable data
    199 */
    200#define SCIP_DECL_VARTRANS(x) SCIP_RETCODE x (SCIP* scip, SCIP_VAR* sourcevar, SCIP_VARDATA* sourcedata, SCIP_VAR* targetvar, SCIP_VARDATA** targetdata)
    201
    202/** frees user data of transformed variable (called when the transformed variable is freed)
    203 *
    204 * This method has to be implemented, if the VARTRANS method is not a simple pointer
    205 * copy operation like in the default VARTRANS implementation. It should free the
    206 * user data of the transformed variable, that was created in the VARTRANS method.
    207 *
    208 * input:
    209 * - scip : SCIP main data structure
    210 * - var : transformed variable the data to free is belonging to
    211 * - vardata : pointer to the user variable data to free
    212 */
    213#define SCIP_DECL_VARDELTRANS(x) SCIP_RETCODE x (SCIP* scip, SCIP_VAR* var, SCIP_VARDATA** vardata)
    214
    215/** copies variable data of source SCIP variable for the target SCIP variable
    216 *
    217 * This method should copy the variable data of the source SCIP and create a target variable data for target
    218 * variable. This callback is optional. If the copying process was successful, the target variable gets this variable
    219 * data assigned. In case the result pointer is set to SCIP_DIDNOTRUN, the target variable will have no variable data at
    220 * all.
    221 *
    222 * The variable map and the constraint map can be used via the function SCIPgetVarCopy() and SCIPgetConsCopy(),
    223 * respectively, to get for certain variables and constraints of the source SCIP the counter parts in the target
    224 * SCIP. You should be very careful in using these two methods since they could lead to infinite loop.
    225 *
    226 * input:
    227 * - scip : target SCIP data structure
    228 * - sourcescip : source SCIP main data structure
    229 * - sourcevar : variable of the source SCIP
    230 * - sourcedata : variable data of the source variable which should get copied
    231 * - varmap, : a hashmap which stores the mapping of source variables to corresponding target variables
    232 * - consmap, : a hashmap which stores the mapping of source constraints to corresponding target constraints
    233 * - targetvar : variable of the (target) SCIP (targetvar is the copy of sourcevar)
    234 * - targetdata : pointer to store created copy of the variable data for the (target) SCIP
    235 *
    236 * output:
    237 * - result : pointer to store the result of the call
    238 *
    239 * possible return values for *result:
    240 * - SCIP_DIDNOTRUN : the copying process was not performed
    241 * - SCIP_SUCCESS : the copying process was successfully performed
    242 */
    243#define SCIP_DECL_VARCOPY(x) SCIP_RETCODE x (SCIP* scip, SCIP* sourcescip, SCIP_VAR* sourcevar, SCIP_VARDATA* sourcedata, \
    244 SCIP_HASHMAP* varmap, SCIP_HASHMAP* consmap, SCIP_VAR* targetvar, SCIP_VARDATA** targetdata, SCIP_RESULT* result)
    245
    246#ifdef __cplusplus
    247}
    248#endif
    249
    250#endif
    common defines and data types used in all packages of SCIP
    #define SCIP_DEPRECATED
    Definition: def.h:421
    struct SCIP_VarData SCIP_VARDATA
    Definition: type_var.h:167
    enum SCIP_DomchgType SCIP_DOMCHGTYPE
    Definition: type_var.h:126
    enum SCIP_BoundchgType SCIP_BOUNDCHGTYPE
    Definition: type_var.h:135
    enum SCIP_ImplintType SCIP_IMPLINTTYPE
    Definition: type_var.h:117
    SCIP_ImplintType
    Definition: type_var.h:89
    @ SCIP_IMPLINTTYPE_NONE
    Definition: type_var.h:90
    @ SCIP_IMPLINTTYPE_STRONG
    Definition: type_var.h:106
    @ SCIP_IMPLINTTYPE_WEAK
    Definition: type_var.h:91
    SCIP_DomchgType
    Definition: type_var.h:121
    @ SCIP_DOMCHGTYPE_DYNAMIC
    Definition: type_var.h:122
    @ SCIP_DOMCHGTYPE_BOUND
    Definition: type_var.h:124
    @ SCIP_DOMCHGTYPE_BOTH
    Definition: type_var.h:123
    struct SCIP_BranchingData SCIP_BRANCHINGDATA
    Definition: type_var.h:153
    SCIP_Vartype
    Definition: type_var.h:63
    @ SCIP_VARTYPE_INTEGER
    Definition: type_var.h:65
    @ SCIP_VARTYPE_CONTINUOUS
    Definition: type_var.h:71
    @ SCIP_VARTYPE_IMPLINT
    Definition: type_var.h:69
    @ SCIP_VARTYPE_BINARY
    Definition: type_var.h:64
    SCIP_BoundchgType
    Definition: type_var.h:130
    @ SCIP_BOUNDCHGTYPE_PROPINFER
    Definition: type_var.h:133
    @ SCIP_BOUNDCHGTYPE_BRANCHING
    Definition: type_var.h:131
    @ SCIP_BOUNDCHGTYPE_CONSINFER
    Definition: type_var.h:132
    SCIP_Varstatus
    Definition: type_var.h:50
    @ SCIP_VARSTATUS_ORIGINAL
    Definition: type_var.h:51
    @ SCIP_VARSTATUS_FIXED
    Definition: type_var.h:54
    @ SCIP_VARSTATUS_COLUMN
    Definition: type_var.h:53
    @ SCIP_VARSTATUS_MULTAGGR
    Definition: type_var.h:56
    @ SCIP_VARSTATUS_NEGATED
    Definition: type_var.h:57
    @ SCIP_VARSTATUS_AGGREGATED
    Definition: type_var.h:55
    @ SCIP_VARSTATUS_LOOSE
    Definition: type_var.h:52
    enum SCIP_LockType SCIP_LOCKTYPE
    Definition: type_var.h:144
    SCIP_LockType
    Definition: type_var.h:140
    @ SCIP_LOCKTYPE_CONFLICT
    Definition: type_var.h:142
    @ SCIP_LOCKTYPE_MODEL
    Definition: type_var.h:141
    enum SCIP_Vartype SCIP_VARTYPE
    Definition: type_var.h:73
    enum SCIP_Varstatus SCIP_VARSTATUS
    Definition: type_var.h:59
    struct SCIP_InferenceData SCIP_INFERENCEDATA
    Definition: type_var.h:154