source: trunk/Cbc/src/CbcCutSubsetModifier.cpp

Last change on this file was 2465, checked in by unxusr, 10 months ago

script to format sources

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1// $Id: CbcCutSubsetModifier.cpp 2465 2019-01-03 19:26:52Z stefan $
2// Copyright (C) 2003, International Business Machines
3// Corporation and others.  All Rights Reserved.
4// This code is licensed under the terms of the Eclipse Public License (EPL).
5
6//Edwin 11/25/09 carved out of CbcCutGenerator
7
8#if defined(_MSC_VER)
9// Turn off compiler warning about long names
10#pragma warning(disable : 4786)
11#endif
12#include "CbcConfig.h"
13#include <cassert>
14#include <cstdlib>
15#include <cmath>
16#include <cfloat>
17
18#ifdef COIN_HAS_CLP
19#include "OsiClpSolverInterface.hpp"
20#else
21#include "OsiSolverInterface.hpp"
22#endif
23#include "CbcModel.hpp"
24#include "CbcMessage.hpp"
25#include "CbcCutGenerator.hpp"
26#include "CbcBranchDynamic.hpp"
27#include "CglProbing.hpp"
28#include "CoinTime.hpp"
29#include "CbcCutSubsetModifier.hpp"
30
31// Default Constructor
32CbcCutSubsetModifier::CbcCutSubsetModifier()
33  : CbcCutModifier()
34  , firstOdd_(COIN_INT_MAX)
35{
36}
37
38// Useful constructor
39CbcCutSubsetModifier::CbcCutSubsetModifier(int firstOdd)
40  : CbcCutModifier()
41{
42  firstOdd_ = firstOdd;
43}
44
45// Copy constructor
46CbcCutSubsetModifier::CbcCutSubsetModifier(const CbcCutSubsetModifier &rhs)
47  : CbcCutModifier(rhs)
48{
49  firstOdd_ = rhs.firstOdd_;
50}
51
52// Clone
53CbcCutModifier *
54CbcCutSubsetModifier::clone() const
55{
56  return new CbcCutSubsetModifier(*this);
57}
58
59// Assignment operator
60CbcCutSubsetModifier &
61CbcCutSubsetModifier::operator=(const CbcCutSubsetModifier &rhs)
62{
63  if (this != &rhs) {
64    CbcCutModifier::operator=(rhs);
65    firstOdd_ = rhs.firstOdd_;
66  }
67  return *this;
68}
69
70// Destructor
71CbcCutSubsetModifier::~CbcCutSubsetModifier()
72{
73}
74/* Returns
75   0 unchanged
76   1 strengthened
77   2 weakened
78   3 deleted
79*/
80int CbcCutSubsetModifier::modify(const OsiSolverInterface * /*solver*/,
81  OsiRowCut &cut)
82{
83  int n = cut.row().getNumElements();
84  if (!n)
85    return 0;
86  const int *column = cut.row().getIndices();
87  //const double * element = cut.row().getElements();
88  int returnCode = 0;
89  for (int i = 0; i < n; i++) {
90    if (column[i] >= firstOdd_) {
91      returnCode = 3;
92      break;
93    }
94  }
95#ifdef COIN_DETAIL
96  if (!returnCode) {
97    const double *element = cut.row().getElements();
98    printf("%g <= ", cut.lb());
99    for (int i = 0; i < n; i++) {
100      printf("%g*x%d ", element[i], column[i]);
101    }
102    printf("<= %g\n", cut.ub());
103  }
104#endif
105  //return 3;
106  return returnCode;
107}
108
109/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
110*/
Note: See TracBrowser for help on using the repository browser.