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

Last change on this file since 2385 was 2385, checked in by unxusr, 4 months ago

formatting

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1/* $Id: MyEventHandler.cpp 2385 2019-01-06 19:43:06Z unxusr $ */
2// Copyright (C) 2004, 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#if defined(_MSC_VER)
7#pragma warning(disable : 4786)
8#pragma warning(disable : 4503)
9#endif
10
11#include "MyEventHandler.hpp"
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 MyEventHandler::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/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
89*/
Note: See TracBrowser for help on using the repository browser.