source: trunk/Clp/src/MyEventHandler.cpp @ 1525

Last change on this file since 1525 was 1525, checked in by mjs, 10 years ago

Formatted .cpp, .hpp, .c, .h files with "astyle -A4 -p". This matches the formatting used in the grand CBC reorganization.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1/* $Id: MyEventHandler.cpp 1525 2010-02-26 17:27:59Z mjs $ */
2// Copyright (C) 2004, International Business Machines
3// Corporation and others.  All Rights Reserved.
4
5#if defined(_MSC_VER)
6#pragma warning(disable:4786)
7#pragma warning(disable:4503)
8#endif
9
10#include "MyEventHandler.hpp"
11
12
13//#############################################################################
14// Constructors / Destructor / Assignment
15//#############################################################################
16
17//-------------------------------------------------------------------
18// Default Constructor
19//-------------------------------------------------------------------
20MyEventHandler::MyEventHandler ()
21     : ClpEventHandler()
22{
23}
24
25//-------------------------------------------------------------------
26// Copy constructor
27//-------------------------------------------------------------------
28MyEventHandler::MyEventHandler (const MyEventHandler & rhs)
29     : ClpEventHandler(rhs)
30{
31}
32
33// Constructor with pointer to model
34MyEventHandler::MyEventHandler(ClpSimplex * model)
35     : ClpEventHandler(model)
36{
37}
38
39//-------------------------------------------------------------------
40// Destructor
41//-------------------------------------------------------------------
42MyEventHandler::~MyEventHandler ()
43{
44}
45
46//----------------------------------------------------------------
47// Assignment operator
48//-------------------------------------------------------------------
49MyEventHandler &
50MyEventHandler::operator=(const MyEventHandler& rhs)
51{
52     if (this != &rhs) {
53          ClpEventHandler::operator=(rhs);
54     }
55     return *this;
56}
57//-------------------------------------------------------------------
58// Clone
59//-------------------------------------------------------------------
60ClpEventHandler * MyEventHandler::clone() const
61{
62     return new MyEventHandler(*this);
63}
64
65int
66MyEventHandler::event(Event whichEvent)
67{
68     if (whichEvent == endOfValuesPass)
69          return 0; // say optimal
70     else
71          return -1; // carry on
72
73#if 0
74     // This is how one can get some progress information at the end of each iteration.
75     if (whichEvent == endOfIteration) {
76          int numIter = model_->getIterationCount();
77          double sumDualInfeas = model_->sumDualInfeasibilities();
78          double sumPrimalInfeas = model_->sumPrimalInfeasibilities();
79          double obj = model_->getObjValue();
80     }
81
82     // This is how one can tell CLP to stop now.
83     // The value of cancelAsap needs to come from the application using CLP.
84     if ( cancelAsap ) return 5;
85     else return -1;
86#endif
87
88
89}
Note: See TracBrowser for help on using the repository browser.