source: stable/2.6/Cbc/src/CbcCutSubsetModifier.cpp @ 2122

Last change on this file since 2122 was 1432, checked in by bjarni, 9 years ago

Added extra return at end of each source file where needed, to remove possible linefeed conflicts (NightlyBuild? errors)

File size: 2.2 KB
Line 
1//Edwin 11/25/09 carved out of CbcCutGenerator
2#if defined(_MSC_VER)
3// Turn off compiler warning about long names
4#  pragma warning(disable:4786)
5#endif
6#include "CbcConfig.h"
7#include <cassert>
8#include <cstdlib>
9#include <cmath>
10#include <cfloat>
11
12#ifdef COIN_HAS_CLP
13#include "OsiClpSolverInterface.hpp"
14#else
15#include "OsiSolverInterface.hpp"
16#endif
17#include "CbcModel.hpp"
18#include "CbcMessage.hpp"
19#include "CbcCutGenerator.hpp"
20#include "CbcBranchDynamic.hpp"
21#include "CglProbing.hpp"
22#include "CoinTime.hpp"
23#include "CbcCutSubsetModifier.hpp"
24
25// Default Constructor
26CbcCutSubsetModifier::CbcCutSubsetModifier ()
27        : CbcCutModifier(),
28        firstOdd_(COIN_INT_MAX)
29{
30}
31
32// Useful constructor
33CbcCutSubsetModifier::CbcCutSubsetModifier (int firstOdd)
34        : CbcCutModifier()
35{
36    firstOdd_ = firstOdd;
37}
38
39// Copy constructor
40CbcCutSubsetModifier::CbcCutSubsetModifier ( const CbcCutSubsetModifier & rhs)
41        : CbcCutModifier(rhs)
42{
43    firstOdd_ = rhs.firstOdd_;
44}
45
46// Clone
47CbcCutModifier *
48CbcCutSubsetModifier::clone() const
49{
50    return new CbcCutSubsetModifier(*this);
51}
52
53// Assignment operator
54CbcCutSubsetModifier &
55CbcCutSubsetModifier::operator=( const CbcCutSubsetModifier & rhs)
56{
57    if (this != &rhs) {
58        CbcCutModifier::operator=(rhs);
59        firstOdd_ = rhs.firstOdd_;
60    }
61    return *this;
62}
63
64// Destructor
65CbcCutSubsetModifier::~CbcCutSubsetModifier ()
66{
67}
68/* Returns
69   0 unchanged
70   1 strengthened
71   2 weakened
72   3 deleted
73*/
74int
75CbcCutSubsetModifier::modify(const OsiSolverInterface * /*solver*/,
76                             OsiRowCut & cut)
77{
78    int n = cut.row().getNumElements();
79    if (!n)
80        return 0;
81    const int * column = cut.row().getIndices();
82    //const double * element = cut.row().getElements();
83    int returnCode = 0;
84    for (int i = 0; i < n; i++) {
85        if (column[i] >= firstOdd_) {
86            returnCode = 3;
87            break;
88        }
89    }
90    if (!returnCode) {
91        const double * element = cut.row().getElements();
92        printf("%g <= ", cut.lb());
93        for (int i = 0; i < n; i++) {
94            printf("%g*x%d ", element[i], column[i]);
95        }
96        printf("<= %g\n", cut.ub());
97    }
98    //return 3;
99    return returnCode;
100}
101
Note: See TracBrowser for help on using the repository browser.