source: html/userguide/ch03s03.html @ 2182

Last change on this file since 2182 was 966, checked in by ddelanu, 16 years ago

Temporary version, trying to fix problems in server change, real release to follow

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Message Handling</title><meta name="generator" content="DocBook XSL Stylesheets V1.66.1"><link rel="start" href="index.html" title="CLP User Guide"><link rel="up" href="ch03.html" title="Chapter 3. 
2  Not-Quite-So-Basic Model Classes
3  "><link rel="prev" href="ch03s02.html" title="Matrix Classes"><link rel="next" href="ch04.html" title="Chapter 4. 
4More Samples
5"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Message Handling</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s02.html">Prev</a> </td><th width="60%" align="center">Chapter 3. 
6  Not-Quite-So-Basic Model Classes
7  </th><td width="20%" align="right"> <a accesskey="n" href="ch04.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="messagehandling"></a>Message Handling</h2></div></div></div><p>
8  Strictly speaking, message handling is a general COIN topic, but it won't hurt
9  to repeat a few important things here.
10  </p><p>
11  A simple user you may wish to turn off some output.  This is done with
12  <tt class="function">model.setLogLevel(int value)</tt>
13  where 0 gives nothing and each increase in value switches on more
14  messages. See <tt class="filename">ClpMessage.cpp</tt>,
15  <tt class="filename">CoinMessage.cpp</tt> and <a href="ch06.html" title="Chapter 6. 
16  Messages
17  ">Chapter 6, <i>
18  Messages
19  </i></a> to see
20  which messages are at which level.  A more sophisticated user may wish to
21  handle messages in a different way.  This is done using
22  <tt class="function">passInMessageHandler</tt> with a pointer to a handler of the
23  user's own design.  The simplest case would be to use the default handler but
24  use a constructor which writes to file.  The code would be:
25  </p><pre class="programlisting">
26  FILE * fp; // assumed open
27  CoinMessageHandler handler(fp);
28  model.passInMessageHandler(&amp;handler);
29  </pre><p>
30  A still more sophisticated use would be to write a class derived from
31  <tt class="function">CoinMessageHandler</tt> and then override the
32  <tt class="function">print</tt> method.  Below follows an example which would
33  print only a message for optimality (or infeasibility):
34  </p><div class="example"><a name="id4772712"></a><p class="title"><b>Example 3.1. Sophisticated message handling</b></p><pre class="programlisting">
35  class DerivedHandler :
36   public CoinMessageHandler {
37   public:
38     virtual int print() ;
39   };
42   int DerivedHandler::print()
43   {
44     if (currentSource()=="Clp") {
45       if (currentMessage().externalNumber()&gt;=0
46       &amp;&amp; currentMessage().externalNumber()&lt;4) {
47         // finished
48         return CoinMessageHandler::print(); // print
49       }
50     }
51     return 0;
52   }
53  </pre></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Matrix Classes </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 4. 
54More Samples
Note: See TracBrowser for help on using the repository browser.