Scippy

    SCIP

    Solving Constraint Integer Programs

    cons_sos1.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 cons_sos1.h
    26 * @ingroup CONSHDLRS
    27 * @brief constraint handler for SOS type 1 constraints
    28 * @author Tobias Fischer
    29 * @author Marc Pfetsch
    30 *
    31 */
    32
    33/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
    34
    35#ifndef __SCIP_CONS_SOS1_H__
    36#define __SCIP_CONS_SOS1_H__
    37
    38
    39#include "scip/def.h"
    40#include "scip/type_cons.h"
    41#include "scip/type_misc.h"
    42#include "scip/type_retcode.h"
    43#include "scip/type_scip.h"
    44#include "scip/type_sol.h"
    45#include "scip/type_var.h"
    46
    47#ifdef __cplusplus
    48extern "C" {
    49#endif
    50
    51/** creates the handler for SOS1 constraints and includes it in SCIP
    52 *
    53 * @ingroup ConshdlrIncludes
    54 * */
    55SCIP_EXPORT
    57 SCIP* scip /**< SCIP data structure */
    58 );
    59
    60/**@addtogroup CONSHDLRS
    61 *
    62 * @{
    63 *
    64 * @name Specially Ordered Set (SOS) Type 1 Constraints
    65 *
    66 * @{
    67 *
    68 * A specially ordered set of type 1 (SOS1) is a sequence of variables such that at most one
    69 * variable is nonzero. The special case of two variables arises, for instance, from equilibrium or
    70 * complementary conditions like \f$x \cdot y = 0\f$. Note that it is in principle allowed that a
    71 * variable appears twice, but it then can be fixed to 0.
    72 */
    73
    74/** creates and captures an SOS1 constraint
    75 *
    76 * We set the constraint to not be modifable. If the weights are non
    77 * NULL, the variables are ordered according to these weights (in
    78 * ascending order).
    79 *
    80 * @note The constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons().
    81 */
    82SCIP_EXPORT
    84 SCIP* scip, /**< SCIP data structure */
    85 SCIP_CONS** cons, /**< pointer to hold the created constraint */
    86 const char* name, /**< name of constraint */
    87 int nvars, /**< number of variables in the constraint */
    88 SCIP_VAR** vars, /**< array with variables of constraint entries */
    89 SCIP_Real* weights, /**< weights determining the variable order, or NULL if natural order should be used */
    90 SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
    91 * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
    92 SCIP_Bool separate, /**< should the constraint be separated during LP processing?
    93 * Usually set to TRUE. */
    94 SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
    95 * TRUE for model constraints, FALSE for additional, redundant constraints. */
    96 SCIP_Bool check, /**< should the constraint be checked for feasibility?
    97 * TRUE for model constraints, FALSE for additional, redundant constraints. */
    98 SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
    99 * Usually set to TRUE. */
    100 SCIP_Bool local, /**< is constraint only valid locally?
    101 * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
    102 SCIP_Bool dynamic, /**< is constraint subject to aging?
    103 * Usually set to FALSE. Set to TRUE for own cuts which
    104 * are separated as constraints. */
    105 SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
    106 * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
    107 SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
    108 * if it may be moved to a more global node?
    109 * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
    110 );
    111
    112/** creates and captures an SOS1 constraint
    113 * in its most basic variant, i. e., with all constraint flags set to their default values, which can be set
    114 * afterwards using SCIPsetConsFLAGNAME() in scip.h
    115 *
    116 * @see SCIPcreateConsSOS1() for the default constraint flag configuration
    117 *
    118 * @warning Do NOT set the constraint to be modifiable manually, because this might lead
    119 * to wrong results as the variable array will not be re-sorted
    120 *
    121 * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
    122 */
    123SCIP_EXPORT
    125 SCIP* scip, /**< SCIP data structure */
    126 SCIP_CONS** cons, /**< pointer to hold the created constraint */
    127 const char* name, /**< name of constraint */
    128 int nvars, /**< number of variables in the constraint */
    129 SCIP_VAR** vars, /**< array with variables of constraint entries */
    130 SCIP_Real* weights /**< weights determining the variable order, or NULL if natural order should be used */
    131 );
    132
    133/** adds variable to SOS1 constraint, the position is determined by the given weight */
    134SCIP_EXPORT
    136 SCIP* scip, /**< SCIP data structure */
    137 SCIP_CONS* cons, /**< constraint */
    138 SCIP_VAR* var, /**< variable to add to the constraint */
    139 SCIP_Real weight /**< weight determining position of variable */
    140 );
    141
    142/** appends variable to SOS1 constraint */
    143SCIP_EXPORT
    145 SCIP* scip, /**< SCIP data structure */
    146 SCIP_CONS* cons, /**< constraint */
    147 SCIP_VAR* var /**< variable to add to the constraint */
    148 );
    149
    150/** gets number of variables in SOS1 constraint */
    151SCIP_EXPORT
    153 SCIP* scip, /**< SCIP data structure */
    154 SCIP_CONS* cons /**< constraint */
    155 );
    156
    157/** gets array of variables in SOS1 constraint */
    158SCIP_EXPORT
    160 SCIP* scip, /**< SCIP data structure */
    161 SCIP_CONS* cons /**< constraint data */
    162 );
    163
    164/** gets array of weights in SOS1 constraint (or NULL if not existent) */
    165SCIP_EXPORT
    167 SCIP* scip, /**< SCIP data structure */
    168 SCIP_CONS* cons /**< constraint data */
    169 );
    170
    171/** gets conflict graph of SOS1 constraints (or NULL if not existent)
    172 *
    173 * @note The conflict graph is globally valid; local changes are not taken into account.
    174 */
    175SCIP_EXPORT
    177 SCIP_CONSHDLR* conshdlr /**< SOS1 constraint handler */
    178 );
    179
    180/** gets number of problem variables that are part of the SOS1 conflict graph */
    181SCIP_EXPORT
    183 SCIP_CONSHDLR* conshdlr /**< SOS1 constraint handler */
    184 );
    185
    186/** returns whether variable is part of the SOS1 conflict graph */
    187SCIP_EXPORT
    189 SCIP_CONSHDLR* conshdlr, /**< SOS1 constraint handler */
    190 SCIP_VAR* var /**< variable */
    191 );
    192
    193/** returns node of variable in the conflict graph or -1 if variable is not part of the SOS1 conflict graph */
    194SCIP_EXPORT
    196 SCIP_CONSHDLR* conshdlr, /**< SOS1 constraint handler */
    197 SCIP_VAR* var /**< variable */
    198 );
    199
    200/** returns variable that belongs to a given node from the conflict graph */
    201SCIP_EXPORT
    203 SCIP_DIGRAPH* conflictgraph, /**< conflict graph */
    204 int node /**< node from the conflict graph */
    205 );
    206
    207/** based on solution values of the variables, fixes variables to zero to turn all SOS1 constraints feasible */
    208SCIP_EXPORT
    210 SCIP* scip, /**< SCIP pointer */
    211 SCIP_CONSHDLR* conshdlr, /**< SOS1 constraint handler */
    212 SCIP_SOL* sol, /**< solution */
    213 SCIP_Bool* changed, /**< pointer to store whether the solution has been changed */
    214 SCIP_Bool* success /**< pointer to store whether SOS1 constraints have been turned feasible and
    215 * solution was good enough */
    216 );
    217
    218/** @} */
    219
    220/** @} */
    221
    222#ifdef __cplusplus
    223}
    224#endif
    225
    226#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_DIGRAPH * SCIPgetConflictgraphSOS1(SCIP_CONSHDLR *conshdlr)
    Definition: cons_sos1.c:10872
    SCIP_Bool SCIPvarIsSOS1(SCIP_CONSHDLR *conshdlr, SCIP_VAR *var)
    Definition: cons_sos1.c:10916
    SCIP_RETCODE SCIPmakeSOS1sFeasible(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_SOL *sol, SCIP_Bool *changed, SCIP_Bool *success)
    Definition: cons_sos1.c:10996
    SCIP_RETCODE SCIPaddVarSOS1(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
    Definition: cons_sos1.c:10725
    SCIP_RETCODE SCIPcreateConsSOS1(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
    Definition: cons_sos1.c:10579
    SCIP_RETCODE SCIPcreateConsBasicSOS1(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights)
    Definition: cons_sos1.c:10709
    SCIP_Real * SCIPgetWeightsSOS1(SCIP *scip, SCIP_CONS *cons)
    Definition: cons_sos1.c:10844
    SCIP_RETCODE SCIPappendVarSOS1(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
    Definition: cons_sos1.c:10761
    int SCIPgetNSOS1Vars(SCIP_CONSHDLR *conshdlr)
    Definition: cons_sos1.c:10894
    int SCIPvarGetNodeSOS1(SCIP_CONSHDLR *conshdlr, SCIP_VAR *var)
    Definition: cons_sos1.c:10940
    SCIP_VAR ** SCIPgetVarsSOS1(SCIP *scip, SCIP_CONS *cons)
    Definition: cons_sos1.c:10819
    int SCIPgetNVarsSOS1(SCIP *scip, SCIP_CONS *cons)
    Definition: cons_sos1.c:10794
    SCIP_VAR * SCIPnodeGetVarSOS1(SCIP_DIGRAPH *conflictgraph, int node)
    Definition: cons_sos1.c:10971
    SCIP_RETCODE SCIPincludeConshdlrSOS1(SCIP *scip)
    Definition: cons_sos1.c:10361
    static SCIP_RETCODE separate(SCIP *scip, SCIP_SEPA *sepa, SCIP_SOL *sol, SCIP_RESULT *result)
    Main separation function.
    Definition: sepa_flower.c:1221
    type definitions for constraints and constraint handlers
    type definitions for miscellaneous datastructures
    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 storing primal CIP solutions
    type definitions for problem variables