6 * $Date: 2012-07-16 11:30:08 +0200 (Mo, 16. Jul 2012) $
7 ***************************************************************/
10 * \brief Handles connection to the COIN library, by offering
13 * If you use Coin, you need to include this file. Please follow
14 * the example of CoinOptimalCrossingMinimizer for the correct use
15 * of the USE_COIN precompiler flag.
17 * \todo Currently, there is only a single implementation of the
18 * CoinCallback-class declared herein (necc. for userdefined cuts).
19 * This implementation is CPLEX specific.
21 * \author Markus Chimani
24 * This file is part of the Open Graph Drawing Framework (OGDF).
28 * See README.txt in the root directory of the OGDF installation for details.
31 * This program is free software; you can redistribute it and/or
32 * modify it under the terms of the GNU General Public License
33 * Version 2 or 3 as published by the Free Software Foundation;
34 * see the file LICENSE.txt included in the packaging of this file
38 * This program is distributed in the hope that it will be useful,
39 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 * GNU General Public License for more details.
44 * You should have received a copy of the GNU General Public
45 * License along with this program; if not, write to the Free
46 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
47 * Boston, MA 02110-1301, USA.
49 * \see http://www.gnu.org/copyleft/gpl.html
50 ***************************************************************/
55 #include <ogdf/basic/basic.h>
60 #define THROW_NO_COIN_EXCEPTION OGDF_THROW_PARAM(LibraryNotSupportedException, lnscCoin)
63 class CoinCallbacks
{};
68 #define OGDF_THROW_NO_CALLBACK_EXCEPTION
70 #include <coin/OsiSolverInterface.hpp>
71 #include <coin/CoinPackedVector.hpp>
75 class OGDF_EXPORT CoinCallbacks
{
76 friend class OGDF_EXPORT CoinManager
;
78 enum CallbackType
{ CT_Cut
= 1, CT_Heuristic
= 2, CT_Incumbent
= 4, CT_Branch
= 8 };
79 enum CutReturn
{ CR_Error
, CR_SolutionValid
, CR_AddCuts
, CR_DontAddCuts
, CR_NoCutsFound
};
80 enum HeuristicReturn
{ HR_Error
, HR_Ignore
, HR_Update
};
81 enum IncumbentReturn
{ IR_Error
, IR_Ignore
, IR_Update
};
82 // enum BranchReturn { BR_Error, ... };
83 virtual CutReturn
cutCallback(const double /* objValue */, const double* /* fracSolution */, OsiCuts
* /* addThese */) { OGDF_THROW_NO_CALLBACK_EXCEPTION
; return CR_Error
; }
84 virtual HeuristicReturn
heuristicCallback(double& /* objValue */, double* /* solution */) { OGDF_THROW_NO_CALLBACK_EXCEPTION
; return HR_Error
; }
85 virtual IncumbentReturn
incumbentCallback(const double /* objValue */, const double* /* solution */) { OGDF_THROW_NO_CALLBACK_EXCEPTION
; return IR_Error
; }
86 // virtual BranchReturn branchCallback() { OGDF_THROW_NO_CALLBACK_EXCEPTION; return BR_Error; };
88 bool registerCallbacks(OsiSolverInterface
* _posi
, int callbackTypes
);
91 class OGDF_EXPORT CoinManager
{
93 static OsiSolverInterface
* createCorrectOsiSolverInterface();
94 static OsiSolverInterface
* createCorrectOsiSolverInterface(CoinCallbacks
* ccc
, int callbackTypes
) {
95 OsiSolverInterface
* posi
= createCorrectOsiSolverInterface();
96 if(ccc
->registerCallbacks(posi
, callbackTypes
))
101 static void logging(OsiSolverInterface
* osi
, bool logMe
);
109 #endif // OGDF_COINY_H