Don't import ogdf namespace
[TortoiseGit.git] / ext / OGDF / ogdf / external / coin.h
blob6b5c6993c182db8a8f48733b2552cf79671694ae
1 /*
2 * $Revision: 2614 $
4 * last checkin:
5 * $Author: chimani $
6 * $Date: 2012-07-16 11:30:08 +0200 (Mo, 16. Jul 2012) $
7 ***************************************************************/
9 /** \file
10 * \brief Handles connection to the COIN library, by offering
11 * helper classes.
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
23 * \par License:
24 * This file is part of the Open Graph Drawing Framework (OGDF).
26 * \par
27 * Copyright (C)<br>
28 * See README.txt in the root directory of the OGDF installation for details.
30 * \par
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
35 * for details.
37 * \par
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.
43 * \par
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 ***************************************************************/
52 #ifndef OGDF_COINY_H
53 #define OGDF_COINY_H
55 #include <ogdf/basic/basic.h>
58 #ifndef USE_COIN
60 #define THROW_NO_COIN_EXCEPTION OGDF_THROW_PARAM(LibraryNotSupportedException, lnscCoin)
62 namespace ogdf {
63 class CoinCallbacks {};
66 #else // USE_COIN
68 #define OGDF_THROW_NO_CALLBACK_EXCEPTION
70 #include <coin/OsiSolverInterface.hpp>
71 #include <coin/CoinPackedVector.hpp>
73 namespace ogdf {
75 class OGDF_EXPORT CoinCallbacks {
76 friend class OGDF_EXPORT CoinManager;
77 public:
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; };
87 private:
88 bool registerCallbacks(OsiSolverInterface* _posi, int callbackTypes);
91 class OGDF_EXPORT CoinManager {
92 public:
93 static OsiSolverInterface* createCorrectOsiSolverInterface();
94 static OsiSolverInterface* createCorrectOsiSolverInterface(CoinCallbacks* ccc, int callbackTypes) {
95 OsiSolverInterface* posi = createCorrectOsiSolverInterface();
96 if(ccc->registerCallbacks(posi, callbackTypes))
97 return posi;
98 delete posi;
99 return NULL;
101 static void logging(OsiSolverInterface* osi, bool logMe);
107 #endif // USE_COIN
109 #endif // OGDF_COINY_H