1 /*!\file
2 * \author Matthias Elf
3 *
4 * \par License:
5 * This file is part of ABACUS - A Branch And CUt System
6 * Copyright (C) 1995 - 2003
7 * University of Cologne, Germany
8 *
9 * \par
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * \par
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * \par
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * \see http://www.gnu.org/copyleft/gpl.html
27 */
28
29 #include <ogdf/lib/abacus/infeascon.h>
30 #include <ogdf/lib/abacus/sub.h>
31
32 namespace abacus {
33
34
goodVar(const Variable * v) const35 bool InfeasCon::goodVar(const Variable *v) const
36 {
37 const double eps = master_->machineEps();
38
39 const bool pos = v->uBound() > eps;
40 const bool neg = v->lBound() < -eps;
41 const double c = constraint_->coeff(v);
42
43 if (infeas_ == TooSmall) {
44 if (c > eps && pos) return true;
45 if (c < -eps && neg) return true;
46 return false;
47 }
48 else if (infeas_ == TooLarge) {
49 if (c > eps && neg) return true;
50 if (c < -eps && pos) return true;
51 return false;
52 }
53 else {
54 Logger::ifout() << "InfeasCon::goodVar(): constraint is feasible\n";
55 OGDF_THROW_PARAM(AlgorithmFailureException, ogdf::AlgorithmFailureCode::InfeasCon);
56 }
57 }
58 }
59