source: trunk/Cbc/src/CbcCutSubsetModifier.cpp @ 1899

Last change on this file since 1899 was 1899, checked in by stefan, 6 years ago

fixup svn properties

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1// $Id: CbcCutSubsetModifier.cpp 1899 2013-04-09 18:12:08Z 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
81CbcCutSubsetModifier::modify(const OsiSolverInterface * /*solver*/,
82                             OsiRowCut & cut)
83{
84    int n = cut.row().getNumElements();
85    if (!n)
86        return 0;
87    const int * column = cut.row().getIndices();
88    //const double * element = cut.row().getElements();
89    int returnCode = 0;
90    for (int i = 0; i < n; i++) {
91        if (column[i] >= firstOdd_) {
92            returnCode = 3;
93            break;
94        }
95    }
96#ifdef COIN_DETAIL
97    if (!returnCode) {
98        const double * element = cut.row().getElements();
99        printf("%g <= ", cut.lb());
100        for (int i = 0; i < n; i++) {
101            printf("%g*x%d ", element[i], column[i]);
102        }
103        printf("<= %g\n", cut.ub());
104    }
105#endif
106    //return 3;
107    return returnCode;
108}
109
Note: See TracBrowser for help on using the repository browser.