Skip to content
...@@ -40,7 +40,7 @@ namespace sat { ...@@ -40,7 +40,7 @@ namespace sat {
// tasks generated by GenerateTask() are executed in parallel in a threadpool. // tasks generated by GenerateTask() are executed in parallel in a threadpool.
class SubSolver { class SubSolver {
public: public:
SubSolver(int id, const std::string& name) : id_(id), name_(name) {} explicit SubSolver(const std::string& name) : name_(name) {}
virtual ~SubSolver() {} virtual ~SubSolver() {}
// Returns true iff GenerateTask() can be called. // Returns true iff GenerateTask() can be called.
...@@ -84,7 +84,6 @@ class SubSolver { ...@@ -84,7 +84,6 @@ class SubSolver {
std::string name() const { return name_; } std::string name() const { return name_; }
protected: protected:
const int id_;
const std::string name_; const std::string name_;
double score_ = 0.0; double score_ = 0.0;
double deterministic_time_ = 0.0; double deterministic_time_ = 0.0;
...@@ -93,8 +92,8 @@ class SubSolver { ...@@ -93,8 +92,8 @@ class SubSolver {
// A simple wrapper to add a synchronization point in the list of subsolvers. // A simple wrapper to add a synchronization point in the list of subsolvers.
class SynchronizationPoint : public SubSolver { class SynchronizationPoint : public SubSolver {
public: public:
SynchronizationPoint(int id, std::function<void()> f) explicit SynchronizationPoint(std::function<void()> f)
: SubSolver(id, ""), f_(std::move(f)) {} : SubSolver(""), f_(std::move(f)) {}
bool TaskIsAvailable() final { return false; } bool TaskIsAvailable() final { return false; }
std::function<void()> GenerateTask(int64 task_id) final { return nullptr; } std::function<void()> GenerateTask(int64 task_id) final { return nullptr; }
void Synchronize() final { f_(); } void Synchronize() final { f_(); }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#ifndef OR_TOOLS_SAT_SYNCHRONIZATION_H_ #ifndef OR_TOOLS_SAT_SYNCHRONIZATION_H_
#define OR_TOOLS_SAT_SYNCHRONIZATION_H_ #define OR_TOOLS_SAT_SYNCHRONIZATION_H_
#include <deque>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -247,6 +248,10 @@ class SharedResponseManager { ...@@ -247,6 +248,10 @@ class SharedResponseManager {
// reported. We check for this case in NewSolution(). // reported. We check for this case in NewSolution().
void NotifyThatImprovingProblemIsInfeasible(const std::string& worker_info); void NotifyThatImprovingProblemIsInfeasible(const std::string& worker_info);
// Adds to the shared response a subset of assumptions that are enough to
// make the problem infeasible.
void AddUnsatCore(const std::vector<int>& core);
// Sets the statistics in the response to the one of the solver inside the // Sets the statistics in the response to the one of the solver inside the
// given in-memory model. This does nothing if the model is nullptr. // given in-memory model. This does nothing if the model is nullptr.
// //
...@@ -327,7 +332,7 @@ class SharedResponseManager { ...@@ -327,7 +332,7 @@ class SharedResponseManager {
// a parallel context. // a parallel context.
class SharedBoundsManager { class SharedBoundsManager {
public: public:
SharedBoundsManager(int num_workers, const CpModelProto& model_proto); explicit SharedBoundsManager(const CpModelProto& model_proto);
// Reports a set of locally improved variable bounds to the shared bounds // Reports a set of locally improved variable bounds to the shared bounds
// manager. The manager will compare these bounds changes against its // manager. The manager will compare these bounds changes against its
...@@ -338,9 +343,14 @@ class SharedBoundsManager { ...@@ -338,9 +343,14 @@ class SharedBoundsManager {
const std::vector<int64>& new_lower_bounds, const std::vector<int64>& new_lower_bounds,
const std::vector<int64>& new_upper_bounds); const std::vector<int64>& new_upper_bounds);
// Returns a new id to be used in GetChangedBounds(). This is just an ever
// increasing sequence starting from zero. Note that the class is not designed
// to have too many of these.
int RegisterNewId();
// When called, returns the set of bounds improvements since // When called, returns the set of bounds improvements since
// the last time this method was called by the same worker. // the last time this method was called with the same id.
void GetChangedBounds(int worker_id, std::vector<int>* variables, void GetChangedBounds(int id, std::vector<int>* variables,
std::vector<int64>* new_lower_bounds, std::vector<int64>* new_lower_bounds,
std::vector<int64>* new_upper_bounds); std::vector<int64>* new_upper_bounds);
...@@ -349,33 +359,24 @@ class SharedBoundsManager { ...@@ -349,33 +359,24 @@ class SharedBoundsManager {
void Synchronize(); void Synchronize();
private: private:
const int num_workers_;
const int num_variables_; const int num_variables_;
const CpModelProto& model_proto_;
absl::Mutex mutex_; absl::Mutex mutex_;
// These are always up to date. // These are always up to date.
std::vector<int64> lower_bounds_ ABSL_GUARDED_BY(mutex_); std::vector<int64> lower_bounds_ ABSL_GUARDED_BY(mutex_);
std::vector<int64> upper_bounds_ ABSL_GUARDED_BY(mutex_); std::vector<int64> upper_bounds_ ABSL_GUARDED_BY(mutex_);
SparseBitset<int64> changed_variables_since_last_synchronize_ SparseBitset<int64> changed_variables_since_last_synchronize_
ABSL_GUARDED_BY(mutex_); ABSL_GUARDED_BY(mutex_);
// These are only updated on Synchronize(). // These are only updated on Synchronize().
std::vector<SparseBitset<int64>> changed_variables_per_workers_
ABSL_GUARDED_BY(mutex_);
std::vector<int64> synchronized_lower_bounds_ ABSL_GUARDED_BY(mutex_); std::vector<int64> synchronized_lower_bounds_ ABSL_GUARDED_BY(mutex_);
std::vector<int64> synchronized_upper_bounds_ ABSL_GUARDED_BY(mutex_); std::vector<int64> synchronized_upper_bounds_ ABSL_GUARDED_BY(mutex_);
std::deque<SparseBitset<int64>> id_to_changed_variables_
ABSL_GUARDED_BY(mutex_);
}; };
// Stores information on the worker in the parallel context.
struct WorkerInfo {
std::string worker_name;
int worker_id = -1;
};
// Implementations
template <typename ValueType> template <typename ValueType>
int SharedSolutionRepository<ValueType>::NumSolutions() const { int SharedSolutionRepository<ValueType>::NumSolutions() const {
absl::MutexLock mutex_lock(&mutex_); absl::MutexLock mutex_lock(&mutex_);
......
...@@ -89,7 +89,7 @@ namespace sat { ...@@ -89,7 +89,7 @@ namespace sat {
// There is hope to unify the variants of these algorithms by abstracting the // There is hope to unify the variants of these algorithms by abstracting the
// tasks away to reason only on events. // tasks away to reason only on events.
// The minimal value of an envelope, for instance the envelope the empty set. // The minimal value of an envelope, for instance the envelope of the empty set.
template <typename IntegerType> template <typename IntegerType>
constexpr IntegerType IntegerTypeMinimumValue() { constexpr IntegerType IntegerTypeMinimumValue() {
return std::numeric_limits<IntegerType>::min(); return std::numeric_limits<IntegerType>::min();
...@@ -111,12 +111,27 @@ class ThetaLambdaTree { ...@@ -111,12 +111,27 @@ class ThetaLambdaTree {
// allows to keep the same memory for each call. // allows to keep the same memory for each call.
void Reset(int num_events); void Reset(int num_events);
// Recomputes the values of internal nodes of the tree from the values in the
// leaves. We enable batching modifications to the tree by providing
// DelayedXXX() methods that run in O(1), but those methods do not
// update internal nodes. This breaks tree invariants, so that GetXXX()
// methods will not reflect modifications made to events.
// RecomputeTreeForDelayedOperations() restores those invariants in O(n).
// Thus, batching operations can be done by first doing calls to DelayedXXX()
// methods, then calling RecomputeTreeForDelayedOperations() once.
void RecomputeTreeForDelayedOperations();
// Makes event present and updates its initial envelope and min/max energies. // Makes event present and updates its initial envelope and min/max energies.
// The initial_envelope must be >= ThetaLambdaTreeNegativeInfinity(). // The initial_envelope must be >= ThetaLambdaTreeNegativeInfinity().
// This updates the tree in O(log n). // This updates the tree in O(log n).
void AddOrUpdateEvent(int event, IntegerType initial_envelope, void AddOrUpdateEvent(int event, IntegerType initial_envelope,
IntegerType energy_min, IntegerType energy_max); IntegerType energy_min, IntegerType energy_max);
// Delayed version of AddOrUpdateEvent(),
// see RecomputeTreeForDelayedOperations().
void DelayedAddOrUpdateEvent(int event, IntegerType initial_envelope,
IntegerType energy_min, IntegerType energy_max);
// Adds event to the lambda part of the tree only. // Adds event to the lambda part of the tree only.
// This will leave GetEnvelope() unchanged, only GetOptionalEnvelope() can // This will leave GetEnvelope() unchanged, only GetOptionalEnvelope() can
// be affected. This is done by setting envelope to IntegerTypeMinimumValue(), // be affected. This is done by setting envelope to IntegerTypeMinimumValue(),
...@@ -125,9 +140,18 @@ class ThetaLambdaTree { ...@@ -125,9 +140,18 @@ class ThetaLambdaTree {
void AddOrUpdateOptionalEvent(int event, IntegerType initial_envelope_opt, void AddOrUpdateOptionalEvent(int event, IntegerType initial_envelope_opt,
IntegerType energy_max); IntegerType energy_max);
// Delayed version of AddOrUpdateOptionalEvent(),
// see RecomputeTreeForDelayedOperations().
void DelayedAddOrUpdateOptionalEvent(int event,
IntegerType initial_envelope_opt,
IntegerType energy_max);
// Makes event absent, compute the new envelope in O(log n). // Makes event absent, compute the new envelope in O(log n).
void RemoveEvent(int event); void RemoveEvent(int event);
// Delayed version of RemoveEvent(), see RecomputeTreeForDelayedOperations().
void DelayedRemoveEvent(int event);
// Returns the maximum envelope using all the energy_min in O(1). // Returns the maximum envelope using all the energy_min in O(1).
// If theta is empty, returns ThetaLambdaTreeNegativeInfinity(). // If theta is empty, returns ThetaLambdaTreeNegativeInfinity().
IntegerType GetEnvelope() const; IntegerType GetEnvelope() const;
...@@ -175,6 +199,15 @@ class ThetaLambdaTree { ...@@ -175,6 +199,15 @@ class ThetaLambdaTree {
} }
private: private:
struct TreeNode {
IntegerType envelope;
IntegerType envelope_opt;
IntegerType sum_of_energy_min;
IntegerType max_of_energy_delta;
};
TreeNode ComposeTreeNodes(TreeNode left, TreeNode right);
int GetLeafFromEvent(int event) const; int GetLeafFromEvent(int event) const;
int GetEventFromLeaf(int leaf) const; int GetEventFromLeaf(int leaf) const;
...@@ -202,13 +235,11 @@ class ThetaLambdaTree { ...@@ -202,13 +235,11 @@ class ThetaLambdaTree {
int num_leaves_; int num_leaves_;
int power_of_two_; int power_of_two_;
// A bool used in debug mode, to check that sequences of delayed operations
// are ended by Reset() or RecomputeTreeForDelayedOperations().
bool leaf_nodes_have_delayed_operations_ = false;
// Envelopes and energies of nodes. // Envelopes and energies of nodes.
struct TreeNode {
IntegerType envelope;
IntegerType envelope_opt;
IntegerType sum_of_energy_min;
IntegerType max_of_energy_delta;
};
std::vector<TreeNode> tree_; std::vector<TreeNode> tree_;
}; };
......
...@@ -81,8 +81,10 @@ class ScopedFloatingPointEnv { ...@@ -81,8 +81,10 @@ class ScopedFloatingPointEnv {
#elif defined(ARCH_K8) #elif defined(ARCH_K8)
CHECK_EQ(0, fegetenv(&fenv_)); CHECK_EQ(0, fegetenv(&fenv_));
excepts &= FE_ALL_EXCEPT; excepts &= FE_ALL_EXCEPT;
#ifdef __APPLE__ #if defined(__APPLE__)
fenv_.__control &= ~excepts; fenv_.__control &= ~excepts;
#elif defined(__FreeBSD__)
fenv_.__x87.__control &= ~excepts;
#else // Linux #else // Linux
fenv_.__control_word &= ~excepts; fenv_.__control_word &= ~excepts;
#endif #endif
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#ifndef OR_TOOLS_UTIL_ZVECTOR_H_ #ifndef OR_TOOLS_UTIL_ZVECTOR_H_
#define OR_TOOLS_UTIL_ZVECTOR_H_ #define OR_TOOLS_UTIL_ZVECTOR_H_
#if defined(__APPLE__) && defined(__GNUC__) #if ( defined(__APPLE__) || defined(__FreeBSD__) ) && defined(__GNUC__)
#include <machine/endian.h> #include <machine/endian.h>
#elif !defined(_MSC_VER) #elif !defined(_MSC_VER)
#include <endian.h> #include <endian.h>
......
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* 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 bandit.h
* @ingroup INTERNALAPI
* @brief internal methods for bandit algorithms
* @author Gregor Hendel
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BANDIT_H__
#define __SCIP_BANDIT_H__
#include "scip/def.h"
#include "blockmemshell/memory.h"
#include "scip/type_retcode.h"
#include "scip/type_result.h"
#include "scip/type_set.h"
#include "scip/type_primal.h"
#include "scip/type_bandit.h"
#include "scip/stat.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates and resets bandit algorithm */
SCIP_RETCODE SCIPbanditCreate(
SCIP_BANDIT** bandit, /**< pointer to bandit algorithm data structure */
SCIP_BANDITVTABLE* banditvtable, /**< virtual table for this bandit algorithm */
BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
BMS_BUFMEM* bufmem, /**< buffer memory */
SCIP_Real* priorities, /**< nonnegative priorities for each action, or NULL if not needed */
int nactions, /**< the positive number of actions for this bandit */
unsigned int initseed, /**< initial seed for random number generation */
SCIP_BANDITDATA* banditdata /**< algorithm specific bandit data */
);
/** calls destructor and frees memory of bandit algorithm */
SCIP_RETCODE SCIPbanditFree(
BMS_BLKMEM* blkmem, /**< block memory */
SCIP_BANDIT** bandit /**< pointer to bandit algorithm data structure */
);
/** reset the bandit algorithm */
SCIP_RETCODE SCIPbanditReset(
BMS_BUFMEM* bufmem, /**< buffer memory */
SCIP_BANDIT* bandit, /**< pointer to bandit algorithm data structure */
SCIP_Real* priorities, /**< priorities for every action, or NULL if not needed */
unsigned int seed /**< initial random seed for bandit selection */
);
/** get data of this bandit algorithm */
SCIP_BANDITDATA* SCIPbanditGetData(
SCIP_BANDIT* bandit /**< pointer to bandit algorithm data structure */
);
/** set the data of this bandit algorithm */
void SCIPbanditSetData(
SCIP_BANDIT* bandit, /**< bandit algorithm data structure */
SCIP_BANDITDATA* banditdata /**< bandit algorihm specific data */
);
/** create a bandit VTable for bandit algorithm callback functions */
SCIP_RETCODE SCIPbanditvtableCreate(
SCIP_BANDITVTABLE** banditvtable, /**< pointer to virtual table for bandit algorithm */
const char* name, /**< a name for the algorithm represented by this vtable */
SCIP_DECL_BANDITFREE ((*banditfree)), /**< callback to free bandit specific data structures */
SCIP_DECL_BANDITSELECT((*banditselect)), /**< selection callback for bandit selector */
SCIP_DECL_BANDITUPDATE((*banditupdate)), /**< update callback for bandit algorithms */
SCIP_DECL_BANDITRESET ((*banditreset)) /**< update callback for bandit algorithms */
);
/** free a bandit vTable for bandit algorithm callback functions */
void SCIPbanditvtableFree(
SCIP_BANDITVTABLE** banditvtable /**< pointer to virtual table for bandit algorithm */
);
#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 bandit_epsgreedy.h
* @ingroup INTERNALAPI
* @brief internal methods for epsilon greedy bandit selection
* @author Gregor Hendel
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BANDIT_EPSGREEDY_H__
#define __SCIP_BANDIT_EPSGREEDY_H__
#include "blockmemshell/memory.h"
#include "scip/def.h"
#include "scip/type_bandit.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the epsilon greedy bandit algorithm includes it in SCIP */
SCIP_RETCODE SCIPincludeBanditvtableEpsgreedy(
SCIP* scip /**< SCIP data structure */
);
/** callback to free bandit specific data structures */
SCIP_DECL_BANDITFREE(SCIPbanditFreeEpsgreedy);
/** selection callback for bandit algorithm */
SCIP_DECL_BANDITSELECT(SCIPbanditSelectEpsgreedy);
/** update callback for bandit algorithm */
SCIP_DECL_BANDITUPDATE(SCIPbanditUpdateEpsgreedy);
/** reset callback for bandit algorithm */
SCIP_DECL_BANDITRESET(SCIPbanditResetEpsgreedy);
/** internal method to create and reset epsilon greedy bandit algorithm */
SCIP_RETCODE SCIPbanditCreateEpsgreedy(
BMS_BLKMEM* blkmem, /**< block memory */
BMS_BUFMEM* bufmem, /**< buffer memory */
SCIP_BANDITVTABLE* vtable, /**< virtual function table with epsilon greedy callbacks */
SCIP_BANDIT** epsgreedy, /**< pointer to store the epsilon greedy bandit algorithm */
SCIP_Real* priorities, /**< nonnegative priorities for each action, or NULL if not needed */
SCIP_Real eps, /**< parameter to increase probability for exploration between all actions */
SCIP_Bool preferrecent, /**< should the weights be updated in an exponentially decaying way? */
SCIP_Real decayfactor, /**< the factor to reduce the weight of older observations if exponential decay is enabled */
int avglim, /**< nonnegative limit on observation number before the exponential decay starts,
* only relevant if exponential decay is enabled
*/
int nactions, /**< the number of possible actions */
unsigned int initseed /**< initial random seed */
);
#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 bandit_exp3.h
* @ingroup INTERNALAPI
* @brief internal methods for Exp.3 bandit algorithm
* @author Gregor Hendel
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BANDIT_EXP3_H__
#define __SCIP_BANDIT_EXP3_H__
#include "blockmemshell/memory.h"
#include "scip/def.h"
#include "scip/type_bandit.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#ifdef __cplusplus
extern "C" {
#endif
/** include virtual function table for Exp.3 bandit algorithms */
SCIP_RETCODE SCIPincludeBanditvtableExp3(
SCIP* scip /**< SCIP data structure */
);
/*
* callback methods for Exp.3 bandit algorithm to create a virtual function table
*/
/** callback to free bandit specific data structures */
SCIP_DECL_BANDITFREE(SCIPbanditFreeExp3);
/** selection callback for bandit selector */
SCIP_DECL_BANDITSELECT(SCIPbanditSelectExp3);
/** update callback for bandit algorithm */
SCIP_DECL_BANDITUPDATE(SCIPbanditUpdateExp3);
/** reset callback for bandit algorithm */
SCIP_DECL_BANDITRESET(SCIPbanditResetExp3);
/** direct bandit creation method for the core where no SCIP pointer is available */
SCIP_RETCODE SCIPbanditCreateExp3(
BMS_BLKMEM* blkmem, /**< block memory data structure */
BMS_BUFMEM* bufmem, /**< buffer memory */
SCIP_BANDITVTABLE* vtable, /**< virtual function table for callback functions of Exp.3 */
SCIP_BANDIT** exp3, /**< pointer to store bandit algorithm */
SCIP_Real* priorities, /**< nonnegative priorities for each action, or NULL if not needed */
SCIP_Real gammaparam, /**< weight between uniform (gamma ~ 1) and weight driven (gamma ~ 0) probability distribution */
SCIP_Real beta, /**< gain offset between 0 and 1 at every observation */
int nactions, /**< the positive number of actions for this bandit algorithm */
unsigned int initseed /**< initial random seed */
);
#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 bandit_ucb.h
* @ingroup INTERNALAPI
* @brief internal methods for UCB bandit algorithm
* @author Gregor Hendel
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BANDIT_UCB_H__
#define __SCIP_BANDIT_UCB_H__
#include "blockmemshell/memory.h"
#include "scip/def.h"
#include "scip/type_bandit.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#ifdef __cplusplus
extern "C" {
#endif
/** include virtual function table for UCB bandit algorithms */
SCIP_RETCODE SCIPincludeBanditvtableUcb(
SCIP* scip /**< SCIP data structure */
);
/*
* Callback methods of bandit algorithm
*/
/** callback to free bandit specific data structures */
SCIP_DECL_BANDITFREE(SCIPbanditFreeUcb);
/** selection callback for bandit selector */
SCIP_DECL_BANDITSELECT(SCIPbanditSelectUcb);
/** update callback for bandit algorithm */
SCIP_DECL_BANDITUPDATE(SCIPbanditUpdateUcb);
/** reset callback for bandit algorithm */
SCIP_DECL_BANDITRESET(SCIPbanditResetUcb);
/** internal method to create and reset UCB bandit algorithm */
SCIP_RETCODE SCIPbanditCreateUcb(
BMS_BLKMEM* blkmem, /**< block memory */
BMS_BUFMEM* bufmem, /**< buffer memory */
SCIP_BANDITVTABLE* vtable, /**< virtual function table for UCB bandit algorithm */
SCIP_BANDIT** ucb, /**< pointer to store bandit algorithm */
SCIP_Real* priorities, /**< nonnegative priorities for each action, or NULL if not needed */
SCIP_Real alpha, /**< parameter to increase confidence width */
int nactions, /**< the positive number of actions for this bandit algorithm */
unsigned int initseed /**< initial random seed */
);
#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 scip/src/scip/benders.h
* @ingroup INTERNALAPI
* @brief internal methods for Benders' decomposition
* @author Stephen J. Maher
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BENDERS_H__
#define __SCIP_BENDERS_H__
#include "blockmemshell/memory.h"
#include "scip/def.h"
#include "scip/type_benders.h"
#include "scip/type_benderscut.h"
#include "scip/type_dcmp.h"
#include "scip/type_message.h"
#include "scip/type_misc.h"
#include "scip/type_result.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "scip/type_set.h"
#include "scip/type_sol.h"
#include "scip/type_stat.h"
#include "scip/type_var.h"
#ifdef __cplusplus
extern "C" {
#endif
/** copies the given Benders' decomposition to a new scip */
SCIP_RETCODE SCIPbendersCopyInclude(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* sourceset, /**< SCIP_SET of SCIP to copy from */
SCIP_SET* targetset, /**< SCIP_SET of SCIP to copy to */
SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
* target variables; must not be NULL */
SCIP_Bool copysubproblems, /**< must the subproblems be copied with the Benders' decomposition copy */
SCIP_Bool* valid /**< was the copying process valid? */
);
/** creates a Benders' decomposition */
SCIP_RETCODE SCIPbendersCreate(
SCIP_BENDERS** benders, /**< pointer to Benders' decomposition data structure */
SCIP_SET* set, /**< global SCIP settings */
SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
const char* name, /**< name of Benders' decomposition */
const char* desc, /**< description of Benders' decomposition */
int priority, /**< priority of the Benders' decomposition */
SCIP_Bool cutlp, /**< should Benders' cuts be generated for LP solutions */
SCIP_Bool cutpseudo, /**< should Benders' cuts be generated for pseudo solutions */
SCIP_Bool cutrelax, /**< should Benders' cuts be generated for relaxation solutions */
SCIP_Bool shareauxvars, /**< should this Benders' use the highest priority Benders aux vars */
SCIP_DECL_BENDERSCOPY ((*benderscopy)), /**< copy method of Benders' decomposition or NULL if you don't want to copy your plugin into sub-SCIPs */
SCIP_DECL_BENDERSFREE ((*bendersfree)), /**< destructor of Benders' decomposition */
SCIP_DECL_BENDERSINIT ((*bendersinit)), /**< initialize Benders' decomposition */
SCIP_DECL_BENDERSEXIT ((*bendersexit)), /**< deinitialize Benders' decomposition */
SCIP_DECL_BENDERSINITPRE((*bendersinitpre)),/**< presolving initialization method for Benders' decomposition */
SCIP_DECL_BENDERSEXITPRE((*bendersexitpre)),/**< presolving deinitialization method for Benders' decomposition */
SCIP_DECL_BENDERSINITSOL((*bendersinitsol)),/**< solving process initialization method of Benders' decomposition */
SCIP_DECL_BENDERSEXITSOL((*bendersexitsol)),/**< solving process deinitialization method of Benders' decomposition */
SCIP_DECL_BENDERSGETVAR((*bendersgetvar)),/**< returns the master variable for a given subproblem variable */
SCIP_DECL_BENDERSCREATESUB((*benderscreatesub)),/**< creates a Benders' decomposition subproblem */
SCIP_DECL_BENDERSPRESUBSOLVE((*benderspresubsolve)),/**< called prior to the subproblem solving loop */
SCIP_DECL_BENDERSSOLVESUBCONVEX((*benderssolvesubconvex)),/**< the solving method for convex Benders' decomposition subproblems */
SCIP_DECL_BENDERSSOLVESUB((*benderssolvesub)),/**< the solving method for the Benders' decomposition subproblems */
SCIP_DECL_BENDERSPOSTSOLVE((*benderspostsolve)),/**< called after the subproblems are solved. */
SCIP_DECL_BENDERSFREESUB((*bendersfreesub)),/**< the freeing method for the Benders' decomposition subproblems */
SCIP_BENDERSDATA* bendersdata /**< Benders' decomposition data */
);
/** calls destructor and frees memory of Benders' decomposition */
SCIP_RETCODE SCIPbendersFree(
SCIP_BENDERS** benders, /**< pointer to Benders' decomposition data structure */
SCIP_SET* set /**< global SCIP settings */
);
/** initializes Benders' decomposition */
SCIP_RETCODE SCIPbendersInit(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set /**< global SCIP settings */
);
/** calls exit method of Benders' decomposition */
SCIP_RETCODE SCIPbendersExit(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set /**< global SCIP settings */
);
/** informs the Benders' decomposition that the presolving process is being started */
SCIP_RETCODE SCIPbendersInitpre(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set, /**< global SCIP settings */
SCIP_STAT* stat /**< dynamic problem statistics */
);
/** informs the Benders' decomposition that the presolving process has completed */
SCIP_RETCODE SCIPbendersExitpre(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set, /**< global SCIP settings */
SCIP_STAT* stat /**< dynamic problem statistics */
);
/** informs Benders' decomposition that the branch and bound process is being started */
SCIP_RETCODE SCIPbendersInitsol(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set /**< global SCIP settings */
);
/** informs Benders' decomposition that the branch and bound process data is being freed */
SCIP_RETCODE SCIPbendersExitsol(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set /**< global SCIP settings */
);
/** activates Benders' decomposition such that it is called in LP solving loop */
SCIP_RETCODE SCIPbendersActivate(
SCIP_BENDERS* benders, /**< the Benders' decomposition structure */
SCIP_SET* set, /**< global SCIP settings */
int nsubproblems /**< the number subproblems used in this decomposition */
);
/** deactivates Benders' decomposition such that it is no longer called in LP solving loop */
SCIP_RETCODE SCIPbendersDeactivate(
SCIP_BENDERS* benders, /**< the Benders' decomposition structure */
SCIP_SET* set /**< global SCIP settings */
);
/** enables or disables all clocks of Benders' decomposition depending on the value of the flag */
void SCIPbendersEnableOrDisableClocks(
SCIP_BENDERS* benders, /**< the Benders' decomposition for which all clocks should be enabled or disabled */
SCIP_Bool enable /**< should the clocks of the Benders' decomposition be enabled? */
);
/** solves the subproblem using the current master problem solution.
*
* The checkint flag indicates whether integer feasibility can be assumed. If it is not assumed, i.e. checkint ==
* FALSE, then only the convex relaxations of the subproblems are solved. If integer feasibility is assumed, i.e.
* checkint == TRUE, then the convex relaxations and the full CIP are solved to generate Benders' cuts and check
* solution feasibility.
*/
SCIP_RETCODE SCIPbendersExec(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set, /**< global SCIP settings */
SCIP_SOL* sol, /**< primal CIP solution */
SCIP_RESULT* result, /**< result of the pricing process */
SCIP_Bool* infeasible, /**< is the master problem infeasible with respect to the Benders' cuts? */
SCIP_Bool* auxviol, /**< set to TRUE only if the solution is feasible but the aux vars are violated */
SCIP_BENDERSENFOTYPE type, /**< the type of solution being enforced */
SCIP_Bool checkint /**< should the integer solution be checked by the subproblems */
);
/** Executes the subproblem solving process. */
SCIP_RETCODE SCIPbendersExecSubproblemSolve(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set, /**< global SCIP settings */
SCIP_SOL* sol, /**< primal CIP solution */
int probnum, /**< the subproblem number */
SCIP_BENDERSSOLVELOOP solveloop, /**< the solve loop iteration. The first iter is for LP, the second for IP */
SCIP_Bool enhancement, /**< is the solve performed as part of an enhancement? */
SCIP_Bool* solved, /**< flag to indicate whether the subproblem was solved */
SCIP_Bool* infeasible, /**< returns whether the current subproblem is infeasible */
SCIP_BENDERSENFOTYPE type /**< the enforcement type calling this function */
);
/** sets up the subproblem using the solution to the master problem */
SCIP_RETCODE SCIPbendersSetupSubproblem(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set, /**< global SCIP settings */
SCIP_SOL* sol, /**< primal CIP solution */
int probnumber, /**< the subproblem number */
SCIP_BENDERSENFOTYPE type /**< the enforcement type calling this function */
);
/** Solve a Benders' decomposition subproblems. This will either call the user defined method or the generic solving
* methods. If the generic method is called, then the subproblem must be set up before calling this method. */
SCIP_RETCODE SCIPbendersSolveSubproblem(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set, /**< global SCIP settings */
SCIP_SOL* sol, /**< primal CIP solution, can be NULL */
int probnumber, /**< the subproblem number */
SCIP_Bool* infeasible, /**< returns whether the current subproblem is infeasible */
SCIP_Bool solvecip, /**< directly solve the CIP subproblem */
SCIP_Real* objective /**< the objective function value of the subproblem, can be NULL */
);
/** frees the subproblems */
SCIP_RETCODE SCIPbendersFreeSubproblem(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set, /**< global SCIP settings */
int probnumber /**< the subproblem number */
);
/** compares the subproblem objective value with the auxiliary variable value for optimality */
SCIP_Bool SCIPbendersSubproblemIsOptimal(
SCIP_BENDERS* benders, /**< the benders' decomposition structure */
SCIP_SET* set, /**< global SCIP settings */
SCIP_SOL* sol, /**< primal CIP solution */
int probnumber /**< the subproblem number */
);
/** returns the value of the auxiliary variable value in a master problem solution */
SCIP_Real SCIPbendersGetAuxiliaryVarVal(
SCIP_BENDERS* benders, /**< the benders' decomposition structure */
SCIP_SET* set, /**< global SCIP settings */
SCIP_SOL* sol, /**< primal CIP solution */
int probnumber /**< the subproblem number */
);
/** Solves an independent subproblem to identify its lower bound. The lower bound is then used to update the bound on
* the auxiliary variable.
*/
SCIP_RETCODE SCIPbendersComputeSubproblemLowerbound(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set, /**< global SCIP settings */
int probnumber, /**< the subproblem to be evaluated */
SCIP_Real* lowerbound, /**< the lowerbound for the subproblem */
SCIP_Bool* infeasible /**< was the subproblem found to be infeasible? */
);
/** merges a subproblem into the master problem. This process just adds a copy of the subproblem variables and
* constraints to the master problem, but keeps the subproblem stored in the Benders' decomposition data structure.
* The reason for keeping the subproblem available is for when it is queried for solutions after the problem is solved.
*
* Once the subproblem is merged into the master problem, then the subproblem is flagged as disabled. This means that
* it will not be solved in the subsequent subproblem solving loops.
*
* The associated auxiliary variables are kept in the master problem. The objective function of the merged subproblem
* is added as an underestimator constraint.
*/
SCIP_RETCODE SCIPbendersMergeSubproblemIntoMaster(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set, /**< global SCIP settings */
SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of subproblem variables corresponding
* to the newly created master variables, or NULL */
SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of subproblem constraints to the
corresponding newly created constraints, or NULL */
int probnumber /**< the number of the subproblem that will be merged into the master problem*/
);
/** Applies a Benders' decomposition to the problem based upon the decomposition selected from the storage */
extern
SCIP_RETCODE SCIPbendersApplyDecomposition(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set, /**< global SCIP settings */
SCIP_DECOMP* decomp /**< the decomposition to apply to the problem */
);
/** sets priority of Benders' decomposition */
void SCIPbendersSetPriority(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set, /**< global SCIP settings */
int priority /**< new priority of the Benders' decomposition */
);
/** sets copy callback of Benders' decomposition */
void SCIPbendersSetCopy(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_DECL_BENDERSCOPY ((*benderscopy)) /**< copy callback of Benders' decomposition */
);
/** sets destructor callback of Benders' decomposition */
void SCIPbendersSetFree(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_DECL_BENDERSFREE ((*bendersfree)) /**< destructor of Benders' decomposition */
);
/** sets initialization callback of Benders' decomposition */
void SCIPbendersSetInit(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_DECL_BENDERSINIT((*bendersinit)) /**< initialize Benders' decomposition */
);
/** sets deinitialization callback of Benders' decomposition */
void SCIPbendersSetExit(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_DECL_BENDERSEXIT((*bendersexit)) /**< deinitialize Benders' decomposition */
);
/** sets presolving initialization callback of Benders' decomposition */
void SCIPbendersSetInitpre(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_DECL_BENDERSINITPRE((*bendersinitpre))/**< initialize presolving for Benders' decomposition */
);
/** sets presolving deinitialization callback of Benders' decomposition */
void SCIPbendersSetExitpre(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_DECL_BENDERSEXITPRE((*bendersexitpre))/**< deinitialize presolving for Benders' decomposition */
);
/** sets solving process initialization callback of Benders' decomposition */
void SCIPbendersSetInitsol(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_DECL_BENDERSINITSOL((*bendersinitsol))/**< solving process initialization callback of Benders' decomposition */
);
/** sets solving process deinitialization callback of Benders' decomposition */
void SCIPbendersSetExitsol(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_DECL_BENDERSEXITSOL((*bendersexitsol))/**< solving process deinitialization callback of Benders' decomposition */
);
/** sets the pre subproblem solve callback of Benders' decomposition */
void SCIPbendersSetPresubsolve(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_DECL_BENDERSPRESUBSOLVE((*benderspresubsolve))/**< called prior to the subproblem solving loop */
);
/** sets convex solve callback of Benders' decomposition */
void SCIPbendersSetSolvesubconvex(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_DECL_BENDERSSOLVESUBCONVEX((*benderssolvesubconvex))/**< solving method for the convex Benders' decomposition subproblem */
);
/** sets solve callback of Benders' decomposition */
void SCIPbendersSetSolvesub(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_DECL_BENDERSSOLVESUB((*benderssolvesub))/**< solving method for a Benders' decomposition subproblem */
);
/** sets post-solve callback of Benders' decomposition */
void SCIPbendersSetPostsolve(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_DECL_BENDERSPOSTSOLVE((*benderspostsolve))/**< solving process deinitialization callback of Benders' decomposition */
);
/** sets post-solve callback of Benders' decomposition */
void SCIPbendersSetSubproblemComp(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_DECL_SORTPTRCOMP((*benderssubcomp)) /**< a comparator for defining the solving order of the subproblems */
);
/** sets free subproblem callback of Benders' decomposition */
void SCIPbendersSetFreesub(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_DECL_BENDERSFREESUB((*bendersfreesub))/**< the freeing callback for the subproblem */
);
/** Returns the corresponding master or subproblem variable for the given variable.
* This provides a call back for the variable mapping between the master and subproblems. */
SCIP_RETCODE SCIPbendersGetVar(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set, /**< global SCIP settings */
SCIP_VAR* var, /**< the variable for which the corresponding variable is desired */
SCIP_VAR** mappedvar, /**< the variable that is mapped to var */
int probnumber /**< the problem number for the desired variable, -1 for the master problem */
);
/** adds a subproblem to the Benders' decomposition data */
SCIP_RETCODE SCIPbendersAddSubproblem(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP* subproblem /**< subproblem to be added to the data storage */
);
/** removes the subproblems from the Benders' decomposition data */
void SCIPbendersRemoveSubproblems(
SCIP_BENDERS* benders /**< Benders' decomposition */
);
/** Sets whether the subproblem is enabled or disabled. A subproblem is disabled if it has been merged into the master
* problem.
*/
void SCIPbendersSetSubproblemEnabled(
SCIP_BENDERS* benders, /**< Benders' decomposition */
int probnumber, /**< the subproblem number */
SCIP_Bool enabled /**< flag to indicate whether the subproblem is enabled */
);
/** changes all of the master problem variables in the given subproblem to continuous */
SCIP_RETCODE SCIPbendersChgMastervarsToCont(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SET* set, /**< global SCIP settings */
int probnumber /**< the subproblem number */
);
/** sets a flag to indicate whether the master variables are all set to continuous */
SCIP_RETCODE SCIPbendersSetMastervarsCont(
SCIP_BENDERS* benders, /**< Benders' decomposition */
int probnumber, /**< the subproblem number */
SCIP_Bool arecont /**< flag to indicate whether the master problem variables are continuous */
);
/** returns whether the master variables are all set to continuous */
SCIP_Bool SCIPbendersGetMastervarsCont(
SCIP_BENDERS* benders, /**< Benders' decomposition */
int probnumber /**< the subproblem number */
);
/** adds the data for the generated cuts to the Benders' cut storage */
SCIP_RETCODE SCIPbendersStoreCut(
SCIP_BENDERS* benders, /**< Benders' decomposition cut */
SCIP_SET* set, /**< global SCIP settings */
SCIP_VAR** vars, /**< the variables that have non-zero coefficients in the cut */
SCIP_Real* vals, /**< the coefficients of the variables in the cut */
SCIP_Real lhs, /**< the left hand side of the cut */
SCIP_Real rhs, /**< the right hand side of the cut */
int nvars /**< the number of variables with non-zero coefficients in the cut */
);
/** inserts a Benders' cut algorithm plugin into the Benders' cuts plugin list */
SCIP_RETCODE SCIPbendersIncludeBenderscut(
SCIP_BENDERS* benders, /**< Benders' decomposition structure */
SCIP_SET* set, /**< global SCIP settings */
SCIP_BENDERSCUT* benderscut /**< Benders' cut */
);
/** sets the Benders' cuts sorted flags in the Benders' decomposition */
void SCIPbendersSetBenderscutsSorted(
SCIP_BENDERS* benders, /**< Benders' decomposition structure */
SCIP_Bool sorted /**< the value to set the sorted flag to */
);
/** sorts Benders' decomposition cuts by priorities */
void SCIPbendersSortBenderscuts(
SCIP_BENDERS* benders /**< Benders' decomposition */
);
/** sorts Benders' decomposition cuts by name */
void SCIPbendersSortBenderscutsName(
SCIP_BENDERS* benders /**< Benders' decomposition */
);
#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 benders_default.h
* @ingroup BENDERSDECOMPOSITION
* @brief default Benders' decomposition plugin
* @author Stephen J. Maher
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BENDERS_DEFAULT_H__
#define __SCIP_BENDERS_DEFAULT_H__
#include "scip/def.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the default Benders' decomposition and includes it in SCIP
*
* @ingroup BendersIncludes
*/
SCIP_EXPORT
SCIP_RETCODE SCIPincludeBendersDefault(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup BENDERS
*
* @{
*/
/** Creates a default Benders' decomposition algorithm and activates it in SCIP */
SCIP_EXPORT
SCIP_RETCODE SCIPcreateBendersDefault(
SCIP* scip, /**< SCIP data structure */
SCIP** subproblems, /**< the Benders' decomposition subproblems */
int nsubproblems /**< the number of subproblems in the Benders' decomposition */
);
/** @} */
#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 benders_xyz.h
* @ingroup BENDERSDECOMPOSITION
* @brief xyz Benders' decomposition
* @author Stephen J. Maher
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BENDERS_XYZ_H__
#define __SCIP_BENDERS_XYZ_H__
#include "scip/scip.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the xyz Benders' decomposition and includes it in SCIP
*
* @ingroup BendersIncludes
*/
SCIP_EXPORT
SCIP_RETCODE SCIPincludeBendersXyz(
SCIP* scip /**< SCIP data structure */
);
/**@addtogroup BENDERSS
*
* @{
*/
/** TODO: add public methods to this group for documentation purposes */
/** @} */
#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 benderscut.h
* @ingroup INTERNALAPI
* @brief internal methods for Benders' decomposition cuts
* @author Stephen J. Maher
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BENDERSCUT_H__
#define __SCIP_BENDERSCUT_H__
#include "scip/def.h"
#include "blockmemshell/memory.h"
#include "scip/type_retcode.h"
#include "scip/type_result.h"
#include "scip/type_set.h"
#include "scip/type_benderscut.h"
#include "scip/type_benders.h"
#include "scip/pub_benderscut.h"
#ifdef __cplusplus
extern "C" {
#endif
/** copies the given Benders' decomposition cut to a new scip */
SCIP_RETCODE SCIPbenderscutCopyInclude(
SCIP_BENDERS* benders, /**< the Benders' decomposition that the cuts are copied to */
SCIP_BENDERSCUT* benderscut, /**< Benders' decomposition cut */
SCIP_SET* set /**< SCIP_SET of SCIP to copy to */
);
/** creates a Benders' decomposition cut */
SCIP_RETCODE SCIPbenderscutCreate(
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_BENDERSCUT** benderscut, /**< pointer to the Benders' decomposition cut data structure */
SCIP_SET* set, /**< global SCIP settings */
SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
const char* name, /**< name of the Benders' decomposition cut */
const char* desc, /**< description of the Benders' decomposition cut */
int priority, /**< priority of the Benders' decomposition cut */
SCIP_Bool islpcut, /**< indicates whether the cut is generated from the LP solution */
SCIP_DECL_BENDERSCUTCOPY((*benderscutcopy)),/**< copy method of the Benders' decomposition cut or NULL if you don't want to copy your plugin into sub-SCIPs */
SCIP_DECL_BENDERSCUTFREE((*benderscutfree)),/**< destructor of the Benders' decomposition cut */
SCIP_DECL_BENDERSCUTINIT((*benderscutinit)),/**< initialize Benders' decomposition cut */
SCIP_DECL_BENDERSCUTEXIT((*benderscutexit)),/**< deinitialize Benders' decomposition cut */
SCIP_DECL_BENDERSCUTINITSOL((*benderscutinitsol)),/**< solving process initialization method of the Benders' decomposition cut */
SCIP_DECL_BENDERSCUTEXITSOL((*benderscutexitsol)),/**< solving process deinitialization method of the Benders' decomposition cut */
SCIP_DECL_BENDERSCUTEXEC((*benderscutexec)),/**< execution method of the Benders' decomposition cut */
SCIP_BENDERSCUTDATA* benderscutdata /**< Benders' decomposition cut data */
);
/** calls destructor and frees memory of the Benders' decomposition cut */
SCIP_RETCODE SCIPbenderscutFree(
SCIP_BENDERSCUT** benderscut, /**< pointer to the Benders' decomposition cut data structure */
SCIP_SET* set /**< global SCIP settings */
);
/** initializes the Benders' decomposition cut */
SCIP_RETCODE SCIPbenderscutInit(
SCIP_BENDERSCUT* benderscut, /**< the Benders' decomposition cut */
SCIP_SET* set /**< global SCIP settings */
);
/** calls exit method of the Benders' decomposition cut */
SCIP_RETCODE SCIPbenderscutExit(
SCIP_BENDERSCUT* benderscut, /**< Benders' decomposition cut */
SCIP_SET* set /**< global SCIP settings */
);
/** informs the Benders' decomposition cut that the branch and bound process is being started */
SCIP_RETCODE SCIPbenderscutInitsol(
SCIP_BENDERSCUT* benderscut, /**< Benders' decomposition cut */
SCIP_SET* set /**< global SCIP settings */
);
/** informs the Benders' decomposition cut that the branch and bound process data is being freed */
SCIP_RETCODE SCIPbenderscutExitsol(
SCIP_BENDERSCUT* benderscut, /**< Benders' decomposition cut */
SCIP_SET* set /**< global SCIP settings */
);
/** calls execution method of the Benders' decomposition cut */
SCIP_RETCODE SCIPbenderscutExec(
SCIP_BENDERSCUT* benderscut, /**< Benders' decomposition cut */
SCIP_SET* set, /**< global SCIP settings */
SCIP_BENDERS* benders, /**< Benders' decomposition */
SCIP_SOL* sol, /**< primal CIP solution */
int probnumber, /**< the number of the subproblem for which the cut is generated */
SCIP_BENDERSENFOTYPE type, /**< the enforcement type calling this function */
SCIP_RESULT* result /**< pointer to store the result of the callback method */
);
/** sets priority of the Benders' decomposition cut */
void SCIPbenderscutSetPriority(
SCIP_BENDERSCUT* benderscut, /**< Benders' decomposition cut */
int priority /**< new priority of the Benders' decomposition cut */
);
/** sets copy callback of the Benders' decomposition cut */
void SCIPbenderscutSetCopy(
SCIP_BENDERSCUT* benderscut, /**< Benders' decomposition cut */
SCIP_DECL_BENDERSCUTCOPY((*benderscutcopy))/**< copy callback of the Benders' decomposition cut or NULL if you don't want to copy your plugin into sub-SCIPs */
);
/** sets destructor callback of the Benders' decomposition cut */
void SCIPbenderscutSetFree(
SCIP_BENDERSCUT* benderscut, /**< Benders' decomposition cut */
SCIP_DECL_BENDERSCUTFREE((*benderscutfree))/**< destructor of the Benders' decomposition cut */
);
/** sets initialization callback of the Benders' decomposition cut */
void SCIPbenderscutSetInit(
SCIP_BENDERSCUT* benderscut, /**< Benders' decomposition cut */
SCIP_DECL_BENDERSCUTINIT((*benderscutinit))/**< initialize the Benders' decomposition cut */
);
/** sets deinitialization callback of the Benders' decomposition cut */
void SCIPbenderscutSetExit(
SCIP_BENDERSCUT* benderscut, /**< Benders' decomposition cut */
SCIP_DECL_BENDERSCUTEXIT((*benderscutexit))/**< deinitialize the Benders' decomposition cut */
);
/** sets solving process initialization callback of the Benders' decomposition cut */
void SCIPbenderscutSetInitsol(
SCIP_BENDERSCUT* benderscut, /**< Benders' decomposition cut */
SCIP_DECL_BENDERSCUTINITSOL((*benderscutinitsol))/**< solving process initialization callback of the Benders' decomposition cut */
);
/** sets solving process deinitialization callback of the Benders' decomposition cut */
void SCIPbenderscutSetExitsol(
SCIP_BENDERSCUT* benderscut, /**< the Benders' decomposition cut */
SCIP_DECL_BENDERSCUTEXITSOL((*benderscutexitsol))/**< solving process deinitialization callback of the Benders' decomposition cut */
);
#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 benderscut_feas.h
* @ingroup BENDERSCUTS
* @brief Standard feasibility cuts for Benders' decomposition
* @author Stephen J. Maher
*
* The classical Benders' decomposition feasibility cuts arise from an infeasible instance of the Benders' decomposition
* subproblem.
* Consider the linear Benders' decomposition subproblem that takes the master problem solution \f$\bar{x}\f$ as input:
* \f[
* z(\bar{x}) = \min\{d^{T}y : Ty \geq h - H\bar{x}, y \geq 0\}
* \f]
* If the subproblem is infeasible as a result of the solution \f$\bar{x}\f$, then the Benders' decomposition
* feasibility cut can be generated from the dual ray. Let \f$w\f$ be the vector corresponding to the dual ray of the
* Benders' decomposition subproblem. The resulting cut is:
* \f[
* 0 \geq w^{T}(h - Hx)
* \f]
*
* Next, consider the nonlinear Benders' decomposition subproblem that takes the master problem solution \f$\bar{x}\f$ as input:
* \f[
* z(\bar{x}) = \min\{d^{T}y : g(\bar{x}, y) \leq 0, y \geq 0\}
* \f]
* If the subproblem is infeasible as a result of the solution \f$\bar{x}\f$, then the Benders' decomposition
* feasibility cut can be generated from a minimal infeasible solution, i.e., a solution of the NLP
* \f[
* \min\left\{\sum_i u_i : g(\bar{x}, y) \leq u, y \geq 0, u \geq 0\right\}
* \f]
* Let \f$\bar{y}\f$, \f$w\f$ be the vectors corresponding to the primal and dual solution of this auxiliary NLP.
* The resulting cut is:
* \f[
* 0 \geq w^{T}\left(g(\bar{x},\bar{y}) + \nabla_x g(\bar{x},\bar{y}) (x - \bar{x})\right)
* \f]
* Note, that usually NLP solvers already provide a minimal infeasible solution when declaring the Benders'
* decomposition subproblem as infeasible.
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BENDERSCUT_FEAS_H__
#define __SCIP_BENDERSCUT_FEAS_H__
#include "scip/def.h"
#include "scip/type_benders.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the Standard Feasibility Benders' decomposition cuts and includes it in SCIP
*
* @ingroup BenderscutIncludes
*/
SCIP_EXPORT
SCIP_RETCODE SCIPincludeBenderscutFeas(
SCIP* scip, /**< SCIP data structure */
SCIP_BENDERS* benders /**< Benders' decomposition */
);
#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 benderscut_feasalt.h
* @ingroup BENDERSCUTS
* @brief Alternative feasibility cuts for Benders' decomposition
* @author Stephen J. Maher
*
* The alternative feasibility cut for Benders' decomposition uses the optimality cut generation code to generate a cut
* that minimises the violation of the constraints.
* Consider the linear Benders' decomposition subproblem that takes the master problem solution \f$\bar{x}\f$ as input:
* \f[
* z(\bar{x}) = \min\{d^{T}y : Ty \geq h - H\bar{x}, y \geq 0\}
* \f]
* If the subproblem is infeasible as a result of the solution \f$\bar{x}\f$, then some of the constraints are violated.
* In this case, we define an alternative/auxiliary subproblem to find a solution that minimises the constraint
* violations. Such a problem is given by
* \f[
* \min\{\mathbb{1}{T}v : Ty + v \geq h - H\bar{x}, y \geq 0, v \geq 0\}
* \f]
*
* This auxiliary problem is guaranteed to always be feasible. Given a solution to this problem, it is possible to
* generate a classical Benders' optimality cut. For such a cut, the reader is referred to \ref benderscut_opt.h.
*
* If the Benders' decomposition subproblem contains non-linear constraints, an equivalent auxiliary subproblem can be
* formed to generate an alternative feasibility cut.
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BENDERSCUT_FEASALT_H__
#define __SCIP_BENDERSCUT_FEASALT_H__
#include "scip/def.h"
#include "scip/type_benders.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the Alternative Feasibility Benders' decomposition cuts and includes it in SCIP
*
* @ingroup BenderscutIncludes
*/
SCIP_EXPORT
SCIP_RETCODE SCIPincludeBenderscutFeasalt(
SCIP* scip, /**< SCIP data structure */
SCIP_BENDERS* benders /**< Benders' decomposition */
);
#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 benderscut_int.h
* @ingroup BENDERSCUTS
* @brief Generates a Laporte and Louveaux Benders' decomposition integer cut
* @author Stephen J. Maher
*
* The classical Benders' decomposition algorithm is only applicable to problems with continuous second stage variables.
* Laporte and Louveaux (1993) developed a method for generating cuts when Benders' decomposition is applied to problem
* with discrete second stage variables. However, these cuts are only applicable when the master problem is a pure
* binary problem.
*
* The integer optimality cuts are a point-wise underestimator of the optimal subproblem objective function value.
* Similar to benderscuts_opt.c, an auxiliary variable, \f$\varphi\f$. is required in the master problem as a lower
* bound on the optimal objective function value for the Benders' decomposition subproblem.
*
* Consider the Benders' decomposition subproblem that takes the master problem solution \f$\bar{x}\f$ as input:
* \f[
* z(\bar{x}) = \min\{d^{T}y : Ty \geq h - H\bar{x}, y \mbox{ integer}\}
* \f]
* If the subproblem is feasible, and \f$z(\bar{x}) > \varphi\f$ (indicating that the current underestimators are not
* optimal) then the Benders' decomposition integer optimality cut can be generated from the optimal solution of the
* subproblem. Let \f$S_{r}\f$ be the set of indicies for master problem variables that are 1 in \f$\bar{x}\f$ and
* \f$L\f$ a known lowerbound on the subproblem objective function value.
*
* The resulting cut is:
* \f[
* \varphi \geq (z(\bar{x}) - L)(\sum_{i \in S_{r}}(x_{i} - 1) + \sum_{i \notin S_{r}}x_{i} + 1)
* \f]
*
* Laporte, G. & Louveaux, F. V. The integer L-shaped method for stochastic integer programs with complete recourse
* Operations Research Letters, 1993, 13, 133-142
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BENDERSCUT_INT_H__
#define __SCIP_BENDERSCUT_INT_H__
#include "scip/def.h"
#include "scip/type_benders.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the integer optimality cut for Benders' decomposition cut and includes it in SCIP
*
* @ingroup BenderscutIncludes
*/
SCIP_EXPORT
SCIP_RETCODE SCIPincludeBenderscutInt(
SCIP* scip, /**< SCIP data structure */
SCIP_BENDERS* benders /**< Benders' decomposition */
);
#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 benderscut_nogood.h
* @ingroup BENDERSCUTS
* @brief Generates a no-good cut for solutions that are integer infeasible
* @author Stephen J. Maher
*
* The no-good cut is generated for the Benders' decomposition master problem if an integer solution is identified as
* infeasible in at least one CIP subproblems. The no-good cut is required, because the classical Benders' decomposition
* feasibility cuts (see benderscut_feas.c) will only cut off the solution \f$\bar{x}\f$ if the LP relaxation of the CIP
* is infeasible.
*
* Consider a Benders' decomposition subproblem that is a CIP and it infeasible. Let \f$S_{r}\f$ be the set of indices
* for master problem variables that are 1 in \f$\bar{x}\f$. The no-good cut is given by
*
* \f[
* 1 \leq \sum_{i \in S_{r}}(1 - x_{i}) + \sum_{i \notin S_{r}}x_{i}
* \f]
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BENDERSCUT_NOGOOD_H__
#define __SCIP_BENDERSCUT_NOGOOD_H__
#include "scip/def.h"
#include "scip/type_benders.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the no good Benders' decomposition cut and includes it in SCIP
*
* @ingroup BenderscutIncludes
*/
SCIP_EXPORT
SCIP_RETCODE SCIPincludeBenderscutNogood(
SCIP* scip, /**< SCIP data structure */
SCIP_BENDERS* benders /**< Benders' decomposition */
);
#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 benderscut_opt.h
* @ingroup BENDERSCUTS
* @brief Generates a standard Benders' decomposition optimality cut
* @author Stephen J. Maher
*
* The classical Benders' decomposition optimality cuts arise from a feasible instance of the Benders' decomposition
* subproblem. The optimality cuts are an underestimator of the subproblem objective function value. Auxiliary
* variables, \f$\varphi\f$ are added to the master problem as a lower bound on the subproblem objective function value.
*
* Consider a linear Benders' decomposition subproblem that takes the master problem solution \f$\bar{x}\f$ as input:
* \f[
* z(\bar{x}) = \min\{d^{T}y : Ty \geq h - H\bar{x}, y \geq 0\}
* \f]
* If the subproblem is feasible, and \f$z(\bar{x}) > \varphi\f$ (indicating that the current underestimators are not
* optimal) then the Benders' decomposition optimality cut can be generated from the optimal dual solution of the
* subproblem. Let \f$w\f$ be the vector corresponding to the optimal dual solution of the Benders' decomposition
* subproblem. The resulting cut is:
* \f[
* \varphi \geq w^{T}(h - Hx)
* \f]
*
* Next, consider a nonlinear Benders' decomposition subproblem that takes the master problem solution \f$\bar{x}\f$ as input:
* \f[
* z(\bar{x}) = \min\{d^{T}y : g(\bar{x},y) \leq 0, y \geq 0\}
* \f]
* If the subproblem is feasible, and \f$z(\bar{x}) > \varphi\f$ (indicating that the current underestimators are not
* optimal) then the Benders' decomposition optimality cut can be generated from the optimal dual solution of the
* subproblem. Let \f$w\f$ be the vector corresponding to the optimal dual solution of the Benders' decomposition subproblem.
* The resulting cut is:
* \f[
* \varphi \geq z(\bar{x}) + w^{T} \nabla_x g(\bar{x}, y) (x-\bar{x})
* \f]
*
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BENDERSCUT_OPT_H__
#define __SCIP_BENDERSCUT_OPT_H__
#include "scip/def.h"
#include "scip/type_benders.h"
#include "scip/type_benderscut.h"
#include "scip/type_cons.h"
#include "scip/type_lp.h"
#include "scip/type_misc.h"
#include "scip/type_nlp.h"
#include "scip/type_retcode.h"
#include "scip/type_scip.h"
#include "nlpi/type_exprinterpret.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the optimality Benders' decomposition cut and includes it in SCIP
*
* @addtogroup BenderscutIncludes
* @{
*/
SCIP_EXPORT
SCIP_RETCODE SCIPincludeBenderscutOpt(
SCIP* scip, /**< SCIP data structure */
SCIP_BENDERS* benders /**< Benders' decomposition */
);
/** Generates a classical Benders' optimality cut using the dual solutions from the subproblem or the input arrays. If
* the dual solutions are input as arrays, then a mapping between the array indices and the rows/variables is required.
* This method can also be used to generate a feasiblity, is a problem to minimise the infeasibilities has been solved
* to generate the dual solutions
*/
SCIP_EXPORT
SCIP_RETCODE SCIPgenerateAndApplyBendersOptCut(
SCIP* masterprob, /**< the SCIP instance of the master problem */
SCIP* subproblem, /**< the SCIP instance of the pricing problem */
SCIP_BENDERS* benders, /**< the benders' decomposition */
SCIP_BENDERSCUT* benderscut, /**< the benders' decomposition cut method */
SCIP_SOL* sol, /**< primal CIP solution */
int probnumber, /**< the number of the pricing problem */
char* cutname, /**< the name for the cut to be generated */
SCIP_Real objective, /**< the objective function of the subproblem */
SCIP_Real* primalvals, /**< the primal solutions for the NLP, can be NULL */
SCIP_Real* consdualvals, /**< dual variables for the constraints, can be NULL */
SCIP_Real* varlbdualvals, /**< the dual variables for the variable lower bounds, can be NULL */
SCIP_Real* varubdualvals, /**< the dual variables for the variable upper bounds, can be NULL */
SCIP_HASHMAP* row2idx, /**< mapping between the row in the subproblem to the index in the dual array, can be NULL */
SCIP_HASHMAP* var2idx, /**< mapping from variable of the subproblem to the index in the dual arrays, can be NULL */
SCIP_BENDERSENFOTYPE type, /**< the enforcement type calling this function */
SCIP_Bool addcut, /**< should the Benders' cut be added as a cut or constraint */
SCIP_Bool feasibilitycut, /**< is this called for the generation of a feasibility cut */
SCIP_RESULT* result /**< the result from solving the subproblems */
);
/** adds the gradient of a nonlinear row in the current NLP solution of a subproblem to a linear row or constraint in the master problem
*
* Only computes gradient w.r.t. master problem variables.
* Computes also the directional derivative, that is, mult times gradient times solution.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPaddNlRowGradientBenderscutOpt(
SCIP* masterprob, /**< the SCIP instance of the master problem */
SCIP* subproblem, /**< the SCIP instance of the subproblem */
SCIP_BENDERS* benders, /**< the benders' decomposition structure */
SCIP_NLROW* nlrow, /**< nonlinear row */
SCIP_EXPRINT* exprint, /**< expressions interpreter */
SCIP_Real mult, /**< multiplier */
SCIP_Real* primalvals, /**< the primal solutions for the NLP, can be NULL */
SCIP_HASHMAP* var2idx, /**< mapping from variable of the subproblem to the index in the dual arrays, can be NULL */
SCIP_Real* dirderiv, /**< storage to add directional derivative */
SCIP_VAR*** vars, /**< pointer to array of variables in the generated cut with non-zero coefficient */
SCIP_Real** vals, /**< pointer to array of coefficients of the variables in the generated cut */
int* nvars, /**< the number of variables in the cut */
int* varssize /**< the number of variables in the array */
);
/** @} */
#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 benderscut_xyz.h
* @ingroup BENDERSCUTS
* @brief xyz Benders' decomposition cuts
* @author Stephen J. Maher
*
* template file for Benders' decomposition cut plugins
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BENDERSCUT_XYZ_H__
#define __SCIP_BENDERSCUT_XYZ_H__
#include "scip/scip.h"
#ifdef __cplusplus
extern "C" {
#endif
/** creates the xyz Benders' decomposition cut and includes it in SCIP
*
* @ingroup BenderscutIncludes
*/
SCIP_EXPORT
SCIP_RETCODE SCIPincludeBenderscutXyz(
SCIP* scip, /**< SCIP data structure */
SCIP_BENDERS* benders /**< Benders' decomposition 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 bendersdefcuts.c
* @brief default cuts for Benders' decomposition
* @author Stephen J. Maher
*/
/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#ifndef __SCIP_BENDERSDEFCUTS_H__
#define __SCIP_BENDERSDEFCUTS_H__
/* include header files here, such that the user only has to include bendersdefcuts.h */
#include "scip/benderscut_feas.h"
#include "scip/benderscut_feasalt.h"
#include "scip/benderscut_int.h"
#include "scip/benderscut_nogood.h"
#include "scip/benderscut_opt.h"
#ifdef __cplusplus
extern "C" {
#endif
/** includes default Benders' decomposition cuts plugins into SCIP and the associated Benders' decomposition */
SCIP_EXPORT
SCIP_RETCODE SCIPincludeBendersDefaultCuts(
SCIP* scip, /**< SCIP data structure */
SCIP_BENDERS* benders /**< Benders' decomposition struture */
);
#ifdef __cplusplus
}
#endif
#endif