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

Last change on this file since 1304 was 755, checked in by andreasw, 14 years ago

finished Clp (create now bin/clp_solver)

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