Skip to content
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_disjunction.h
* @ingroup CONSHDLRS
* @brief constraint handler for disjunction constraints
* @author Stefan Heinz
* @author Michael Winkler
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_DISJUNCTION_H__
#define __SCIP_CONS_DISJUNCTION_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for disjunction constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrDisjunction(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Disjunction Constraints
*
* @{
*
* A disjunction constraint \f$ C \f$ is a constraint of the form
* \f[
* C = C_1 \vee \dots \vee C_n
* \f]
* where all the \f$ C_i \f$ are individual constraints themselves.
*/
/** creates and captures a disjunction constraint
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsDisjunction(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nconss, /**< number of initial constraints in disjunction */
SCIP_CONS** conss, /**< initial constraint in disjunction */
SCIP_CONS* relaxcons, /**< a conjunction constraint containing the linear relaxation of the disjunction constraint, or NULL */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
);
/** creates and captures a cumulative constraint
* in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
* method SCIPcreateConsDisjunction(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
*
* @see SCIPcreateConsDisjunction() for information about the basic constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicDisjunction(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nconss, /**< number of initial constraints in disjunction */
SCIP_CONS** conss, /**< initial constraint in disjunction */
SCIP_CONS* relaxcons /**< a conjunction constraint containing the linear relaxation of the disjunction constraint, or NULL */
);
/** adds constraint to the disjunction of constraints */
SCIP_EXPORT
SCIP_RETCODE SCIPaddConsElemDisjunction(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< disjunction constraint */
SCIP_CONS* addcons /**< additional constraint in disjunction */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_indicator.h
* @ingroup CONSHDLRS
* @brief constraint handler for indicator constraints
* @author Marc Pfetsch
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_INDICATOR_H__
#define __SCIP_CONS_INDICATOR_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_lp.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_sol.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for indicator constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrIndicator(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Indicator Constraints
*
* @{
*
* An indicator constraint is given by a binary variable \f$z\f$ and an inequality \f$ax \leq
* b\f$. It states that if \f$z = 1\f$ then \f$ax \leq b\f$ holds.
*
* This constraint is handled by adding a slack variable \f$s:\; ax - s \leq b\f$ with \f$s \geq
* 0\f$. The constraint is enforced by fixing \f$s\f$ to 0 if \f$z = 1\f$.
*
* @note The constraint only implements an implication not an equivalence, i.e., it does not ensure
* that \f$z = 1\f$ if \f$ax \leq b\f$ or equivalently if \f$s = 0\f$ holds.
*
* This constraint is equivalent to a linear constraint \f$ax - s \leq b\f$ and an SOS1 constraint on
* \f$z\f$ and \f$s\f$ (at most one should be nonzero). In the indicator context we can, however,
* separate more inequalities.
*/
/** creates and captures an indicator constraint
*
* @note @a binvar is checked to be binary only later. This enables a change of the type in
* procedures reading an instance.
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsIndicator(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint (indicator or quadratic) */
const char* name, /**< name of constraint */
SCIP_VAR* binvar, /**< binary indicator variable (or NULL) */
int nvars, /**< number of variables in the inequality */
SCIP_VAR** vars, /**< array with variables of inequality (or NULL) */
SCIP_Real* vals, /**< values of variables in inequality (or NULL) */
SCIP_Real rhs, /**< rhs of the inequality */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP? Usually set to TRUE. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures an indicator constraint in its most basic version, i. e., all constraint flags are set to their
* basic value as explained for the method SCIPcreateConsIndicator(); all flags can be set via
* SCIPsetConsFLAGNAME-methods in scip.h
*
* @see SCIPcreateConsIndicator() for information about the basic constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicIndicator(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint (indicator or quadratic) */
const char* name, /**< name of constraint */
SCIP_VAR* binvar, /**< binary indicator variable (or NULL) */
int nvars, /**< number of variables in the inequality */
SCIP_VAR** vars, /**< array with variables of inequality (or NULL) */
SCIP_Real* vals, /**< values of variables in inequality (or NULL) */
SCIP_Real rhs /**< rhs of the inequality */
);
/** creates and captures an indicator constraint with given linear constraint and slack variable
*
* @note @a binvar is checked to be binary only later. This enables a change of the type in
* procedures reading an instance.
*
* @note we assume that @a slackvar actually appears in @a lincons and we also assume that it takes
* the role of a slack variable!
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsIndicatorLinCons(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR* binvar, /**< binary indicator variable (or NULL) */
SCIP_CONS* lincons, /**< linear constraint */
SCIP_VAR* slackvar, /**< slack variable */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP? Usually set to TRUE. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures an indicator constraint with given linear constraint and slack variable
* in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
* method SCIPcreateConsIndicator(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
* @note @a binvar is checked to be binary only later. This enables a change of the type in
* procedures reading an instance.
*
* @note we assume that @a slackvar actually appears in @a lincons and we also assume that it takes
* the role of a slack variable!
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*
* @see SCIPcreateConsIndicatorLinCons() for information about the basic constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicIndicatorLinCons(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR* binvar, /**< binary indicator variable (or NULL) */
SCIP_CONS* lincons, /**< linear constraint */
SCIP_VAR* slackvar /**< slack variable */
);
/** adds variable to the inequality of the indicator constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPaddVarIndicator(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< indicator constraint */
SCIP_VAR* var, /**< variable to add to the inequality */
SCIP_Real val /**< value of variable */
);
/** gets the linear constraint corresponding to the indicator constraint (may be NULL) */
SCIP_EXPORT
SCIP_CONS* SCIPgetLinearConsIndicator(
SCIP_CONS* cons /**< indicator constraint */
);
/** sets the linear constraint corresponding to the indicator constraint (may be NULL) */
SCIP_EXPORT
SCIP_RETCODE SCIPsetLinearConsIndicator(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< indicator constraint */
SCIP_CONS* lincons /**< linear constraint */
);
/** sets binary indicator variable for indicator constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPsetBinaryVarIndicator(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< indicator constraint */
SCIP_VAR* binvar /**< binary variable to add to the inequality */
);
/** gets binary variable corresponding to indicator constraint */
SCIP_EXPORT
SCIP_VAR* SCIPgetBinaryVarIndicator(
SCIP_CONS* cons /**< indicator constraint */
);
/** gets slack variable corresponding to indicator constraint */
SCIP_EXPORT
SCIP_VAR* SCIPgetSlackVarIndicator(
SCIP_CONS* cons /**< indicator constraint */
);
/** sets upper bound for slack variable corresponding to indicator constraint
*
* Use with care if you know that the maximal violation of the corresponding constraint is at most @p ub. This bound
* might be improved automatically during the solution process.
*
* @pre This method should only be called if SCIP is in one of the following stages:
* - \ref SCIP_STAGE_INIT
* - \ref SCIP_STAGE_PROBLEM
*/
SCIP_EXPORT
SCIP_RETCODE SCIPsetSlackVarUb(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< indicator constraint */
SCIP_Real ub /**< upper bound for slack variable */
);
/** checks whether indicator constraint is violated w.r.t. sol */
SCIP_EXPORT
SCIP_Bool SCIPisViolatedIndicator(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< indicator constraint */
SCIP_SOL* sol /**< solution, or NULL to use current node's solution */
);
/** based on values of other variables, computes slack and binary variable to turn constraint feasible */
SCIP_EXPORT
SCIP_RETCODE SCIPmakeIndicatorFeasible(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< indicator constraint */
SCIP_SOL* sol, /**< solution */
SCIP_Bool* changed /**< pointer to store whether the solution has been changed */
);
/** based on values of other variables, computes slack and binary variable to turn all constraints feasible */
SCIP_EXPORT
SCIP_RETCODE SCIPmakeIndicatorsFeasible(
SCIP* scip, /**< SCIP data structure */
SCIP_CONSHDLR* conshdlr, /**< indicator constraint handler */
SCIP_SOL* sol, /**< solution */
SCIP_Bool* changed /**< pointer to store whether the solution has been changed */
);
/** adds additional linear constraint that is not connected with an indicator constraint, but can be used for separation */
SCIP_EXPORT
SCIP_RETCODE SCIPaddLinearConsIndicator(
SCIP* scip, /**< SCIP data structure */
SCIP_CONSHDLR* conshdlr, /**< indicator constraint handler */
SCIP_CONS* lincons /**< linear constraint */
);
/** adds additional globally valid row that is not connected with an indicator constraint, but can be used for separation */
SCIP_EXPORT
SCIP_RETCODE SCIPaddRowIndicator(
SCIP* scip, /**< SCIP data structure */
SCIP_CONSHDLR* conshdlr, /**< indicator constraint handler */
SCIP_ROW* row /**< row to add */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_integral.h
* @ingroup CONSHDLRS
* @brief constraint handler for the integrality constraint
* @author Tobias Achterberg
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_INTEGRAL_H__
#define __SCIP_CONS_INTEGRAL_H__
#include "scip/def.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for the integrality constraint and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrIntegral(
SCIP* scip /**< SCIP data structure */
);
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_knapsack.h
* @ingroup CONSHDLRS
* @brief Constraint handler for knapsack constraints of the form \f$a^T x \le b\f$, x binary and \f$a \ge 0\f$.
* @author Tobias Achterberg
* @author Kati Wolter
* @author Michael Winkler
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_KNAPSACK_H__
#define __SCIP_CONS_KNAPSACK_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_lp.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_sepa.h"
#include "scip/type_sol.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for knapsack constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrKnapsack(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Knapsack Constraints
*
* @{
*
* This constraint handler handles a special type of linear constraints, namely knapsack constraints.
* A knapsack constraint has the form
* \f[
* \sum_{i=1}^n a_i x_i \leq b
* \f]
* with non-negative integer coefficients \f$a_i\f$, integer right-hand side \f$b\f$, and binary variables \f$x_i\f$.
*/
/** creates and captures a knapsack constraint
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsKnapsack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of items in the knapsack */
SCIP_VAR** vars, /**< array with item variables */
SCIP_Longint* weights, /**< array with item weights */
SCIP_Longint capacity, /**< capacity of knapsack (right hand side of inequality) */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a knapsack constraint
* in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
* method SCIPcreateConsKnapsack(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
*
* @see SCIPcreateConsKnapsack() for information about the basic constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicKnapsack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of items in the knapsack */
SCIP_VAR** vars, /**< array with item variables */
SCIP_Longint* weights, /**< array with item weights */
SCIP_Longint capacity /**< capacity of knapsack */
);
/** adds new item to knapsack constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPaddCoefKnapsack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_VAR* var, /**< item variable */
SCIP_Longint weight /**< item weight */
);
/** gets the capacity of the knapsack constraint */
SCIP_EXPORT
SCIP_Longint SCIPgetCapacityKnapsack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** changes capacity of the knapsack constraint
*
* @note This method can only be called during problem creation stage (SCIP_STAGE_PROBLEM)
*/
SCIP_EXPORT
SCIP_RETCODE SCIPchgCapacityKnapsack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_Longint capacity /**< new capacity of knapsack */
);
/** gets the number of items in the knapsack constraint */
SCIP_EXPORT
int SCIPgetNVarsKnapsack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the array of variables in the knapsack constraint; the user must not modify this array! */
SCIP_EXPORT
SCIP_VAR** SCIPgetVarsKnapsack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the array of weights in the knapsack constraint; the user must not modify this array! */
SCIP_EXPORT
SCIP_Longint* SCIPgetWeightsKnapsack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the dual solution of the knapsack constraint in the current LP */
SCIP_EXPORT
SCIP_Real SCIPgetDualsolKnapsack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the dual Farkas value of the knapsack constraint in the current infeasible LP */
SCIP_EXPORT
SCIP_Real SCIPgetDualfarkasKnapsack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** returns the linear relaxation of the given knapsack constraint; may return NULL if no LP row was yet created;
* the user must not modify the row!
*/
SCIP_EXPORT
SCIP_ROW* SCIPgetRowKnapsack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** solves knapsack problem in maximization form exactly using dynamic programming;
* if needed, one can provide arrays to store all selected items and all not selected items
*
* @note in case you provide the solitems or nonsolitems array you also have to provide the counter part, as well
*
* @note the algorithm will first compute a greedy solution and terminate
* if the greedy solution is proven to be optimal.
* The dynamic programming algorithm runs with a time and space complexity
* of O(nitems * capacity).
*/
SCIP_EXPORT
SCIP_RETCODE SCIPsolveKnapsackExactly(
SCIP* scip, /**< SCIP data structure */
int nitems, /**< number of available items */
SCIP_Longint* weights, /**< item weights */
SCIP_Real* profits, /**< item profits */
SCIP_Longint capacity, /**< capacity of knapsack */
int* items, /**< item numbers */
int* solitems, /**< array to store items in solution, or NULL */
int* nonsolitems, /**< array to store items not in solution, or NULL */
int* nsolitems, /**< pointer to store number of items in solution, or NULL */
int* nnonsolitems, /**< pointer to store number of items not in solution, or NULL */
SCIP_Real* solval, /**< pointer to store optimal solution value, or NULL */
SCIP_Bool* success /**< pointer to store if an error occured during solving
* (normally a memory problem) */
);
/** solves knapsack problem in maximization form approximately by solving the LP-relaxation of the problem using Dantzig's
* method and rounding down the solution; if needed, one can provide arrays to store all selected items and all not
* selected items
*/
SCIP_EXPORT
SCIP_RETCODE SCIPsolveKnapsackApproximately(
SCIP* scip, /**< SCIP data structure */
int nitems, /**< number of available items */
SCIP_Longint* weights, /**< item weights */
SCIP_Real* profits, /**< item profits */
SCIP_Longint capacity, /**< capacity of knapsack */
int* items, /**< item numbers */
int* solitems, /**< array to store items in solution, or NULL */
int* nonsolitems, /**< array to store items not in solution, or NULL */
int* nsolitems, /**< pointer to store number of items in solution, or NULL */
int* nnonsolitems, /**< pointer to store number of items not in solution, or NULL */
SCIP_Real* solval /**< pointer to store optimal solution value, or NULL */
);
/** separates different classes of valid inequalities for the 0-1 knapsack problem */
SCIP_EXPORT
SCIP_RETCODE SCIPseparateKnapsackCuts(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< originating constraint of the knapsack problem, or NULL */
SCIP_SEPA* sepa, /**< originating separator of the knapsack problem, or NULL */
SCIP_VAR** vars, /**< variables in knapsack constraint */
int nvars, /**< number of variables in knapsack constraint */
SCIP_Longint* weights, /**< weights of variables in knapsack constraint */
SCIP_Longint capacity, /**< capacity of knapsack */
SCIP_SOL* sol, /**< primal SCIP solution to separate, NULL for current LP solution */
SCIP_Bool usegubs, /**< should GUB information be used for separation? */
SCIP_Bool* cutoff, /**< pointer to store whether a cutoff has been detected */
int* ncuts /**< pointer to add up the number of found cuts */
);
/* relaxes given general linear constraint into a knapsack constraint and separates lifted knapsack cover inequalities */
SCIP_EXPORT
SCIP_RETCODE SCIPseparateRelaxedKnapsack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< originating constraint of the knapsack problem, or NULL */
SCIP_SEPA* sepa, /**< originating separator of the knapsack problem, or NULL */
int nknapvars, /**< number of variables in the continuous knapsack constraint */
SCIP_VAR** knapvars, /**< variables in the continuous knapsack constraint */
SCIP_Real* knapvals, /**< coefficients of the variables in the continuous knapsack constraint */
SCIP_Real valscale, /**< -1.0 if lhs of row is used as rhs of c. k. constraint, +1.0 otherwise */
SCIP_Real rhs, /**< right hand side of the continuous knapsack constraint */
SCIP_SOL* sol, /**< primal CIP solution, NULL for current LP solution */
SCIP_Bool* cutoff, /**< pointer to store whether a cutoff was found */
int* ncuts /**< pointer to add up the number of found cuts */
);
/** cleans up (multi-)aggregations and fixings from knapsack constraints */
SCIP_EXPORT
SCIP_RETCODE SCIPcleanupConssKnapsack(
SCIP* scip, /**< SCIP data structure */
SCIP_Bool onlychecked, /**< should only checked constraints be cleaned up? */
SCIP_Bool* infeasible /**< pointer to return whether the problem was detected to be infeasible */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_linear.h
* @ingroup CONSHDLRS
* @brief Constraint handler for linear constraints in their most general form, \f$lhs <= a^T x <= rhs\f$.
* @author Tobias Achterberg
* @author Timo Berthold
* @author Marc Pfetsch
* @author Kati Wolter
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_LINEAR_H__
#define __SCIP_CONS_LINEAR_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_lp.h"
#include "scip/type_misc.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_sol.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* constraint specific interface methods
*/
/** creates the handler for linear constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrLinear(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Linear Constraints
*
* This constraint handler handles linear constraints in their most general form. That is,
* \f[
* lhs \leq \sum_{i=1}^n a_i x_i \leq rhs
* \f]
* with \f$a_i \in Q, i = 1,\dots,n\f$, \f$lhs\in Q \cup \{-\infty\}\f$, \f$rhs\in Q \cup \{\infty\}\f$,
* and decision variables \f$x_i, i = 1,\dots,n\f$ which can be binary, integer, or continuous.
*
* Furthermore, this header offers the upgrade functionality of a general linear constraint into a more specific
* constraint, such as a knapsack constraint, via SCIP_DECL_LINCONSUPGD() and SCIPincludeLinconsUpgrade()
*
* @{
*/
typedef struct SCIP_LinConsUpgrade SCIP_LINCONSUPGRADE; /**< linear constraint update method */
/** upgrading method for linear constraints into more specific constraints
*
* input:
* - scip : SCIP main data structure
* - cons : the linear constraint to upgrade
* - nvars : number of variables in the constraint
* - vars : array with constraint variables
* - vals : array with constraint coefficients
* - lhs : left hand side of linear constraint
* - rhs : right hand side of linear constraint
* - nposbin : number of binary variables with positive coefficient
* - nnegbin : number of binary variables with negative coefficient
* - nposint : number of integer variables with positive coefficient
* - nnegint : number of integer variables with negative coefficient
* - nposimpl : number of implicit integer variables with positive coefficient (including implicit binary variables)
* - nnegimpl : number of implicit integer variables with negative coefficient (including implicit binary variables)
* - nposimplbin : number of implicit binary variables with positive coefficient
* - nnegimplbin : number of implicit binary variables with negative coefficient
* - nposcont : number of continuous variables with positive coefficient
* - nnegcont : number of continuous variables with negative coefficient
* - ncoeffspone : number of +1 coefficients
* - ncoeffsnone : number of -1 coefficients
* - ncoeffspint : number of positive integral coefficients other than +1
* - ncoeffsnint : number of negative integral coefficients other than -1
* - ncoeffspfrac : number of positive fractional coefficients
* - ncoeffsnfrac : number of negative fractional coefficients
* - poscoeffsum : sum of all positive coefficients
* - negcoeffsum : sum of all negative coefficients
* - integral : TRUE iff constraints activity value is always integral
* - upgdcons : pointer to store the upgraded constraint
*/
#define SCIP_DECL_LINCONSUPGD(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONS* cons, int nvars, SCIP_VAR** vars, SCIP_Real* vals, SCIP_Real lhs, SCIP_Real rhs, \
int nposbin, int nnegbin, int nposint, int nnegint, int nposimpl, int nnegimpl, int nposimplbin, int nnegimplbin, int nposcont, int nnegcont, \
int ncoeffspone, int ncoeffsnone, int ncoeffspint, int ncoeffsnint, int ncoeffspfrac, int ncoeffsnfrac, \
SCIP_Real poscoeffsum, SCIP_Real negcoeffsum, SCIP_Bool integral, SCIP_CONS** upgdcons)
/** includes a linear constraint update method into the linear constraint handler */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeLinconsUpgrade(
SCIP* scip, /**< SCIP data structure */
SCIP_DECL_LINCONSUPGD((*linconsupgd)), /**< method to call for upgrading linear constraint */
int priority, /**< priority of upgrading method */
const char* conshdlrname /**< name of the constraint handler */
);
/** creates and captures a linear constraint
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of nonzeros in the constraint */
SCIP_VAR** vars, /**< array with variables of constraint entries */
SCIP_Real* vals, /**< array with coefficients of constraint entries */
SCIP_Real lhs, /**< left hand side of constraint */
SCIP_Real rhs, /**< right hand side of constraint */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a linear constraint
* in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
* method SCIPcreateConsLinear(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
*
* @see SCIPcreateConsLinear() for information about the basic constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of nonzeros in the constraint */
SCIP_VAR** vars, /**< array with variables of constraint entries */
SCIP_Real* vals, /**< array with coefficients of constraint entries */
SCIP_Real lhs, /**< left hand side of constraint */
SCIP_Real rhs /**< right hand side of constraint */
);
/** creates by copying and captures a linear constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPcopyConsLinear(
SCIP* scip, /**< target SCIP data structure */
SCIP_CONS** cons, /**< pointer to store the created target constraint */
SCIP* sourcescip, /**< source SCIP data structure */
const char* name, /**< name of constraint */
int nvars, /**< number of variables in source variable array */
SCIP_VAR** sourcevars, /**< source variables of the linear constraints */
SCIP_Real* sourcecoefs, /**< coefficient array of the linear constraint, or NULL if all coefficients are one */
SCIP_Real lhs, /**< left hand side of the linear constraint */
SCIP_Real rhs, /**< right hand side of the linear constraint */
SCIP_HASHMAP* varmap, /**< a SCIP_HASHMAP mapping variables of the source SCIP to corresponding
* variables of the target SCIP */
SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
* target constraints */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP? */
SCIP_Bool separate, /**< should the constraint be separated during LP processing? */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing? */
SCIP_Bool check, /**< should the constraint be checked for feasibility? */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing? */
SCIP_Bool local, /**< is constraint only valid locally? */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)? */
SCIP_Bool dynamic, /**< is constraint subject to aging? */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup? */
SCIP_Bool stickingatnode, /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node? */
SCIP_Bool global, /**< create a global or a local copy? */
SCIP_Bool* valid /**< pointer to store if the copying was valid */
);
/** adds coefficient to linear constraint (if it is not zero) */
SCIP_EXPORT
SCIP_RETCODE SCIPaddCoefLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_VAR* var, /**< variable of constraint entry */
SCIP_Real val /**< coefficient of constraint entry */
);
/** changes coefficient of variable in linear constraint; deletes the variable if coefficient is zero; adds variable if
* not yet contained in the constraint
*
* @note This method may only be called during problem creation stage for an original constraint and variable.
*
* @note This method requires linear time to search for occurences of the variable in the constraint data.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPchgCoefLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_VAR* var, /**< variable of constraint entry */
SCIP_Real val /**< new coefficient of constraint entry */
);
/** deletes variable from linear constraint
*
* @note This method may only be called during problem creation stage for an original constraint and variable.
*
* @note This method requires linear time to search for occurences of the variable in the constraint data.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPdelCoefLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_VAR* var /**< variable of constraint entry */
);
/** gets left hand side of linear constraint */
SCIP_EXPORT
SCIP_Real SCIPgetLhsLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets right hand side of linear constraint */
SCIP_EXPORT
SCIP_Real SCIPgetRhsLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** changes left hand side of linear constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPchgLhsLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_Real lhs /**< new left hand side */
);
/** changes right hand side of linear constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPchgRhsLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_Real rhs /**< new right hand side */
);
/** gets the number of variables in the linear constraint */
SCIP_EXPORT
int SCIPgetNVarsLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the array of variables in the linear constraint; the user must not modify this array! */
SCIP_EXPORT
SCIP_VAR** SCIPgetVarsLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the array of coefficient values in the linear constraint; the user must not modify this array! */
SCIP_EXPORT
SCIP_Real* SCIPgetValsLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the activity of the linear constraint in the given solution
*
* @note if the solution contains values at infinity, this method will return SCIP_INVALID in case the activity
* comprises positive and negative infinity contributions
*/
SCIP_EXPORT
SCIP_Real SCIPgetActivityLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_SOL* sol /**< solution, or NULL to use current node's solution */
);
/** gets the feasibility of the linear constraint in the given solution */
SCIP_EXPORT
SCIP_Real SCIPgetFeasibilityLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_SOL* sol /**< solution, or NULL to use current node's solution */
);
/** gets the dual solution of the linear constraint in the current LP */
SCIP_EXPORT
SCIP_Real SCIPgetDualsolLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the dual Farkas value of the linear constraint in the current infeasible LP */
SCIP_EXPORT
SCIP_Real SCIPgetDualfarkasLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** returns the linear relaxation of the given linear constraint; may return NULL if no LP row was yet created;
* the user must not modify the row!
*/
SCIP_EXPORT
SCIP_ROW* SCIPgetRowLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** tries to automatically convert a linear constraint into a more specific and more specialized constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPupgradeConsLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< source constraint to try to convert */
SCIP_CONS** upgdcons /**< pointer to store upgraded constraint, or NULL if not successful */
);
/** performs linear constraint type classification as used for MIPLIB
*
* iterates through all linear constraints and stores relevant statistics in the linear constraint statistics \p linconsstats.
*
* @note only constraints are iterated that belong to the linear constraint handler. If the problem has been presolved already,
* constraints that were upgraded to more special types such as, e.g., varbound constraints, will not be shown correctly anymore.
* Similarly, if specialized constraints were created through the API, these are currently not present.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPclassifyConstraintTypesLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_LINCONSSTATS* linconsstats /**< linear constraint type classification */
);
/** cleans up (multi-)aggregations and fixings from linear constraints */
SCIP_EXPORT
SCIP_RETCODE SCIPcleanupConssLinear(
SCIP* scip, /**< SCIP data structure */
SCIP_Bool onlychecked, /**< should only checked constraints be cleaned up? */
SCIP_Bool* infeasible /**< pointer to return whether the problem was detected to be infeasible */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_linking.h
* @ingroup CONSHDLRS
* @brief constraint handler for linking binary variables to a linking (continuous or integer) variable
* @author Stefan Heinz
* @author Jens Schulz
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_LINKING_H__
#define __SCIP_CONS_LINKING_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for linking constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrLinking(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Linking Constraints
*
* @{
*
* The constraints handler stores linking constraints between a linking variable (continuous or integer) and an array of binary variables. Such
* a linking constraint has the form:
* \f[
* y = \sum_{i=1}^n {c_i * x_i}
* \f]
* with linking variable (continuous or integer) \f$ y \f$, binary variables \f$ x_1, \dots, x_n \f$ and offset \f$b \in Q\f$, and
* with the additional side condition that exactly one binary variable has to be one (set partitioning condition).
*
* This constraint can be created only with the linking variable, if it is an integer variable. In this case the binary variables are only created on
* demand. That is, whenever someone asks for the binary variables. Therefore, such constraints can be used to get a
* "binary representation" of the domain of the linking variable which will be dynamically created.
*/
/** creates and captures a linking constraint
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsLinking(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR* linkvar, /**< linking variable (continuous or integer) which should be linked */
SCIP_VAR** binvars, /**< binary variables */
SCIP_Real* vals, /**< coefficients of the binary variables */
int nbinvars, /**< number of binary starting variables */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a linking constraint
* in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
* method SCIPcreateConsLinking(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
*
* @see SCIPcreateConsLinking() for information about the basic constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicLinking(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR* linkvar, /**< linking variable (continuous or integer) which should be linked */
SCIP_VAR** binvars, /**< binary variables, or NULL */
SCIP_Real* vals, /**< coefficients of the binary variables */
int nbinvars /**< number of binary variables */
);
/** checks if for the given linking variable (continuous or integer) a linking constraint exists */
SCIP_EXPORT
SCIP_Bool SCIPexistsConsLinking(
SCIP* scip, /**< SCIP data structure */
SCIP_VAR* linkvar /**< linking variable (continuous or integer) which should be linked */
);
/** returns the linking constraint belonging the given linking variable (continuous or integer) or NULL if it does not exist yet */
SCIP_EXPORT
SCIP_CONS* SCIPgetConsLinking(
SCIP* scip, /**< SCIP data structure */
SCIP_VAR* linkvar /**< linking variable (continuous or integer) which should be linked */
);
/** returns the linking variable (continuous or integer) of the linking constraint */
SCIP_EXPORT
SCIP_VAR* SCIPgetLinkvarLinking(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< linking constraint */
);
/** returns the binary variables of the linking constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPgetBinvarsLinking(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< linking constraint */
SCIP_VAR*** binvars, /**< pointer to store the binary variables array pointer */
int* nbinvars /**< pointer to store the number of returned binary variables */
);
/** returns the number of binary variables of the linking constraint */
SCIP_EXPORT
int SCIPgetNBinvarsLinking(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< linking constraint */
);
/** returns the coefficients of the binary variables */
SCIP_EXPORT
SCIP_Real* SCIPgetValsLinking(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< linking constraint */
);
/** return all binary variable information of the linking constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPgetBinvarsDataLinking(
SCIP_CONS* cons, /**< linking constraint */
SCIP_VAR*** binvars, /**< pointer to store binary variables, or NULL */
SCIP_Real** vals, /**< pointer to store the binary coefficients, or NULL */
int* nbinvars /**< pointer to store the number of binary variables, or NULL */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_logicor.h
* @ingroup CONSHDLRS
* @brief Constraint handler for logicor constraints \f$1^T x \ge 1\f$ (equivalent to set covering, but algorithms are suited for depth first search).
* @author Tobias Achterberg
* @author Michael Winkler
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_LOGICOR_H__
#define __SCIP_CONS_LOGICOR_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_lp.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for logic or constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrLogicor(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Logicor Constraints
*
* @{
*
* This constraint handler handles a special type of linear constraints, namely
* logic or constraints. These are equivalent to set covering constraints, but
* are handled by special algorithms which are better suited for depth first search.
* For a set of binary variables \f$x_i, i=1,\dots,n\f$, a logic or constraint has the form
* \f[
* \sum_{i=1}^n x_i \ge 1.
* \f]
*/
/** creates and captures a logic or constraint
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsLogicor(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of variables in the constraint */
SCIP_VAR** vars, /**< array with variables of constraint entries */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a logicor constraint
* in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
* method SCIPcreateConsLogicor(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
*
* @see SCIPcreateConsLogicor() for information about the basic constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicLogicor(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of variables in the constraint */
SCIP_VAR** vars /**< array with variables of constraint entries */
);
/** adds coefficient in logic or constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPaddCoefLogicor(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< logicor constraint */
SCIP_VAR* var /**< variable to add to the constraint */
);
/** gets number of variables in logic or constraint */
SCIP_EXPORT
int SCIPgetNVarsLogicor(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets array of variables in logic or constraint */
SCIP_EXPORT
SCIP_VAR** SCIPgetVarsLogicor(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the dual solution of the logic or constraint in the current LP */
SCIP_EXPORT
SCIP_Real SCIPgetDualsolLogicor(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the dual Farkas value of the logic or constraint in the current infeasible LP */
SCIP_EXPORT
SCIP_Real SCIPgetDualfarkasLogicor(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** returns the linear relaxation of the given logic or constraint; may return NULL if no LP row was yet created;
* the user must not modify the row!
*/
SCIP_EXPORT
SCIP_ROW* SCIPgetRowLogicor(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** cleans up (multi-)aggregations and fixings from logicor constraints */
SCIP_EXPORT
SCIP_RETCODE SCIPcleanupConssLogicor(
SCIP* scip, /**< SCIP data structure */
SCIP_Bool onlychecked, /**< should only checked constraints be cleaned up? */
int* naddconss, /**< pointer to count number of added (linear) constraints */
int* ndelconss, /**< pointer to count number of deleted (logicor) constraints */
int* nchgcoefs /**< pointer to count number of changed coefficients */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_nonlinear.h
* @ingroup CONSHDLRS
* @brief constraint handler for nonlinear constraints \f$\textrm{lhs} \leq \sum_{i=1}^n a_ix_i + \sum_{j=1}^m c_jf_j(x) \leq \textrm{rhs}\f$
* @author Stefan Vigerske
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_NONLINEAR_H__
#define __SCIP_CONS_NONLINEAR_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "nlpi/type_expr.h"
#include "scip/type_nlp.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_sol.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** upgrading method for nonlinear constraints into more specific constraints
*
* the method might upgrade a nonlinear constraint into a set of upgrade constraints
* the caller provided an array upgdconss to store upgrade constraints
* the length of upgdconss is given by upgdconsssize
* if an upgrade is not possible, set *nupgdconss to zero
* if more than upgdconsssize many constraints shall replace cons, the function
* should return the required number as negated value in *nupgdconss
* i.e., if cons should be replaced by 3 constraints, the function should set
* *nupgdconss to -3 and return with SCIP_OKAY
*
* input:
* - scip : SCIP main data structure
* - cons : the nonlinear constraint to upgrade
* - nupgdconss : pointer to store number of constraints that replace this constraint
* - upgdconss : array to store constraints that replace this constraint
* - upgdconsssize : length of the provided upgdconss array
*/
#define SCIP_DECL_NONLINCONSUPGD(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONS* cons, \
int* nupgdconss, SCIP_CONS** upgdconss, int upgdconsssize)
/** reformulation method for expression graph nodes
*
* The method might reformulate a node in an expression graph by adding
* auxiliary constraints and/or variables.
* The caller provided an expression graph node which is to be reformulated.
* If the method takes action, it has to return the node that should replace
* the given node in *reformnode. The caller will then ensure that all parents of
* node will use *reformnode, so node may be freed.
* If the method does not do any reformulation, it shall return NULL in *reformnode.
* The counter naddcons can be used to setup the names of added variables/constraints.
* The method should increase this counter by the number of added constraints.
* The method has to ensure that the reformulated node, if still valid,
* has valid bound and curvature information.
*
* input:
* - scip : SCIP main data structure
* - exprgraph : the expression graph which node to reformulate
* - node : the expression graph node to reformulate
* - naddcons : counter on number of added constraints so far
*
* output:
* - naddcons : to be increased by number of additionally added constraints
* - reformnode : reformulated node to replace node with, or NULL if no reformulation
*/
#define SCIP_DECL_EXPRGRAPHNODEREFORM(x) SCIP_RETCODE x (SCIP* scip, \
SCIP_EXPRGRAPH* exprgraph, SCIP_EXPRGRAPHNODE* node, \
int* naddcons, SCIP_EXPRGRAPHNODE** reformnode)
/** creates the handler for nonlinear constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrNonlinear(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Nonlinear Constraints
*
* @{
*
* This constraint handler handles constraints of the form
* \f[
* \textrm{lhs} \leq \sum_{i=1}^n a_ix_i + \sum_{j=1}^m c_jf_j(x) \leq \textrm{rhs},
* \f]
* where \f$a_i\f$ and \f$c_j\f$ are coefficients and
* \f$f_j(x)\f$ are nonlinear functions (given as expression tree).
*
* Constraints are enforced by separation, domain propagation, and spatial branching.
*
* For convex or concave \f$f_j(x)\f$, cuts that separate on the convex hull of the function graph are implemented.
* For \f$f_j(x)\f$ that are not known to be convex or concave, a simple variant of linear estimation based on interval gradients is implemented.
*
* Branching is performed for variables in nonconvex terms, if the relaxation solution cannot be separated.
*
* This header offers the upgrade functionality to upgrade a general nonlinear constraint into a more specific constraint
* via SCIP_DECL_NONLINCONSUPGD().
*
* Furthermore, the definition of callbacks used to reformulate an expression graph is offered by
* SCIP_DECL_EXPRGRAPHNODEREFORM().
*
* Further, the function representation is stored in an expression graph, which allows to propagate variable domains
* and constraint sides and offers a simple convexity check.
* During presolve, the expression graph is reformulated, whereby new variables and constraints are created
* such that for the remaining nonlinear constraints the functions \f$f_j(x)\f$ are known to be convex or concave.
* See also
*
* @par
* Stefan Vigerske@n
* Decomposition of Multistage Stochastic Programs and a Constraint Integer Programming Approach to Mixed-Integer Nonlinear Programming@n
* PhD Thesis, Humboldt-University Berlin, 2012, submitted.
*/
/** includes a nonlinear constraint upgrade method into the nonlinear constraint handler */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeNonlinconsUpgrade(
SCIP* scip, /**< SCIP data structure */
SCIP_DECL_NONLINCONSUPGD((*nonlinconsupgd)),/**< method to call for upgrading nonlinear constraint, or NULL */
SCIP_DECL_EXPRGRAPHNODEREFORM((*nodereform)),/**< method to call for reformulating expression graph node, or NULL */
int priority, /**< priority of upgrading method */
SCIP_Bool active, /**< should the upgrading method by active by default? */
const char* conshdlrname /**< name of the constraint handler */
);
/** creates and captures a nonlinear constraint
* this variant takes expression trees as input
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nlinvars, /**< number of linear variables in the constraint */
SCIP_VAR** linvars, /**< array with linear variables of constraint entries */
SCIP_Real* lincoefs, /**< array with coefficients of constraint linear entries */
int nexprtrees, /**< number of expression trees for nonlinear part of constraint */
SCIP_EXPRTREE** exprtrees, /**< expression trees for nonlinear part of constraint */
SCIP_Real* nonlincoefs, /**< coefficients for expression trees for nonlinear part, or NULL if all 1.0 */
SCIP_Real lhs, /**< left hand side of constraint */
SCIP_Real rhs, /**< right hand side of constraint */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are seperated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a nonlinear constraint
* in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
* method SCIPcreateConsNonlinear(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
*
* this variant takes expression trees as input
*
* @see SCIPcreateConsNonlinear() for information about the basic constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nlinvars, /**< number of linear variables in the constraint */
SCIP_VAR** linvars, /**< array with linear variables of constraint entries */
SCIP_Real* lincoefs, /**< array with coefficients of constraint linear entries */
int nexprtrees, /**< number of expression trees for nonlinear part of constraint */
SCIP_EXPRTREE** exprtrees, /**< expression trees for nonlinear part of constraint */
SCIP_Real* nonlincoefs, /**< coefficients for expression trees for nonlinear part, or NULL if all 1.0 */
SCIP_Real lhs, /**< left hand side of constraint */
SCIP_Real rhs /**< right hand side of constraint */
);
/** creates and captures a nonlinear constraint
* this variant takes a node of the expression graph as input and can only be used during presolving
* it is assumed that the nonlinear constraint will be added to the transformed problem short after creation
* the given exprgraphnode is captured in this method
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsNonlinear2(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nlinvars, /**< number of linear variables in the constraint */
SCIP_VAR** linvars, /**< array with linear variables of constraint entries */
SCIP_Real* lincoefs, /**< array with coefficients of constraint linear entries */
SCIP_EXPRGRAPHNODE* exprgraphnode, /**< expression graph node associated to nonlinear expression */
SCIP_Real lhs, /**< left hand side of constraint */
SCIP_Real rhs, /**< right hand side of constraint */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are seperated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a nonlinear constraint
* in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
* method SCIPcreateConsNonlinear2(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
*
* this variant takes a node of the expression graph as input and can only be used during presolving
* it is assumed that the nonlinear constraint will be added to the transformed problem short after creation
* the given exprgraphnode is captured in this method
*
* @see SCIPcreateConsNonlinear2() for information about the basic constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicNonlinear2(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nlinvars, /**< number of linear variables in the constraint */
SCIP_VAR** linvars, /**< array with linear variables of constraint entries */
SCIP_Real* lincoefs, /**< array with coefficients of constraint linear entries */
SCIP_EXPRGRAPHNODE* exprgraphnode, /**< expression graph node associated to nonlinear expression */
SCIP_Real lhs, /**< left hand side of constraint */
SCIP_Real rhs /**< right hand side of constraint */
);
/** adds a linear variable with coefficient to a nonlinear constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPaddLinearVarNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_VAR* var, /**< variable */
SCIP_Real coef /**< coefficient of variable */
);
/** sets the expression trees in a nonlinear constraint
* constraint must not be active yet
*/
SCIP_EXPORT
SCIP_RETCODE SCIPsetExprtreesNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
int nexprtrees, /**< number of expression trees */
SCIP_EXPRTREE** exprtrees, /**< new expression trees, or NULL if nexprtrees is 0 */
SCIP_Real* coefs /**< coefficients of expression trees, or NULL if all 1.0 */
);
/** adds expression trees to a nonlinear constraint
* constraint must not be active yet
*/
SCIP_EXPORT
SCIP_RETCODE SCIPaddExprtreesNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
int nexprtrees, /**< number of expression trees */
SCIP_EXPRTREE** exprtrees, /**< new expression trees, or NULL if nexprtrees is 0 */
SCIP_Real* coefs /**< coefficients of expression trees, or NULL if all 1.0 */
);
/** gets the nonlinear constraint as a nonlinear row representation */
SCIP_EXPORT
SCIP_RETCODE SCIPgetNlRowNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_NLROW** nlrow /**< pointer to store nonlinear row */
);
/** gets the number of variables in the linear term of a nonlinear constraint */
SCIP_EXPORT
int SCIPgetNLinearVarsNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** gets the variables in the linear part of a nonlinear constraint */
SCIP_EXPORT
SCIP_VAR** SCIPgetLinearVarsNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** gets the coefficients in the linear part of a nonlinear constraint */
SCIP_EXPORT
SCIP_Real* SCIPgetLinearCoefsNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** gets the number of expression trees of a nonlinear constraint */
SCIP_EXPORT
int SCIPgetNExprtreesNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** gets the expression trees of a nonlinear constraint */
SCIP_EXPORT
SCIP_EXPRTREE** SCIPgetExprtreesNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** gets the coefficients of the expression trees of a nonlinear constraint */
SCIP_EXPORT
SCIP_Real* SCIPgetExprtreeCoefsNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** gets the expression graph node of a nonlinear constraint */
SCIP_EXPORT
SCIP_EXPRGRAPHNODE* SCIPgetExprgraphNodeNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** gets the left hand side of a nonlinear constraint */
SCIP_EXPORT
SCIP_Real SCIPgetLhsNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** gets the right hand side of a nonlinear constraint */
SCIP_EXPORT
SCIP_Real SCIPgetRhsNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** check the function of a nonlinear constraint for convexity/concavity, if not done yet */
SCIP_EXPORT
SCIP_RETCODE SCIPcheckCurvatureNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** gets the curvature of the nonlinear function of a nonlinear constraint
*
* The curvature is computed by summing up the curvature for each nonlinear summand.
* To get the curvature for single summands, use SCIPgetExprtreeCurvaturesNonlinear().
*/
SCIP_EXPORT
SCIP_RETCODE SCIPgetCurvatureNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_Bool checkcurv, /**< whether to check constraint curvature, if not checked before */
SCIP_EXPRCURV* curvature /**< pointer to store curvature of constraint */
);
/** gets the curvature of the expression trees (multiplied by their coefficient) of a nonlinear constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPgetExprtreeCurvaturesNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_Bool checkcurv, /**< whether to check constraint curvature, if not checked before */
SCIP_EXPRCURV** curvatures /**< buffer to store curvatures of exprtrees */
);
/** computes the violation of a nonlinear constraint by a solution */
SCIP_EXPORT
SCIP_RETCODE SCIPgetViolationNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_SOL* sol, /**< solution which violation to calculate, or NULL for LP solution */
SCIP_Real* violation /**< pointer to store violation of constraint */
);
/** get index of a linear variable of a nonlinear constraint that may be decreased without making any other constraint infeasible, or -1 if none */
SCIP_EXPORT
int SCIPgetLinvarMayDecreaseNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** get index of a linear variable of a nonlinear constraint that may be increased without making any other constraint infeasible, or -1 if none */
SCIP_EXPORT
int SCIPgetLinvarMayIncreaseNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** gets expression graph of nonlinear constraint handler */
SCIP_EXPORT
SCIP_EXPRGRAPH* SCIPgetExprgraphNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONSHDLR* conshdlr /**< nonlinear constraint handler */
);
/** given three points, constructs coefficient of equation for hyperplane generated by these three points
* Three points a, b, and c are given.
* Computes coefficients alpha, beta, gamma, and delta, such that a, b, and c, satisfy
* alpha * x1 + beta * x2 + gamma * x3 = delta and gamma >= 0.0.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcomputeHyperplaneThreePoints(
SCIP* scip, /**< SCIP data structure */
SCIP_Real a1, /**< first coordinate of a */
SCIP_Real a2, /**< second coordinate of a */
SCIP_Real a3, /**< third coordinate of a */
SCIP_Real b1, /**< first coordinate of b */
SCIP_Real b2, /**< second coordinate of b */
SCIP_Real b3, /**< third coordinate of b */
SCIP_Real c1, /**< first coordinate of c */
SCIP_Real c2, /**< second coordinate of c */
SCIP_Real c3, /**< third coordinate of c */
SCIP_Real* alpha, /**< coefficient of first coordinate */
SCIP_Real* beta, /**< coefficient of second coordinate */
SCIP_Real* gamma_, /**< coefficient of third coordinate */
SCIP_Real* delta /**< constant right-hand side */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_or.h
* @ingroup CONSHDLRS
* @brief Constraint handler for "or" constraints, \f$r = x_1 \vee x_2 \vee \dots \vee x_n\f$
* @author Tobias Achterberg
* @author Stefan Heinz
* @author Michael Winkler
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_OR_H__
#define __SCIP_CONS_OR_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for or constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrOr(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name OR Constraints
*
* @{
*
* This constraint handler deals with OR constraint. These are constraint of the form:
*
* \f[
* r = x_1 \vee x_2 \vee \dots \vee x_n
* \f]
*
* where \f$x_i\f$ is a binary variable for all \f$i\f$. Hence, \f$r\f$ is also of binary type. The variable \f$r\f$ is
* called resultant and the \f$x\f$'s operators.
*/
/** creates and captures an or constraint
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsOr(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR* resvar, /**< resultant variable of the operation */
int nvars, /**< number of operator variables in the constraint */
SCIP_VAR** vars, /**< array with operator variables of constraint */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures an or constraint
* in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
* method SCIPcreateConsNonlinear(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
*
* @see SCIPcreateConsOr() for information about the basic constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicOr(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR* resvar, /**< resultant variable of the operation */
int nvars, /**< number of operator variables in the constraint */
SCIP_VAR** vars /**< array with operator variables of constraint */
);
/** gets number of variables in or constraint */
SCIP_EXPORT
int SCIPgetNVarsOr(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets array of variables in or constraint */
SCIP_EXPORT
SCIP_VAR** SCIPgetVarsOr(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the resultant variable in or constraint */
SCIP_EXPORT
SCIP_VAR* SCIPgetResultantOr(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_orbisack.h
* @ingroup CONSHDLRS
* @brief constraint handler for orbisack constraints
* @author Christopher Hojny
*
* The constraint works on two vectors of variables, which are interpreted as columns of a matrix such that the first
* column is lexicographically not smaller than the second.
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_ORBISACK_H__
#define __SCIP_CONS_ORBISACK_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_sol.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for orbisack constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
*/
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrOrbisack(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Orbisack Constraints
*
* @{
*
* This constraint handler can be used to handle symmetries in certain 0/1-programs. The principle
* structure is that some variables can be ordered in matrix form with two columns, such that
* permuting both columns does not change the validity and objective function value of a solution.
* That is, there exists a permutation symmetry of the program that permutes the variables of the
* first and second column row-wise.
*
* In more mathematical terms the structure has to be as follows: There are 0/1-variables
* \f$x_{ij}\f$, \f$i \in \{1, \dots, n\}\f$, \f$j \in \{1, 2\}\f$. Permuting columns of
* \f$x\f$ does not change the validity and objective function value of any feasible solution.
*/
/** checks whether a given binary solution is feasible for the orbisack */
SCIP_EXPORT
SCIP_RETCODE SCIPcheckSolutionOrbisack(
SCIP* scip, /**< SCIP data structure */
SCIP_SOL* sol, /**< solution to check for feasibility */
SCIP_VAR** vars1, /**< variables of first column */
SCIP_VAR** vars2, /**< variables of second column */
int nrows, /**< number of rows */
SCIP_Bool printreason, /**< whether reason for infeasibility should be printed */
SCIP_Bool* feasible /**< memory address to store whether sol is feasible */
);
/** creates and captures a orbisack constraint
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsOrbisack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR*const* vars1, /**< first column matrix of variables on which the symmetry acts */
SCIP_VAR*const* vars2, /**< second column matrix of variables on which the symmetry acts */
int nrows, /**< number of rows in variable matrix */
SCIP_Bool ispporbisack, /**< whether the orbisack is a packing/partitioning orbisack */
SCIP_Bool isparttype, /**< whether the orbisack is a partitioning orbisack */
SCIP_Bool ismodelcons, /**< whether the orbisack is a model constraint */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures an orbisack constraint in its most basic variant
*
* All constraint flags set to their default values, which can be set afterwards using SCIPsetConsFLAGNAME() in scip.h.
*
* @see SCIPcreateConsOrbisack() for the default constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicOrbisack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR** vars1, /**< first column of matrix of variables on which the symmetry acts */
SCIP_VAR** vars2, /**< second column of matrix of variables on which the symmetry acts */
int nrows, /**< number of rows in constraint matrix */
SCIP_Bool ispporbisack, /**< whether the orbisack is a packing/partitioning orbisack */
SCIP_Bool isparttype, /**< whether the orbisack is a partitioning orbisack */
SCIP_Bool ismodelcons /**< whether the orbisack is a model constraint */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_orbitope.h
* @ingroup CONSHDLRS
* @brief constraint handler for (partitioning/packing/full) orbitope constraints w.r.t. the full symmetric group
* @author Timo Berthold
* @author Marc Pfetsch
* @author Christopher Hojny
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_ORBITOPE_H__
#define __SCIP_CONS_ORBITOPE_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for orbitope constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
*/
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrOrbitope(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Orbitope Constraints
*
* @{
*
* This constraint handler can be used to handle symmetries in certain 0/1-programs. The principle
* structure is that some variables can be ordered in matrix form, such that permuting columns does
* not change the validity and objective function value of a solution. That is, the symmetry group
* of the program contains the full symmetric group obtained by permuting the columns of this
* matrix. These symmetries can be handled by so-called full orbitopes.
*
* Moreover, if the variables in each row are contained in set packing or partitioning
* constraint, these symmetries can be handled by specialized packing or partitioning orbitopes.
*
* In more mathematical terms the structure has to be as follows: There are 0/1-variables
* \f$x_{ij}\f$, \f$i \in \{1, \dots, p\}\f$, \f$j \in \{1, \dots, q\}\f$. The variables may be coupled
* through set packing or partitioning constraints:
* \f[
* \sum_{j = 1}^q x_{ij} \leq 1 \quad \mbox{or} \quad \sum_{j = 1}^q x_{ij} = 1 \quad \mbox{for all }i = 1, \ldots, p.
* \f]
* Permuting columns of \f$x\f$ does not change the validity and objective function value of any feasible solution.
*
* We distinguish whether an orbitope is a model constraint or not. If it is a model constraint, then
* its information are copied to subSCIPs. Otherwise, the constraint was added just for the purpose of
* symmetry handling and we do not copy its information to subSCIPs.
*/
/** type of orbitope constraint: full, packing, or partitioning orbitope */
enum SCIP_OrbitopeType
{
SCIP_ORBITOPETYPE_FULL = 0, /**< constraint is a full orbitope constraint: rowsum(x) unrestricted */
SCIP_ORBITOPETYPE_PARTITIONING = 1, /**< constraint is a partitioning orbitope constraint: rowsum(x) == 1 */
SCIP_ORBITOPETYPE_PACKING = 2 /**< constraint is a packing orbitope constraint: rowsum(x) <= 1 */
};
typedef enum SCIP_OrbitopeType SCIP_ORBITOPETYPE;
/** creates and captures a orbitope constraint
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsOrbitope(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR*** vars, /**< matrix of variables on which the symmetry acts */
SCIP_ORBITOPETYPE orbitopetype, /**< type of orbitope constraint */
int nspcons, /**< number of set partitioning/packing constraints <=> p */
int nblocks, /**< number of symmetric variable blocks <=> q */
SCIP_Bool resolveprop, /**< should propagation be resolved? */
SCIP_Bool ismodelcons, /**< whether the orbitope is a model constraint */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures an orbitope constraint
* in its most basic variant, i. e., with all constraint flags set to their default values, which can be set
* afterwards using SCIPsetConsFLAGNAME() in scip.h
*
* @see SCIPcreateConsOrbitope() for the default constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicOrbitope(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR*** vars, /**< matrix of variables on which the symmetry acts */
SCIP_ORBITOPETYPE orbitopetype, /**< type of orbitope constraint */
int nspcons, /**< number of set partitioning/packing constraints <=> p */
int nblocks, /**< number of symmetric variable blocks <=> q */
SCIP_Bool resolveprop, /**< should propagation be resolved? */
SCIP_Bool ismodelcons /**< whether the orbitope is a model constraint */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_pseudoboolean.h
* @ingroup CONSHDLRS
* @brief constraint handler for pseudoboolean constraints
* @author Stefan Heinz
* @author Michael Winkler
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_PSEUDOBOOLEAN_H__
#define __SCIP_CONS_PSEUDOBOOLEAN_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ARTIFICIALVARNAMEPREFIX "andresultant_"
/** creates the handler for pseudoboolean constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrPseudoboolean(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Pseudoboolean Constraints
*
* @{
*
* The constraint handler deals with pseudo boolean constraints. These are constraints of the form
* \f[
* \mbox{lhs} \leq \sum_{k=0}^m c_k \cdot x_k + \sum_{i=0}^n c_i \cdot \prod_{j \in I_i} x_j \leq \mbox{rhs}
* \f]
* where all \f$x\f$ are binary.
*/
/** solution status after solving LP */
enum SCIP_LinearConsType
{
SCIP_LINEARCONSTYPE_INVALIDCONS = -1, /**< this is no valid linear constraint type */
SCIP_LINEARCONSTYPE_LINEAR = 0, /**< this is the common linear constraint */
SCIP_LINEARCONSTYPE_LOGICOR = 1, /**< this is a logicor constraint */
SCIP_LINEARCONSTYPE_KNAPSACK = 2, /**< this is a knapsack constraint */
#ifndef WITHEQKNAPSACK
SCIP_LINEARCONSTYPE_SETPPC = 3 /**< this is a setppc constraint */
#else
SCIP_LINEARCONSTYPE_SETPPC = 3, /**< this is a setppc constraint */
SCIP_LINEARCONSTYPE_EQKNAPSACK = 4 /**< this is a equality knapsack constraint */
#endif
};
typedef enum SCIP_LinearConsType SCIP_LINEARCONSTYPE;
/** creates and captures a pseudoboolean constraint, with given linear and and-constraints
*
* @note intvar must currently be NULL
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsPseudobooleanWithConss(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_CONS* lincons, /**< associated linear constraint */
SCIP_LINEARCONSTYPE linconstype, /**< linear constraint type of associated linear constraint */
SCIP_CONS** andconss, /**< associated and-constraints */
SCIP_Real* andcoefs, /**< associated coefficients of and-constraints */
int nandconss, /**< number of associated and-constraints */
SCIP_VAR* indvar, /**< indicator variable if it's a soft constraint, or NULL */
SCIP_Real weight, /**< weight of the soft constraint, if it is one */
SCIP_Bool issoftcons, /**< is this a soft constraint */
SCIP_VAR* intvar, /**< an artificial variable which was added only for the objective function,
* if this variable is not NULL this constraint (without this integer
* variable) describes the objective function */
SCIP_Real lhs, /**< left hand side of constraint */
SCIP_Real rhs, /**< right hand side of constraint */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant
* constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant
* constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching
* constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if
* pricing adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which are seperated as
* constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user
* cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent
* node data. */
);
/** creates and captures a pseudoboolean constraint
*
* @note linear and nonlinear terms can be added using SCIPaddCoefPseudoboolean() and SCIPaddTermPseudoboolean(),
* respectively
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*
* @note intvar must currently be NULL
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsPseudoboolean(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR** linvars, /**< variables of the linear part, or NULL */
int nlinvars, /**< number of variables of the linear part */
SCIP_Real* linvals, /**< coefficients of linear part, or NULL */
SCIP_VAR*** terms, /**< nonlinear terms of variables, or NULL */
int nterms, /**< number of terms of variables of nonlinear term */
int* ntermvars, /**< number of variables in nonlinear terms, or NULL */
SCIP_Real* termvals, /**< coefficients of nonlinear parts, or NULL */
SCIP_VAR* indvar, /**< indicator variable if it's a soft constraint, or NULL */
SCIP_Real weight, /**< weight of the soft constraint, if it is one */
SCIP_Bool issoftcons, /**< is this a soft constraint */
SCIP_VAR* intvar, /**< an artificial variable which was added only for the objective function,
* if this variable is not NULL this constraint (without this integer
* variable) describes the objective function */
SCIP_Real lhs, /**< left hand side of constraint */
SCIP_Real rhs, /**< right hand side of constraint */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a pseudoboolean constraint
* in its most basic variant, i. e., with all constraint flags set to their default values, which can be set
* afterwards using SCIPsetConsFLAGNAME() in scip.h
*
* @see SCIPcreateConsPseudoboolean() for the default constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*
* @note intvar must currently be NULL
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicPseudoboolean(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR** linvars, /**< variables of the linear part, or NULL */
int nlinvars, /**< number of variables of the linear part */
SCIP_Real* linvals, /**< coefficients of linear part, or NULL */
SCIP_VAR*** terms, /**< nonlinear terms of variables, or NULL */
int nterms, /**< number of terms of variables of nonlinear term */
int* ntermvars, /**< number of variables in nonlinear terms, or NULL */
SCIP_Real* termvals, /**< coefficients of nonlinear parts, or NULL */
SCIP_VAR* indvar, /**< indicator variable if it's a soft constraint, or NULL */
SCIP_Real weight, /**< weight of the soft constraint, if it is one */
SCIP_Bool issoftcons, /**< is this a soft constraint */
SCIP_VAR* intvar, /**< a artificial variable which was added only for the objective function,
* if this variable is not NULL this constraint (without this integer
* variable) describes the objective function */
SCIP_Real lhs, /**< left hand side of constraint */
SCIP_Real rhs /**< right hand side of constraint */
);
/** adds linear term pseudo boolean constraint (if it is not zero)
*
* @note you can only add a coefficient if the special type of linear constraint won't changed
*
* @todo if adding a coefficient would change the type of the special linear constraint, we need to erase it and
* create a new linear constraint
*/
SCIP_EXPORT
SCIP_RETCODE SCIPaddCoefPseudoboolean(
SCIP*const scip, /**< SCIP data structure */
SCIP_CONS*const cons, /**< pseudoboolean constraint */
SCIP_VAR* const var, /**< variable of constraint entry */
SCIP_Real const val /**< coefficient of constraint entry */
);
/** adds nonlinear term to pseudo boolean constraint (if it is not zero)
*
* @note you can only add a coefficient if the special type of linear constraint won't changed
*
* @todo if adding a coefficient would change the type of the special linear constraint, we need to erase it and
* create a new linear constraint
*/
SCIP_EXPORT
SCIP_RETCODE SCIPaddTermPseudoboolean(
SCIP*const scip, /**< SCIP data structure */
SCIP_CONS*const cons, /**< pseudoboolean constraint */
SCIP_VAR**const vars, /**< variables of the nonlinear term */
int const nvars, /**< number of variables of the nonlinear term */
SCIP_Real const val /**< coefficient of constraint entry */
);
/** gets indicator variable of pseudoboolean constraint, or NULL if there is no */
SCIP_EXPORT
SCIP_VAR* SCIPgetIndVarPseudoboolean(
SCIP*const scip, /**< SCIP data structure */
SCIP_CONS*const cons /**< pseudoboolean constraint */
);
/** gets linear constraint of pseudoboolean constraint */
SCIP_EXPORT
SCIP_CONS* SCIPgetLinearConsPseudoboolean(
SCIP*const scip, /**< SCIP data structure */
SCIP_CONS*const cons /**< pseudoboolean constraint */
);
/** gets type of linear constraint of pseudoboolean constraint */
SCIP_EXPORT
SCIP_LINEARCONSTYPE SCIPgetLinearConsTypePseudoboolean(
SCIP*const scip, /**< SCIP data structure */
SCIP_CONS*const cons /**< pseudoboolean constraint */
);
/** gets number of linear variables without artificial terms variables of pseudoboolean constraint */
SCIP_EXPORT
int SCIPgetNLinVarsWithoutAndPseudoboolean(
SCIP*const scip, /**< SCIP data structure */
SCIP_CONS*const cons /**< pseudoboolean constraint */
);
/** gets linear constraint of pseudoboolean constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPgetLinDatasWithoutAndPseudoboolean(
SCIP*const scip, /**< SCIP data structure */
SCIP_CONS*const cons, /**< pseudoboolean constraint */
SCIP_VAR**const linvars, /**< array to store and-constraints */
SCIP_Real*const lincoefs, /**< array to store and-coefficients */
int*const nlinvars /**< pointer to store the required array size for and-constraints, have to
* be initialized with size of given array */
);
/** gets and-constraints of pseudoboolean constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPgetAndDatasPseudoboolean(
SCIP*const scip, /**< SCIP data structure */
SCIP_CONS*const cons, /**< pseudoboolean constraint */
SCIP_CONS**const andconss, /**< array to store and-constraints */
SCIP_Real*const andcoefs, /**< array to store and-coefficients */
int*const nandconss /**< pointer to store the required array size for and-constraints, have to
* be initialized with size of given array */
);
/** gets number of and constraints of pseudoboolean constraint */
SCIP_EXPORT
int SCIPgetNAndsPseudoboolean(
SCIP*const scip, /**< SCIP data structure */
SCIP_CONS*const cons /**< pseudoboolean constraint */
);
/** changes left hand side of pseudoboolean constraint
*
* @note you can only change the left hand side if the special type of linear constraint won't changed
*
* @todo if changing the left hand side would change the type of the special linear constraint, we need to erase it
* and create a new linear constraint
*/
SCIP_EXPORT
SCIP_RETCODE SCIPchgLhsPseudoboolean(
SCIP*const scip, /**< SCIP data structure */
SCIP_CONS*const cons, /**< pseudoboolean constraint */
SCIP_Real const lhs /**< new left hand side */
);
/** changes right hand side of pseudoboolean constraint
*
* @note you can only change the right hand side if the special type of linear constraint won't changed
*
* @todo if changing the right hand side would change the type of the special linear constraint, we need to erase it
* and create a new linear constraint
*/
SCIP_EXPORT
SCIP_RETCODE SCIPchgRhsPseudoboolean(
SCIP*const scip, /**< SCIP data structure */
SCIP_CONS*const cons, /**< pseudoboolean constraint */
SCIP_Real const rhs /**< new right hand side */
);
/** get left hand side of pseudoboolean constraint */
SCIP_EXPORT
SCIP_Real SCIPgetLhsPseudoboolean(
SCIP*const scip, /**< SCIP data structure */
SCIP_CONS*const cons /**< pseudoboolean constraint */
);
/** get right hand side of pseudoboolean constraint */
SCIP_EXPORT
SCIP_Real SCIPgetRhsPseudoboolean(
SCIP*const scip, /**< SCIP data structure */
SCIP_CONS*const cons /**< pseudoboolean constraint */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_quadratic.h
* @ingroup CONSHDLRS
* @brief constraint handler for quadratic constraints \f$\textrm{lhs} \leq \sum_{i,j=1}^n a_{i,j} x_ix_j + \sum_{i=1}^n b_i x_i \leq \textrm{rhs}\f$
* @author Stefan Vigerske
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_QUADRATIC_H__
#define __SCIP_CONS_QUADRATIC_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_lp.h"
#include "scip/type_misc.h"
#include "scip/type_nlp.h"
#include "nlpi/type_nlpi.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_sepa.h"
#include "scip/type_sol.h"
#include "scip/type_timing.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for quadratic constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrQuadratic(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Quadratic Constraints
*
* @{
*
* This constraint handler handles constraints of the form
* \f[
* \textrm{lhs} \leq \sum_{i,j=1}^n a_{i,j} x_ix_j + \sum_{i=1}^n b_i x_i \leq \textrm{rhs}
* \f]
*
* Constraints are enforced by separation, domain propagation, and spatial branching.
*
* For semidefinite matrices \f$A=(a_{i,j})_{i,j}\f$, cuts based on linearization of \f$\langle x, Ax\rangle\f$ are implemented.
* For underestimating a non-convex term, McCormick underestimators and secants for univariate concave quadratic terms are implemented.
* If \f$\langle x, Ax\rangle\f$ is factorable (i.e., can be written as product of two linear functions),
* specialized separation techniques (e.g., lifted tangent inequalities) that take the constraint sides into account are applied.
*
* Branching is performed for variables in nonconvex terms, if the relaxation solution cannot be separated.
* Further, domain propagation is applied.
*
* During presolve, variable products which contain binary variables may be reformulated into linear constraints, thereby introducing new variables.
*
* See also
* @par
* Timo Berthold and Stefan Heinz and Stefan Vigerske@n
* <a href="http://dx.doi.org/10.1007/978-1-4614-1927-3">Extending a CIP framework to solve MIQCPs</a>@n
* In: Jon Lee and Sven Leyffer (eds.),
* Mixed-integer nonlinear optimization: Algorithmic advances and applications,
* IMA volumes in Mathematics and its Applications, volume 154, 427-444, 2012.
*
* @par
* Stefan Vigerske@n
* Decomposition of Multistage Stochastic Programs and a Constraint Integer Programming Approach to Mixed-Integer Nonlinear Programming@n
* PhD Thesis, Humboldt-University Berlin, 2012, submitted.
*
* @par
* Pietro Belotti and Andrew J. Miller and Mahdi Namazifar@n
* Linear inequalities for bounded products of variables@n
* SIAG/OPT Views-and-News 22:1, 1-8, 2011.
*/
/** event data for variable bound changes in quadratic constraints */
typedef struct SCIP_QuadVarEventData SCIP_QUADVAREVENTDATA;
/** data structure to store a single term associated to a quadratic variable
*/
struct SCIP_QuadVarTerm
{
SCIP_VAR* var; /**< quadratic variable */
SCIP_Real lincoef; /**< linear coefficient of variable */
SCIP_Real sqrcoef; /**< square coefficient of variable */
int nadjbilin; /**< number of bilinear terms this variable is involved in */
int adjbilinsize; /**< size of adjacent bilinear terms array */
int* adjbilin; /**< indices of associated bilinear terms */
SCIP_QUADVAREVENTDATA* eventdata; /**< event data for bound change events */
};
typedef struct SCIP_QuadVarTerm SCIP_QUADVARTERM;
/** data structure to store a single bilinear term (similar to SCIP_QUADELEM)
* except for temporary reasons, we assume that the index of var1 is smaller than the index of var2
*/
struct SCIP_BilinTerm
{
SCIP_VAR* var1;
SCIP_VAR* var2;
SCIP_Real coef;
};
typedef struct SCIP_BilinTerm SCIP_BILINTERM;
/** storage for a linear row in preparation
*
* Uses to assemble data that could eventually make a SCIP_ROW.
* @note Only one-sided rows are allowed here.
*/
struct SCIP_RowPrep
{
SCIP_VAR** vars; /**< variables */
SCIP_Real* coefs; /**< coefficients of variables */
int nvars; /**< number of variables (= number of coefficients) */
int varssize; /**< length of variables array (= lengths of coefficients array) */
SCIP_Real side; /**< side */
SCIP_SIDETYPE sidetype; /**< type of side */
SCIP_Bool local; /**< whether the row is only locally valid (i.e., for the current node) */
char name[SCIP_MAXSTRLEN]; /**< row name */
};
typedef struct SCIP_RowPrep SCIP_ROWPREP;
/** upgrading method for quadratic constraints into more specific constraints
*
* the method might upgrade a quadratic constraint into a set of quadratic constraints
* the caller provided an array upgdconss to store upgrade constraints
* the length of upgdconss is given by upgdconsssize
* if an upgrade is not possible, set *nupgdconss to zero
* if more than upgdconsssize many constraints shall replace cons, the function
* should return the required number as negated value in *nupgdconss
* i.e., if cons should be replaced by 3 constraints, the function should set
* *nupgdconss to -3 and return with SCIP_OKAY
*
* input:
* - scip : SCIP main data structure
* - cons : the quadratic constraint to upgrade
* - nbinlin : number of binary variables in linear part
* - nbinquad : number of binary variables in quadratic part
* - nintlin : number of integer variables in linear part
* - nintquad : number of integer variables in quadratic part
* - nimpllin : number of implicit integer variables in linear part
* - nimplquad : number of implicit integer variables in quadratic part
* - ncontlin : number of continuous variables in linear part
* - ncontquad : number of continuous variables in quadratic part
* - integral : TRUE iff constraints activity value is always integral
* - nupgdconss : pointer to store number of constraints that replace this constraint
* - upgdconss : array to store constraints that replace this constraint
* - upgdconsssize : length of the provided upgdconss array
* - presoltiming : current presolve timing
*/
#define SCIP_DECL_QUADCONSUPGD(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONS* cons, \
int nbinlin, int nbinquad, int nintlin, int nintquad, int nimpllin, int nimplquad, int ncontlin, int ncontquad, \
SCIP_Bool integral, int* nupgdconss, SCIP_CONS** upgdconss, int upgdconsssize, SCIP_PRESOLTIMING presoltiming)
/** includes a quadratic constraint upgrade method into the quadratic constraint handler */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeQuadconsUpgrade(
SCIP* scip, /**< SCIP data structure */
SCIP_DECL_QUADCONSUPGD((*quadconsupgd)), /**< method to call for upgrading quadratic constraint */
int priority, /**< priority of upgrading method */
SCIP_Bool active, /**< should the upgrading method be active by default? */
const char* conshdlrname /**< name of the constraint handler */
);
/** Creates and captures a quadratic constraint.
*
* The constraint should be given in the form
* \f[
* \ell \leq \sum_{i=1}^n b_i x_i + \sum_{j=1}^m a_j y_j z_j \leq u,
* \f]
* where \f$x_i = y_j = z_k\f$ is possible.
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nlinvars, /**< number of linear terms (n) */
SCIP_VAR** linvars, /**< variables in linear part (x_i) or NULL if nlinvars == 0 */
SCIP_Real* lincoefs, /**< coefficients of variables in linear part (b_i) or NULL if nlinvars == 0 */
int nquadterms, /**< number of quadratic terms (m) */
SCIP_VAR** quadvars1, /**< array with first variables in quadratic terms (y_j) or NULL if nquadterms == 0 */
SCIP_VAR** quadvars2, /**< array with second variables in quadratic terms (z_j) or NULL if nquadterms == 0 */
SCIP_Real* quadcoeffs, /**< array with coefficients of quadratic terms (a_j) or NULL if nquadterms == 0 */
SCIP_Real lhs, /**< left hand side of quadratic equation (l) */
SCIP_Real rhs, /**< right hand side of quadratic equation (u) */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
);
/** creates and captures a quadratic constraint
* in its most basic variant, i. e., with all constraint flags set to their default values, which can be set
* afterwards using SCIPsetConsFLAGNAME() in scip.h
*
* The constraint should be given in the form
* \f[
* \ell \leq \sum_{i=1}^n b_i x_i + \sum_{j=1}^m a_j y_jz_j \leq u,
* \f]
* where \f$x_i = y_j = z_k\f$ is possible.
*
* @see SCIPcreateConsQuadratic() for the default constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nlinvars, /**< number of linear terms (n) */
SCIP_VAR** linvars, /**< array with variables in linear part (x_i) */
SCIP_Real* lincoefs, /**< array with coefficients of variables in linear part (b_i) */
int nquadterms, /**< number of quadratic terms (m) */
SCIP_VAR** quadvars1, /**< array with first variables in quadratic terms (y_j) */
SCIP_VAR** quadvars2, /**< array with second variables in quadratic terms (z_j) */
SCIP_Real* quadcoefs, /**< array with coefficients of quadratic terms (a_j) */
SCIP_Real lhs, /**< left hand side of quadratic equation (ell) */
SCIP_Real rhs /**< right hand side of quadratic equation (u) */
);
/** creates and captures a quadratic constraint.
*
* The constraint should be given in the form
* \f[
* \ell \leq \sum_{i=1}^n b_i x_i + \sum_{j=1}^m (a_j y_j^2 + b_j y_j) + \sum_{k=1}^p c_k v_k w_k \leq u.
* \f]
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsQuadratic2(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nlinvars, /**< number of linear terms (n) */
SCIP_VAR** linvars, /**< array with variables in linear part (x_i) */
SCIP_Real* lincoefs, /**< array with coefficients of variables in linear part (b_i) */
int nquadvarterms, /**< number of quadratic terms (m) */
SCIP_QUADVARTERM* quadvarterms, /**< quadratic variable terms */
int nbilinterms, /**< number of bilinear terms (p) */
SCIP_BILINTERM* bilinterms, /**< bilinear terms */
SCIP_Real lhs, /**< constraint left hand side (ell) */
SCIP_Real rhs, /**< constraint right hand side (u) */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP? */
SCIP_Bool separate, /**< should the constraint be separated during LP processing? */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing? */
SCIP_Bool check, /**< should the constraint be checked for feasibility? */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing? */
SCIP_Bool local, /**< is constraint only valid locally? */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)? */
SCIP_Bool dynamic, /**< is constraint dynamic? */
SCIP_Bool removable /**< should the constraint be removed from the LP due to aging or cleanup? */
);
/** creates and captures a quadratic constraint
* in its most basic variant, i. e., with all constraint flags set to their default values, which can be set
* afterwards using SCIPsetConsFLAGNAME() in scip.h
*
* The constraint should be given in the form
* \f[
* \ell \leq \sum_{i=1}^n b_i x_i + \sum_{j=1}^m (a_j y_j^2 + b_j y_j) + \sum_{k=1}^p c_kv_kw_k \leq u.
* \f]
*
* @see SCIPcreateConsQuadratic2() for the default constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicQuadratic2(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nlinvars, /**< number of linear terms (n) */
SCIP_VAR** linvars, /**< array with variables in linear part (x_i) */
SCIP_Real* lincoefs, /**< array with coefficients of variables in linear part (b_i) */
int nquadvarterms, /**< number of quadratic terms (m) */
SCIP_QUADVARTERM* quadvarterms, /**< quadratic variable terms */
int nbilinterms, /**< number of bilinear terms (p) */
SCIP_BILINTERM* bilinterms, /**< bilinear terms */
SCIP_Real lhs, /**< constraint left hand side (ell) */
SCIP_Real rhs /**< constraint right hand side (u) */
);
/** Adds a constant to the constraint function, that is, subtracts a constant from both sides */
SCIP_EXPORT
void SCIPaddConstantQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_Real constant /**< constant to subtract from both sides */
);
/** Adds a linear variable with coefficient to a quadratic constraint.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPaddLinearVarQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_VAR* var, /**< variable */
SCIP_Real coef /**< coefficient of variable */
);
/** Adds a quadratic variable with linear and square coefficient to a quadratic constraint.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPaddQuadVarQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_VAR* var, /**< variable */
SCIP_Real lincoef, /**< linear coefficient of variable */
SCIP_Real sqrcoef /**< square coefficient of variable */
);
/** Adds a linear coefficient for a quadratic variable.
*
* Variable will be added with square coefficient 0.0 if not existing yet.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPaddQuadVarLinearCoefQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_VAR* var, /**< variable */
SCIP_Real coef /**< value to add to linear coefficient of variable */
);
/** Adds a square coefficient for a quadratic variable.
*
* Variable will be added with linear coefficient 0.0 if not existing yet.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPaddSquareCoefQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_VAR* var, /**< variable */
SCIP_Real coef /**< value to add to square coefficient of variable */
);
/** Adds a bilinear term to a quadratic constraint.
*
* Variables will be added with linear and square coefficient 0.0 if not existing yet.
* If variables are equal, only the square coefficient of the variable is updated.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPaddBilinTermQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_VAR* var1, /**< first variable */
SCIP_VAR* var2, /**< second variable */
SCIP_Real coef /**< coefficient of bilinear term */
);
/** Gets the quadratic constraint as a nonlinear row representation.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPgetNlRowQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_NLROW** nlrow /**< pointer to store nonlinear row */
);
/** Gets the number of variables in the linear part of a quadratic constraint.
*/
SCIP_EXPORT
int SCIPgetNLinearVarsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** Gets the variables in the linear part of a quadratic constraint.
* Length is given by SCIPgetNLinearVarsQuadratic.
*/
SCIP_EXPORT
SCIP_VAR** SCIPgetLinearVarsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** Gets the coefficients in the linear part of a quadratic constraint.
* Length is given by SCIPgetNLinearVarsQuadratic.
*/
SCIP_EXPORT
SCIP_Real* SCIPgetCoefsLinearVarsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** Gets the number of quadratic variable terms of a quadratic constraint.
*/
SCIP_EXPORT
int SCIPgetNQuadVarTermsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** Gets the quadratic variable terms of a quadratic constraint.
* Length is given by SCIPgetNQuadVarTermsQuadratic.
*/
SCIP_EXPORT
SCIP_QUADVARTERM* SCIPgetQuadVarTermsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** Ensures that quadratic variable terms are sorted. */
SCIP_EXPORT
SCIP_RETCODE SCIPsortQuadVarTermsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** Finds the position of a quadratic variable term for a given variable.
*
* @note If the quadratic variable terms have not been sorted before, then a search may reorder the current order of the terms.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPfindQuadVarTermQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_VAR* var, /**< variable to search for */
int* pos /**< buffer to store position of quadvarterm for var, or -1 if not found */
);
/** Gets the number of bilinear terms of a quadratic constraint.
*/
SCIP_EXPORT
int SCIPgetNBilinTermsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** Gets the bilinear terms of a quadratic constraint.
* Length is given by SCIPgetNBilinTermQuadratic.
*/
SCIP_EXPORT
SCIP_BILINTERM* SCIPgetBilinTermsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** Gets the left hand side of a quadratic constraint.
*/
SCIP_EXPORT
SCIP_Real SCIPgetLhsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** Gets the right hand side of a quadratic constraint.
*/
SCIP_EXPORT
SCIP_Real SCIPgetRhsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** get index of a variable in linvars that may be decreased without making any other constraint infeasible, or -1 if none */
SCIP_EXPORT
int SCIPgetLinvarMayDecreaseQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** get index of a variable in linvars that may be increased without making any other constraint infeasible, or -1 if none */
SCIP_EXPORT
int SCIPgetLinvarMayIncreaseQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** Check the quadratic function of a quadratic constraint for its semi-definiteness, if not done yet.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcheckCurvatureQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** Indicates whether the quadratic function of a quadratic constraint is (known to be) convex.
*/
SCIP_EXPORT
SCIP_Bool SCIPisConvexQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** Indicates whether the quadratic function of a quadratic constraint is (known to be) concave.
*/
SCIP_EXPORT
SCIP_Bool SCIPisConcaveQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** Checks and indicates whether the quadratic constraint is convex. */
SCIP_EXPORT
SCIP_RETCODE SCIPisConvexConsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_HASHMAP* assumevarfixed, /**< hashmap containing variables that should be assumed to be fixed, or NULL */
SCIP_Bool* result /**< buffer where to store whether constraint is convex (under given variable fixing) */
);
/** Gets the violation of a constraint by a solution. */
SCIP_EXPORT
SCIP_RETCODE SCIPgetViolationQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_SOL* sol, /**< solution which violation to calculate, or NULL for LP solution */
SCIP_Real* violation /**< pointer to store violation of constraint */
);
/** Indicates whether the quadratic constraint is local w.r.t. the current local bounds.
*
* That is, checks whether each variable with a square term is fixed and for each bilinear term at least one variable is fixed.
*/
SCIP_EXPORT
SCIP_Bool SCIPisLinearLocalQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** Adds the constraint to an NLPI problem. */
SCIP_EXPORT
SCIP_RETCODE SCIPaddToNlpiProblemQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_NLPI* nlpi, /**< interface to NLP solver */
SCIP_NLPIPROBLEM* nlpiprob, /**< NLPI problem where to add constraint */
SCIP_HASHMAP* scipvar2nlpivar, /**< mapping from SCIP variables to variable indices in NLPI */
SCIP_Bool names /**< whether to pass constraint names to NLPI */
);
/** sets the left hand side of a quadratic constraint
*
* @note This method may only be called during problem creation stage for an original constraint.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPchgLhsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_Real lhs /**< new left hand side */
);
/** sets the right hand side of a quadratic constraint
*
* @note This method may only be called during problem creation stage for an original constraint.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPchgRhsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_Real rhs /**< new right hand side */
);
SCIP_EXPORT
/** gets the feasibility of the quadratic constraint in the given solution */
SCIP_RETCODE SCIPgetFeasibilityQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_SOL* sol, /**< solution, or NULL to use current node's solution */
SCIP_Real* feasibility /**< pointer to store the feasibility */
);
/** gets the activity of the quadratic constraint in the given solution */
SCIP_EXPORT
SCIP_RETCODE SCIPgetActivityQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_SOL* sol, /**< solution, or NULL to use current node's solution */
SCIP_Real* activity /**< pointer to store the activity */
);
/** changes the linear coefficient value for a given quadratic variable in a quadratic constraint data; if not
* available, it adds it
*
* @note this is only allowed for original constraints and variables in problem creation stage
*/
SCIP_EXPORT
SCIP_RETCODE SCIPchgLinearCoefQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_VAR* var, /**< quadratic variable */
SCIP_Real coef /**< new coefficient */
);
/** changes the square coefficient value for a given quadratic variable in a quadratic constraint data; if not
* available, it adds it
*
* @note this is only allowed for original constraints and variables in problem creation stage
*/
SCIP_EXPORT
SCIP_RETCODE SCIPchgSquareCoefQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_VAR* var, /**< quadratic variable */
SCIP_Real coef /**< new coefficient */
);
/** changes the bilinear coefficient value for a given quadratic variable in a quadratic constraint data; if not
* available, it adds it
*
* @note this is only allowed for original constraints and variables in problem creation stage
*/
SCIP_EXPORT
SCIP_RETCODE SCIPchgBilinCoefQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_VAR* var1, /**< first quadratic variable */
SCIP_VAR* var2, /**< second quadratic variable */
SCIP_Real coef /**< coefficient of bilinear term */
);
/** returns the total number of bilinear terms that are contained in all quadratic constraints */
SCIP_EXPORT
int SCIPgetNAllBilinearTermsQuadratic(
SCIP* scip /**< SCIP data structure */
);
/** returns all bilinear terms that are contained in all quadratic constraints */
SCIP_EXPORT
SCIP_RETCODE SCIPgetAllBilinearTermsQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_VAR** RESTRICT x, /**< array to store first variable of each bilinear term */
SCIP_VAR** RESTRICT y, /**< array to second variable of each bilinear term */
int* RESTRICT nbilinterms, /**< buffer to store the total number of bilinear terms */
int* RESTRICT nunderests, /**< array to store the total number of constraints that require to underestimate a bilinear term */
int* RESTRICT noverests, /**< array to store the total number of constraints that require to overestimate a bilinear term */
SCIP_Real* maxnonconvexity /**< estimate of nonconvex eigenvalues of all quadratic constraints containing a bilinear term */
);
/** adds a globally valid inequality of the form xcoef x <= ycoef y + constant for a bilinear term (x,y)
*
* @note the indices of bilinear terms match with the entries of bilinear terms returned by SCIPgetAllBilinearTermsQuadratic
*/
SCIP_EXPORT
SCIP_RETCODE SCIPaddBilinearIneqQuadratic(
SCIP* scip, /**< SCIP data structure */
SCIP_VAR* x, /**< first variable */
SCIP_VAR* y, /**< second variable */
int idx, /**< index of the bilinear term */
SCIP_Real xcoef, /**< x coefficient */
SCIP_Real ycoef, /**< y coefficient */
SCIP_Real constant, /**< constant part */
SCIP_Bool* success /**< buffer to store whether inequality has been accepted */
);
/** @} */
#ifdef SCIP_PRIVATE_ROWPREP
/** creates a SCIP_ROWPREP datastructure
*
* Initial row represents 0 <= 0.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateRowprep(
SCIP* scip, /**< SCIP data structure */
SCIP_ROWPREP** rowprep, /**< buffer to store pointer to rowprep */
SCIP_SIDETYPE sidetype, /**< whether cut will be or lower-equal or larger-equal type */
SCIP_Bool local /**< whether cut will be valid only locally */
);
/** frees a SCIP_ROWPREP datastructure */
SCIP_EXPORT
void SCIPfreeRowprep(
SCIP* scip, /**< SCIP data structure */
SCIP_ROWPREP** rowprep /**< pointer that stores pointer to rowprep */
);
/** creates a copy of a SCIP_ROWPREP datastructure */
SCIP_EXPORT
SCIP_RETCODE SCIPcopyRowprep(
SCIP* scip, /**< SCIP data structure */
SCIP_ROWPREP** target, /**< buffer to store pointer of rowprep copy */
SCIP_ROWPREP* source /**< rowprep to copy */
);
/** ensures that rowprep has space for at least given number of additional terms
*
* Useful when knowing in advance how many terms will be added.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPensureRowprepSize(
SCIP* scip, /**< SCIP data structure */
SCIP_ROWPREP* rowprep, /**< rowprep */
int size /**< number of additional terms for which to alloc space in rowprep */
);
/** prints a rowprep */
SCIP_EXPORT
void SCIPprintRowprep(
SCIP* scip, /**< SCIP data structure */
SCIP_ROWPREP* rowprep, /**< rowprep to be printed */
FILE* file /**< file to print to, or NULL for stdout */
);
/** adds a term coef*var to a rowprep */
SCIP_EXPORT
SCIP_RETCODE SCIPaddRowprepTerm(
SCIP* scip, /**< SCIP data structure */
SCIP_ROWPREP* rowprep, /**< rowprep */
SCIP_VAR* var, /**< variable to add */
SCIP_Real coef /**< coefficient to add */
);
/** adds several terms coef*var to a rowprep */
SCIP_EXPORT
SCIP_RETCODE SCIPaddRowprepTerms(
SCIP* scip, /**< SCIP data structure */
SCIP_ROWPREP* rowprep, /**< rowprep */
int nvars, /**< number of terms to add */
SCIP_VAR** vars, /**< variables to add */
SCIP_Real* coefs /**< coefficients to add */
);
/** adds constant value to side of rowprep */
SCIP_EXPORT
void SCIPaddRowprepSide(
SCIP_ROWPREP* rowprep, /**< rowprep */
SCIP_Real side /**< constant value to be added to side */
);
/** adds constant term to rowprep
*
* Substracts constant from side.
*/
SCIP_EXPORT
void SCIPaddRowprepConstant(
SCIP_ROWPREP* rowprep, /**< rowprep */
SCIP_Real constant /**< constant value to be added */
);
#ifdef NDEBUG
#define SCIPaddRowprepSide(rowprep, sideadd) ((rowprep)->side += (sideadd))
#define SCIPaddRowprepConstant(rowprep, constant) SCIPaddRowprepSide(rowprep, -(constant))
#endif
/** computes violation of cut in a given solution */
SCIP_EXPORT
SCIP_Real SCIPgetRowprepViolation(
SCIP* scip, /**< SCIP data structure */
SCIP_ROWPREP* rowprep, /**< rowprep to be turned into a row */
SCIP_SOL* sol /**< solution or NULL for LP solution */
);
/** Merge terms that use same variable and eliminate zero coefficients.
*
* Terms are sorted by variable (@see SCIPvarComp) after return.
*/
SCIP_EXPORT
void SCIPmergeRowprepTerms(
SCIP* scip, /**< SCIP data structure */
SCIP_ROWPREP* rowprep /**< rowprep to be cleaned up */
);
/* Cleans up and attempts to improve rowprep
*
* Drops small or large coefficients if coefrange is too large, if this can be done by relaxing the cut.
* Scales coefficients up to reach minimal violation, if possible.
* Scaling is omitted if violation is very small (ROWPREP_SCALEUP_VIOLNONZERO) or
* maximal coefficient would become huge (ROWPREP_SCALEUP_MAXMAXCOEF).
* Scales coefficients and side down if they are large and if the minimal violation is still reached.
* Rounds coefficients close to integral values to integrals, if this can be done by relaxing the cut.
* Rounds side within epsilon of 0 to 0.0 or +/-1.1*epsilon, whichever relaxes the cut least.
*
* After return, the terms in the rowprep will be sorted by absolute value of coefficient, in decreasing order.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcleanupRowprep(
SCIP* scip, /**< SCIP data structure */
SCIP_ROWPREP* rowprep, /**< rowprep to be cleaned */
SCIP_SOL* sol, /**< solution that we try to cut off, or NULL for LP solution */
SCIP_Real maxcoefrange, /**< maximal allowed coefficients range */
SCIP_Real minviol, /**< minimal absolute violation the row should achieve (w.r.t. sol) */
SCIP_Real* coefrange, /**< buffer to store coefrange of cleaned up cut, or NULL if not of interest */
SCIP_Real* viol /**< buffer to store absolute violation of cleaned up cut in sol, or NULL if not of interest */
);
/** scales a rowprep
*
* @return Exponent of actually applied scaling factor, if written as 2^x.
*/
SCIP_EXPORT
int SCIPscaleRowprep(
SCIP_ROWPREP* rowprep, /**< rowprep to be scaled */
SCIP_Real factor /**< suggested scale factor */
);
/** generates a SCIP_ROW from a rowprep */
SCIP_EXPORT
SCIP_RETCODE SCIPgetRowprepRowConshdlr(
SCIP* scip, /**< SCIP data structure */
SCIP_ROW** row, /**< buffer to store pointer to new row */
SCIP_ROWPREP* rowprep, /**< rowprep to be turned into a row */
SCIP_CONSHDLR* conshdlr /**< constraint handler */
);
/** generates a SCIP_ROW from a rowprep */
SCIP_EXPORT
SCIP_RETCODE SCIPgetRowprepRowCons(
SCIP* scip, /**< SCIP data structure */
SCIP_ROW** row, /**< buffer to store pointer to new row */
SCIP_ROWPREP* rowprep, /**< rowprep to be turned into a row */
SCIP_CONS* cons /**< constraint */
);
/** generates a SCIP_ROW from a rowprep */
SCIP_EXPORT
SCIP_RETCODE SCIPgetRowprepRowSepa(
SCIP* scip, /**< SCIP data structure */
SCIP_ROW** row, /**< buffer to store pointer to new row */
SCIP_ROWPREP* rowprep, /**< rowprep to be turned into a row */
SCIP_SEPA* sepa /**< separator */
);
#endif
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_setppc.h
* @ingroup CONSHDLRS
* @brief Constraint handler for the set partitioning / packing / covering constraints \f$1^T x\ \{=, \le, \ge\}\ 1\f$.
* @author Tobias Achterberg
* @author Michael Winkler
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_SETPPC_H__
#define __SCIP_CONS_SETPPC_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_lp.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for set partitioning / packing / covering constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrSetppc(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Set Packing/Partitioning/Covering Constraints
*
* @{
*
* This constraint handler handles three special classes of linear constraints, namely
* set partitioning, set packing, and set covering constraints.
* For a set of binary variables \f$x_i, i=1,\dots,n\f$, a set partitioning constraint has the form
* \f[
* \sum_{i=1}^n x_i = 1,
* \f]
* a set packing constraint has the form
* \f[
* \sum_{i=1}^n x_i \le 1,
* \f]
* and a set covering constraint has the form
* \f[
* \sum_{i=1}^n x_i \ge 1.
* \f]
*/
/** type of setppc constraint: set partitioning, set packing, or set covering */
enum SCIP_SetppcType
{
SCIP_SETPPCTYPE_PARTITIONING = 0, /**< constraint is a set partitioning constraint: sum(x) == 1 */
SCIP_SETPPCTYPE_PACKING = 1, /**< constraint is a set packing constraint: sum(x) <= 1 */
SCIP_SETPPCTYPE_COVERING = 2 /**< constraint is a set covering constraint: sum(x) >= 1 */
};
typedef enum SCIP_SetppcType SCIP_SETPPCTYPE;
/** creates and captures a set partitioning constraint
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsSetpart(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of variables in the constraint */
SCIP_VAR** vars, /**< array with variables of constraint entries */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a set partitioning constraint
* in its most basic variant, i. e., with all constraint flags set to their default values, which can be set
* afterwards using SCIPsetConsFLAGNAME() in scip.h
*
* @see SCIPcreateConsSetpart() for the default constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicSetpart(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of variables in the constraint */
SCIP_VAR** vars /**< array with variables of constraint entries */
);
/** creates and captures a set packing constraint
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsSetpack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of variables in the constraint */
SCIP_VAR** vars, /**< array with variables of constraint entries */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a set packing constraint
* in its most basic variant, i. e., with all constraint flags set to their default values, which can be set
* afterwards using SCIPsetConsFLAGNAME() in scip.h
*
* @see SCIPcreateConsSetpack() for the default constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicSetpack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of variables in the constraint */
SCIP_VAR** vars /**< array with variables of constraint entries */
);
/** creates and captures a set covering constraint
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsSetcover(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of variables in the constraint */
SCIP_VAR** vars, /**< array with variables of constraint entries */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a set packing constraint
* in its most basic variant, i. e., with all constraint flags set to their default values, which can be set
* afterwards using SCIPsetConsFLAGNAME() in scip.h
*
* @see SCIPcreateConsSetpack() for the default constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicSetcover(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of variables in the constraint */
SCIP_VAR** vars /**< array with variables of constraint entries */
);
/** adds coefficient in set partitioning / packing / covering constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPaddCoefSetppc(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint data */
SCIP_VAR* var /**< variable to add to the constraint */
);
/** gets number of variables in set partitioning / packing / covering constraint */
SCIP_EXPORT
int SCIPgetNVarsSetppc(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets array of variables in set partitioning / packing / covering constraint */
SCIP_EXPORT
SCIP_VAR** SCIPgetVarsSetppc(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets type of set partitioning / packing / covering constraint */
SCIP_EXPORT
SCIP_SETPPCTYPE SCIPgetTypeSetppc(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the dual solution of the set partitioning / packing / covering constraint in the current LP */
SCIP_EXPORT
SCIP_Real SCIPgetDualsolSetppc(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the dual Farkas value of the set partitioning / packing / covering constraint in the current infeasible LP */
SCIP_EXPORT
SCIP_Real SCIPgetDualfarkasSetppc(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** returns the linear relaxation of the given set partitioning / packing / covering constraint; may return NULL if no
* LP row was yet created; the user must not modify the row!
*/
SCIP_EXPORT
SCIP_ROW* SCIPgetRowSetppc(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** returns current number of variables fixed to one in the constraint */
SCIP_EXPORT
int SCIPgetNFixedonesSetppc(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** returns current number of variables fixed to zero in the constraint */
SCIP_EXPORT
int SCIPgetNFixedzerosSetppc(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** cleans up (multi-)aggregations and fixings from setppc constraints */
SCIP_EXPORT
SCIP_RETCODE SCIPcleanupConssSetppc(
SCIP* scip, /**< SCIP data structure */
SCIP_Bool onlychecked, /**< should only checked constraints be cleaned up? */
SCIP_Bool* infeasible, /**< pointer to return whether problem was detected to be infeasible */
int* naddconss, /**< pointer to count number of added (linear) constraints */
int* ndelconss, /**< pointer to count number of deleted (setppc) constraints */
int* nchgcoefs, /**< pointer to count number of changed coefficients */
int* nfixedvars /**< pointer to count number of fixed variables */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_soc.h
* @ingroup CONSHDLRS
* @brief constraint handler for second order cone constraints \f$\sqrt{\gamma + \sum_{i=1}^{n} (\alpha_i\, (x_i + \beta_i))^2} \leq \alpha_{n+1}\, (x_{n+1}+\beta_{n+1})\f$
* @author Stefan Vigerske
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_SOC_H__
#define __SCIP_CONS_SOC_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_misc.h"
#include "scip/type_nlp.h"
#include "nlpi/type_nlpi.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for second order cone constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrSOC(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Second Order Cone Constraints
*
* @{
*
* This constraint handler implements second order cone constraints of the form
* \f[
* \sqrt{\gamma + \sum_{i=1}^{n} (\alpha_i\, (x_i + \beta_i))^2} \leq \alpha_{n+1}\, (x_{n+1}+\beta_{n+1})
* \f]
* Here, \f$\gamma \geq 0\f$ and either \f$x_{n+1} \geq -\beta_{n+1}, \alpha_{n+1} \geq 0\f$ or
* \f$x_{n+1} \leq -\beta_{n+1}, \alpha_{n+1} \leq 0\f$.
*
* Constraints are enforced by separation, where cuts are generated by linearizing the (convex) nonlinear function on the left-hand-side of the constraint.
* Further, a linear outer-approximation (which includes new variables) based on Ben-Tal & Nemirovski or Glineur can be added.
* See also
*
* @par
* Timo Berthold and Stefan Heinz and Stefan Vigerske@n
* <a href="http://dx.doi.org/10.1007/978-1-4614-1927-3">Extending a CIP framework to solve MIQCPs</a>@n
* In: Jon Lee and Sven Leyffer (eds.),
* Mixed-integer nonlinear optimization: Algorithmic advances and applications,
* IMA volumes in Mathematics and its Applications, volume 154, 427-444, 2012.
*
* @par
* Aharon Ben-Tal and Arkadi Nemirovski@n
* On Polyhedral Approximations of the Second-order Cone@n
* Mathematics of Operations Research 26:2, 193-205, 2001
*
* @par
* Fran&ccedil;ois Glineur@n
* Computational experiments with a linear approximation of second order cone optimization@n
* Technical Report 2000:1, Facult&eacute; Polytechnique de Mons, Belgium
*/
/** creates and captures a second order cone constraint
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsSOC(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of variables on left hand side of constraint (n) */
SCIP_VAR** vars, /**< array with variables on left hand side (x_i) */
SCIP_Real* coefs, /**< array with coefficients of left hand side variables (alpha_i), or NULL if all 1.0 */
SCIP_Real* offsets, /**< array with offsets of variables (beta_i), or NULL if all 0.0 */
SCIP_Real constant, /**< constant on left hand side (gamma) */
SCIP_VAR* rhsvar, /**< variable on right hand side of constraint (x_{n+1}) */
SCIP_Real rhscoeff, /**< coefficient of variable on right hand side (alpha_{n+1}) */
SCIP_Real rhsoffset, /**< offset of variable on right hand side (beta_{n+1}) */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
);
/** creates and captures a second order cone constraint
* in its most basic variant, i. e., with all constraint flags set to their default values, which can be set
* afterwards using SCIPsetConsFLAGNAME() in scip.h
*
* @see SCIPcreateConsSOC() for the default constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicSOC(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of variables on left hand side of constraint (n) */
SCIP_VAR** vars, /**< array with variables on left hand side (x_i) */
SCIP_Real* coefs, /**< array with coefficients of left hand side variables (alpha_i), or NULL if all 1.0 */
SCIP_Real* offsets, /**< array with offsets of variables (beta_i), or NULL if all 0.0 */
SCIP_Real constant, /**< constant on left hand side (gamma) */
SCIP_VAR* rhsvar, /**< variable on right hand side of constraint (x_{n+1}) */
SCIP_Real rhscoeff, /**< coefficient of variable on right hand side (alpha_{n+1}) */
SCIP_Real rhsoffset /**< offset of variable on right hand side (beta_{n+1}) */
);
/** Gets the SOC constraint as a nonlinear row representation.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPgetNlRowSOC(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_NLROW** nlrow /**< pointer to store nonlinear row */
);
/** Gets the number of variables on the left hand side of a SOC constraint.
*/
SCIP_EXPORT
int SCIPgetNLhsVarsSOC(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** Gets the variables on the left hand side of a SOC constraint.
*/
SCIP_EXPORT
SCIP_VAR** SCIPgetLhsVarsSOC(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** Gets the coefficients of the variables on the left hand side of a SOC constraint, or NULL if all are equal to 1.0.
*/
SCIP_EXPORT
SCIP_Real* SCIPgetLhsCoefsSOC(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** Gets the offsets of the variables on the left hand side of a SOC constraint, or NULL if all are equal to 0.0.
*/
SCIP_EXPORT
SCIP_Real* SCIPgetLhsOffsetsSOC(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** Gets the constant on the left hand side of a SOC constraint.
*/
SCIP_EXPORT
SCIP_Real SCIPgetLhsConstantSOC(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** Gets the variable on the right hand side of a SOC constraint.
*/
SCIP_EXPORT
SCIP_VAR* SCIPgetRhsVarSOC(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** Gets the coefficient of the variable on the right hand side of a SOC constraint.
*/
SCIP_EXPORT
SCIP_Real SCIPgetRhsCoefSOC(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** Gets the offset of the variables on the right hand side of a SOC constraint.
*/
SCIP_EXPORT
SCIP_Real SCIPgetRhsOffsetSOC(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** Adds the constraint to an NLPI problem.
* Uses nonconvex formulation as quadratic function.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPaddToNlpiProblemSOC(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< SOC constraint */
SCIP_NLPI* nlpi, /**< interface to NLP solver */
SCIP_NLPIPROBLEM* nlpiprob, /**< NLPI problem where to add constraint */
SCIP_HASHMAP* scipvar2nlpivar, /**< mapping from SCIP variables to variable indices in NLPI */
SCIP_Bool names /**< whether to pass constraint names to NLPI */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_sos1.h
* @ingroup CONSHDLRS
* @brief constraint handler for SOS type 1 constraints
* @author Tobias Fischer
* @author Marc Pfetsch
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_SOS1_H__
#define __SCIP_CONS_SOS1_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_misc.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_sol.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for SOS1 constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrSOS1(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Specially Ordered Set (SOS) Type 1 Constraints
*
* @{
*
* A specially ordered set of type 1 (SOS1) is a sequence of variables such that at most one
* variable is nonzero. The special case of two variables arises, for instance, from equilibrium or
* complementary conditions like \f$x \cdot y = 0\f$. Note that it is in principle allowed that a
* variable appears twice, but it then can be fixed to 0.
*/
/** creates and captures an SOS1 constraint
*
* We set the constraint to not be modifable. If the weights are non
* NULL, the variables are ordered according to these weights (in
* ascending order).
*
* @note The constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons().
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsSOS1(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of variables in the constraint */
SCIP_VAR** vars, /**< array with variables of constraint entries */
SCIP_Real* weights, /**< weights determining the variable order, or NULL if natural order should be used */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures an SOS1 constraint
* in its most basic variant, i. e., with all constraint flags set to their default values, which can be set
* afterwards using SCIPsetConsFLAGNAME() in scip.h
*
* @see SCIPcreateConsSOS1() for the default constraint flag configuration
*
* @warning Do NOT set the constraint to be modifiable manually, because this might lead
* to wrong results as the variable array will not be resorted
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicSOS1(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of variables in the constraint */
SCIP_VAR** vars, /**< array with variables of constraint entries */
SCIP_Real* weights /**< weights determining the variable order, or NULL if natural order should be used */
);
/** adds variable to SOS1 constraint, the position is determined by the given weight */
SCIP_EXPORT
SCIP_RETCODE SCIPaddVarSOS1(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_VAR* var, /**< variable to add to the constraint */
SCIP_Real weight /**< weight determining position of variable */
);
/** appends variable to SOS1 constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPappendVarSOS1(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_VAR* var /**< variable to add to the constraint */
);
/** gets number of variables in SOS1 constraint */
SCIP_EXPORT
int SCIPgetNVarsSOS1(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** gets array of variables in SOS1 constraint */
SCIP_EXPORT
SCIP_VAR** SCIPgetVarsSOS1(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets array of weights in SOS1 constraint (or NULL if not existent) */
SCIP_EXPORT
SCIP_Real* SCIPgetWeightsSOS1(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets conflict graph of SOS1 constraints (or NULL if not existent)
*
* @note The conflict graph is globally valid; local changes are not taken into account.
*/
SCIP_EXPORT
SCIP_DIGRAPH* SCIPgetConflictgraphSOS1(
SCIP_CONSHDLR* conshdlr /**< SOS1 constraint handler */
);
/** gets number of problem variables that are part of the SOS1 conflict graph */
SCIP_EXPORT
int SCIPgetNSOS1Vars(
SCIP_CONSHDLR* conshdlr /**< SOS1 constraint handler */
);
/** returns whether variable is part of the SOS1 conflict graph */
SCIP_EXPORT
SCIP_Bool SCIPvarIsSOS1(
SCIP_CONSHDLR* conshdlr, /**< SOS1 constraint handler */
SCIP_VAR* var /**< variable */
);
/** returns node of variable in the conflict graph or -1 if variable is not part of the SOS1 conflict graph */
SCIP_EXPORT
int SCIPvarGetNodeSOS1(
SCIP_CONSHDLR* conshdlr, /**< SOS1 constraint handler */
SCIP_VAR* var /**< variable */
);
/** returns variable that belongs to a given node from the conflict graph */
SCIP_EXPORT
SCIP_VAR* SCIPnodeGetVarSOS1(
SCIP_DIGRAPH* conflictgraph, /**< conflict graph */
int node /**< node from the conflict graph */
);
/** based on solution values of the variables, fixes variables to zero to turn all SOS1 constraints feasible */
SCIP_EXPORT
SCIP_RETCODE SCIPmakeSOS1sFeasible(
SCIP* scip, /**< SCIP pointer */
SCIP_CONSHDLR* conshdlr, /**< SOS1 constraint handler */
SCIP_SOL* sol, /**< solution */
SCIP_Bool* changed, /**< pointer to store whether the solution has been changed */
SCIP_Bool* success /**< pointer to store whether SOS1 constraints have been turned feasible and
* solution was good enough */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_sos2.h
* @ingroup CONSHDLRS
* @brief constraint handler for SOS type 2 constraints
* @author Marc Pfetsch
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_SOS2_H__
#define __SCIP_CONS_SOS2_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for SOS2 constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrSOS2(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Specially Ordered Set (SOS) Type 2 Constraints
*
* @{
*
* A specially ordered set of type 2 (SOS2) is a sequence of variables such that at most two
* variables are nonzero and if two variables are nonzero they must be adjacent in the specified
* sequence. Note that it is in principle allowed that a variable appears twice, but it then can be
* fixed to 0 if it is at least two apart in the sequence.
*/
/** creates and captures an SOS2 constraint
*
* We set the constraint to not be modifable. If the weights are non
* NULL, the variables are ordered according to these weights (in
* ascending order).
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsSOS2(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of variables in the constraint */
SCIP_VAR** vars, /**< array with variables of constraint entries */
SCIP_Real* weights, /**< weights determining the variable order, or NULL if natural order should be used */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a SOS2 constraint with all constraint flags set to their default values.
*
* @warning Do NOT set the constraint to be modifiable manually, because this might lead
* to wrong results as the variable array will not be resorted
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicSOS2(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int nvars, /**< number of variables in the constraint */
SCIP_VAR** vars, /**< array with variables of constraint entries */
SCIP_Real* weights /**< weights determining the variable order, or NULL if natural order should be used */
);
/** adds variable to SOS2 constraint, the position is determined by the given weight */
SCIP_EXPORT
SCIP_RETCODE SCIPaddVarSOS2(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_VAR* var, /**< variable to add to the constraint */
SCIP_Real weight /**< weight determining position of variable */
);
/** appends variable to SOS2 constraint */
SCIP_EXPORT
SCIP_RETCODE SCIPappendVarSOS2(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_VAR* var /**< variable to add to the constraint */
);
/** gets number of variables in SOS2 constraint */
SCIP_EXPORT
int SCIPgetNVarsSOS2(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint */
);
/** gets array of variables in SOS2 constraint */
SCIP_EXPORT
SCIP_VAR** SCIPgetVarsSOS2(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets array of weights in SOS2 constraint (or NULL if not existent) */
SCIP_EXPORT
SCIP_Real* SCIPgetWeightsSOS2(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_superindicator.h
* @ingroup CONSHDLRS
* @brief constraint handler for indicator constraints over arbitrary constraint types
* @author Ambros Gleixner
* @author Frederic Pythoud
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_SUPERINDICATOR_H__
#define __SCIP_CONS_SUPERINDICATOR_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_dialog.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* constraint-specific interface methods
*/
/** creates the handler for superindicator constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrSuperindicator(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Superindicator Constraints
*
* @{
*
* Superindicator constraints are constraints of the form
* \f[
* x_i = 1 \Rightarrow C(x)
* \f]
* where \f$ x_i \f$ is a binary variable and \f$ C(\dot) \f$ a constraint. The superindicator constraint is satisfied
* if and only if x_i is zero or C is satisfied.
*/
/** creates and captures a superindicator constraint
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsSuperindicator(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR* binvar, /**< pointer to the indicator constraint */
SCIP_CONS* slackcons, /**< constraint corresponding to the handled constraint */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a superindicator constraint
* in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
* method SCIPcreateConsSuperindicator(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
*
* @see SCIPcreateConsSuperindicator() for information about the basic constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicSuperindicator(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR* binvar, /**< pointer to the indicator constraint */
SCIP_CONS* slackcons /**< constraint corresponding to the handled constraint */
);
/** gets binary variable corresponding to the superindicator constraint */
SCIP_EXPORT
SCIP_VAR* SCIPgetBinaryVarSuperindicator(
SCIP_CONS* cons /**< superindicator constraint */
);
/** gets the slack constraint corresponding to the superindicator constraint */
SCIP_EXPORT
SCIP_CONS* SCIPgetSlackConsSuperindicator(
SCIP_CONS* cons /**< superindicator constraint */
);
/*
* constraint-dependent SCIP methods
*/
/** transforms the current problem into a MinUC problem (minimizing the number of unsatisfied constraints),
* a CIP generalization of the MinULR (min. unsatisfied linear relations) problem
*/
SCIP_EXPORT
SCIP_RETCODE SCIPtransformMinUC(
SCIP* scip, /**< SCIP data structure */
SCIP_Bool* success /**< pointer to store whether all constraints could be transformed */
);
/*
* constraint-dependent dialog entries
*/
/** dialog execution method for the SCIPtransformMinUC() command */
SCIP_EXPORT
SCIP_DECL_DIALOGEXEC(SCIPdialogExecChangeMinUC);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_symresack.h
* @ingroup CONSHDLRS
* @brief constraint handler for symresack constraints
* @author Christopher Hojny
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_SYMRESACK_H__
#define __SCIP_CONS_SYMRESACK_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for symresack constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
*/
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrSymresack(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Symresack Constraints
*
* @{
*
* Given a permutation that acts on the order of the variables of a (mixed) 0/1-program
* such that the permutation is a symmetry of the program, this constraint handler can
* be used to handle the symmetries corresponding to the permutation. The symmetries
* are handled by enforcing that a binary solution is lexicographically not smaller than
* its permutation. In a presolving step, we check whether the permutation acts only on
* binary points. Otherwise, we eliminate the non-binary variables from the permutation.
* Furthermore, we delete fixed points from the permutation.
*
* Moreover, the constraint handler checks whether each cycle of the permutation is
* contained in a set packing or partitioning constraint. In this case, the symresack
* is strengthened to a ppsymresack and strong symmetry handling inequalities are added during
* the initialization of the constraint handler.
*
* @pre The permutation is encoded by an array perm for which perm[i] = j if and only if
* the image of i under the permutation is j.
*
* @pre The permutation given to the constraint handler has to be a symmetry of the
* underlying problem. This is NOT checked by the constraint handler.
*/
/** creates a symmetry breaking constraint
*
* Depending on the given permutation, either an orbisack or symresack constraint
* is created.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateSymbreakCons(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int* perm, /**< permutation */
SCIP_VAR** vars, /**< variables */
int nvars, /**< number of variables in vars array */
SCIP_Bool ismodelcons, /**< whether the added constraint is a model constraint */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a symresack constraint
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsSymresack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int* perm, /**< permutation */
SCIP_VAR** vars, /**< variables */
int nvars, /**< number of variables in vars array */
SCIP_Bool ismodelcons, /**< whether the symresack is a model constraint */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a symresack constraint
* in its most basic variant, i.e., with all constraint flags set to their default values, which can be set
* afterwards using SCIPsetConsFLAGNAME() in scip.h
*
* @see SCIPcreateConsSymresack() for the default constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicSymresack(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
int* perm, /**< permutation */
SCIP_VAR** vars, /**< variables */
int nvars, /**< number of variables in vars array */
SCIP_Bool ismodelcons /**< whether the symresack is a model constraint */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
/* fuer Informationstechnik Berlin */
/* */
/* SCIP is distributed under the terms of the ZIB Academic License. */
/* */
/* You should have received a copy of the ZIB Academic License */
/* along with SCIP; see the file COPYING. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file cons_varbound.h
* @ingroup CONSHDLRS
* @brief Constraint handler for variable bound constraints \f$lhs \leq x + c y \leq rhs\f$.
* @author Tobias Achterberg
* @author Timo Berthold
* @author Michael Winkler
* @author Gerald Gamrath
* @author Stefan Heinz
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_CONS_VARBOUND_H__
#define __SCIP_CONS_VARBOUND_H__
#include "scip/def.h"
#include "scip/type_cons.h"
#include "scip/type_lp.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the handler for variable bound constraints and includes it in SCIP
*
* @ingroup ConshdlrIncludes
* */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeConshdlrVarbound(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup CONSHDLRS
*
* @{
*
* @name Variable Bound Constraints
*
* @{
*
* This constraint handler handles a special type of linear constraints, namely variable bound constraints.
* A variable bound constraint has the form
* \f[
* lhs \leq x + c y \leq rhs
* \f]
* with coefficient \f$c \in Q\f$, \f$lhs\in Q \cup \{-\infty\}\f$, \f$rhs\in Q \cup \{\infty\}\f$,
* and decision variables \f$x\f$ (non-binary) and \f$y\f$ (binary or integer).
*/
/** creates and captures a variable bound constraint: lhs <= x + c*y <= rhs
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsVarbound(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR* var, /**< variable x that has variable bound */
SCIP_VAR* vbdvar, /**< binary, integer or implicit integer bounding variable y */
SCIP_Real vbdcoef, /**< coefficient c of bounding variable y */
SCIP_Real lhs, /**< left hand side of variable bound inequality */
SCIP_Real rhs, /**< right hand side of variable bound inequality */
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
* Usually set to TRUE. */
SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool check, /**< should the constraint be checked for feasibility?
* TRUE for model constraints, FALSE for additional, redundant constraints. */
SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
* Usually set to TRUE. */
SCIP_Bool local, /**< is constraint only valid locally?
* Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
* Usually set to FALSE. In column generation applications, set to TRUE if pricing
* adds coefficients to this constraint. */
SCIP_Bool dynamic, /**< is constraint subject to aging?
* Usually set to FALSE. Set to TRUE for own cuts which
* are separated as constraints. */
SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
* Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
* if it may be moved to a more global node?
* Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
);
/** creates and captures a varbound constraint
* in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
* method SCIPcreateConsVarbound(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
*
* @see SCIPcreateConsVarbound() for information about the basic constraint flag configuration
*
* @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
*/
SCIP_EXPORT
SCIP_RETCODE SCIPcreateConsBasicVarbound(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS** cons, /**< pointer to hold the created constraint */
const char* name, /**< name of constraint */
SCIP_VAR* var, /**< variable x that has variable bound */
SCIP_VAR* vbdvar, /**< binary, integer or implicit integer bounding variable y */
SCIP_Real vbdcoef, /**< coefficient c of bounding variable y */
SCIP_Real lhs, /**< left hand side of variable bound inequality */
SCIP_Real rhs /**< right hand side of variable bound inequality */
);
/** gets left hand side of variable bound constraint lhs <= x + c*y <= rhs */
SCIP_EXPORT
SCIP_Real SCIPgetLhsVarbound(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets right hand side of variable bound constraint lhs <= x + c*y <= rhs */
SCIP_EXPORT
SCIP_Real SCIPgetRhsVarbound(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets bounded variable x of variable bound constraint lhs <= x + c*y <= rhs */
SCIP_EXPORT
SCIP_VAR* SCIPgetVarVarbound(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets bounding variable y of variable bound constraint lhs <= x + c*y <= rhs */
SCIP_EXPORT
SCIP_VAR* SCIPgetVbdvarVarbound(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets bound coefficient c of variable bound constraint lhs <= x + c*y <= rhs */
SCIP_EXPORT
SCIP_Real SCIPgetVbdcoefVarbound(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the dual solution of the variable bound constraint in the current LP */
SCIP_EXPORT
SCIP_Real SCIPgetDualsolVarbound(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** gets the dual Farkas value of the variable bound constraint in the current infeasible LP */
SCIP_EXPORT
SCIP_Real SCIPgetDualfarkasVarbound(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** returns the linear relaxation of the given variable bound constraint; may return NULL if no LP row was yet created;
* the user must not modify the row!
*/
SCIP_EXPORT
SCIP_ROW* SCIPgetRowVarbound(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons /**< constraint data */
);
/** cleans up (multi-)aggregations and fixings from varbound constraints */
SCIP_EXPORT
SCIP_RETCODE SCIPcleanupConssVarbound(
SCIP* scip, /**< SCIP data structure */
SCIP_Bool onlychecked, /**< should only checked constraints be cleaned up? */
SCIP_Bool* infeasible, /**< pointer to return whether the problem was detected to be infeasible */
int* naddconss, /**< pointer to count number of added (linear) constraints */
int* ndelconss, /**< pointer to count number of deleted (varbound) constraints */
int* nchgbds /**< pointer to count number of bound changes */
);
/** @} */
/** @} */
#ifdef __cplusplus
}
#endif
#endif