Ipopt 3.12.10

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpJournalist.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2009 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: IpJournalist.hpp 2204 2013-04-13 13:49:26Z stefan $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8
9 #ifndef __IPJOURNALIST_HPP__
10 #define __IPJOURNALIST_HPP__
11
12 #include "IpoptConfig.h"
13 #include "IpTypes.hpp"
14 #include "IpReferenced.hpp"
15 #include "IpSmartPtr.hpp"
16
17 #ifdef HAVE_CSTDARG
18 # include <cstdarg>
19 #else
20 # ifdef HAVE_STDARG_H
21 # include <stdarg.h>
22 # else
23 # include <cstdarg> // if this header is included by someone who does not define HAVE_CSTDARG or HAVE_STDARG, let's hope that cstdarg is available
24 # endif
25 #endif
26
27 #ifdef HAVE_CSTDIO
28 # include <cstdio>
29 #else
30 # ifdef HAVE_STDIO_H
31 # include <stdio.h>
32 # else
33 # include <cstdio> // if this header is included by someone who does not define HAVE_CSTDIO or HAVE_STDIO, let's hope that cstdio is available
34 # endif
35 #endif
36
37 #include <string>
38 #include <vector>
39 #include <ostream>
40
41 namespace Ipopt
42 {
43
44 // forward declarations
45 class Journal;
46 class FileJournal;
47
51 enum EJournalLevel {
52 J_INSUPPRESSIBLE=-1,
53 J_NONE=0,
54 J_ERROR,
55 J_STRONGWARNING,
56 J_SUMMARY,
57 J_WARNING,
58 J_ITERSUMMARY,
59 J_DETAILED,
60 J_MOREDETAILED,
61 J_VECTOR,
62 J_MOREVECTOR,
63 J_MATRIX,
64 J_MOREMATRIX,
65 J_ALL,
66 J_LAST_LEVEL
67 };
68
70 enum EJournalCategory {
71 J_DBG=0,
72 J_STATISTICS,
73 J_MAIN,
74 J_INITIALIZATION,
75 J_BARRIER_UPDATE,
76 J_SOLVE_PD_SYSTEM,
77 J_FRAC_TO_BOUND,
78 J_LINEAR_ALGEBRA,
79 J_LINE_SEARCH,
80 J_HESSIAN_APPROXIMATION,
81 J_SOLUTION,
82 J_DOCUMENTATION,
83 J_NLP,
84 J_TIMING_STATISTICS,
85 J_USER_APPLICATION ,
86 J_USER1 ,
87 J_USER2 ,
88 J_USER3 ,
89 J_USER4 ,
90 J_USER5 ,
91 J_USER6 ,
92 J_USER7 ,
93 J_USER8 ,
94 J_USER9 ,
95 J_USER10 ,
96 J_USER11 ,
97 J_USER12 ,
98 J_USER13 ,
99 J_USER14 ,
100 J_USER15 ,
101 J_USER16 ,
102 J_USER17 ,
103 J_LAST_CATEGORY
104 };
106
134 class Journalist : public ReferencedObject
135 {
136 public:
140 Journalist();
141
143 virtual ~Journalist();
145
152 virtual void Printf(EJournalLevel level, EJournalCategory category,
153 const char* format, ...) const;
154
162 virtual void PrintStringOverLines(EJournalLevel level, EJournalCategory category,
163 Index indent_spaces, Index max_length,
164 const std::string& line) const;
165
167 virtual void PrintfIndented(EJournalLevel level,
168 EJournalCategory category,
169 Index indent_level,
170 const char* format, ...) const;
171
174 virtual void VPrintf(EJournalLevel level,
175 EJournalCategory category,
176 const char* pformat,
177 va_list ap) const;
178
181 virtual void VPrintfIndented(EJournalLevel level,
182 EJournalCategory category,
183 Index indent_level,
184 const char* pformat,
185 va_list ap) const;
186
193 virtual bool ProduceOutput(EJournalLevel level,
194 EJournalCategory category) const;
195
196
201 virtual void FlushBuffer() const;
203
222 virtual bool AddJournal(const SmartPtr<Journal> jrnl);
223
231 virtual SmartPtr<Journal> AddFileJournal(
232 const std::string& location_name,
233 const std::string& fname,
234 EJournalLevel default_level = J_WARNING
235 );
236
240 virtual SmartPtr<Journal> GetJournal(const std::string& location_name);
241
243 virtual void DeleteAllJournals();
245
246 private:
256 Journalist(const Journalist&);
257
259 void operator=(const Journalist&);
261
262 //** Private Data Members. */
264 std::vector< SmartPtr<Journal> > journals_;
266 };
267
273 class Journal : public ReferencedObject
274 {
275 public:
277 Journal(const std::string& name, EJournalLevel default_level);
278
280 virtual ~Journal();
281
283 virtual std::string Name();
284
286 virtual void SetPrintLevel(
287 EJournalCategory category, EJournalLevel level
288 );
289
291 virtual void SetAllPrintLevels(
292 EJournalLevel level
293 );
294
306 virtual bool IsAccepted(
307 EJournalCategory category, EJournalLevel level
308 ) const;
309
311 virtual void Print(EJournalCategory category, EJournalLevel level,
312 const char* str)
313 {
314 PrintImpl(category, level, str);
315 }
316
318 virtual void Printf(EJournalCategory category, EJournalLevel level,
319 const char* pformat, va_list ap)
320 {
321 PrintfImpl(category, level, pformat, ap);
322 }
323
325 virtual void FlushBuffer()
326 {
327 FlushBufferImpl();
328 }
330
331 protected:
337 virtual void PrintImpl(EJournalCategory category, EJournalLevel level,
338 const char* str)=0;
339
341 virtual void PrintfImpl(EJournalCategory category, EJournalLevel level,
342 const char* pformat, va_list ap)=0;
343
345 virtual void FlushBufferImpl()=0;
347
348 private:
358 Journal();
359
361 Journal(const Journal&);
362
364 void operator=(const Journal&);
366
368 std::string name_;
369
371 Index print_levels_[J_LAST_CATEGORY];
372 };
373
374
379 class FileJournal : public Journal
380 {
381 public:
383 FileJournal(const std::string& name, EJournalLevel default_level);
384
386 virtual ~FileJournal();
387
395 virtual bool Open(const char* fname);
396
397 protected:
403 virtual void PrintImpl(EJournalCategory category, EJournalLevel level,
404 const char* str);
405
407 virtual void PrintfImpl(EJournalCategory category, EJournalLevel level,
408 const char* pformat, va_list ap);
409
411 virtual void FlushBufferImpl();
413
414 private:
424 FileJournal();
425
427 FileJournal(const FileJournal&);
428
430 void operator=(const FileJournal&);
432
434 FILE* file_;
435 };
436
440 class StreamJournal : public Journal
441 {
442 public:
444 StreamJournal(const std::string& name, EJournalLevel default_level);
445
447 virtual ~StreamJournal()
448 {}
449
451 void SetOutputStream(std::ostream* os);
452
453 protected:
459 virtual void PrintImpl(EJournalCategory category, EJournalLevel level,
460 const char* str);
461
463 virtual void PrintfImpl(EJournalCategory category, EJournalLevel level,
464 const char* pformat, va_list ap);
465
467 virtual void FlushBufferImpl();
469
470 private:
480 StreamJournal();
481
483 StreamJournal(const StreamJournal&);
484
486 void operator=(const StreamJournal&);
488
490 std::ostream* os_;
491
493 char buffer_[32768];
494 };
495 }
496
497 #endif
Ipopt::J_USER10
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:95
Ipopt::J_LINE_SEARCH
Definition: IpJournalist.hpp:79
Ipopt::Journal::Journal
Journal()
Default Constructor.
Ipopt::J_MOREVECTOR
Definition: IpJournalist.hpp:62
Ipopt::Journal::FlushBuffer
virtual void FlushBuffer()
Flush output buffer.
Definition: IpJournalist.hpp:325
Ipopt::J_USER13
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:98
Ipopt::J_HESSIAN_APPROXIMATION
Definition: IpJournalist.hpp:80
Ipopt::StreamJournal::SetOutputStream
void SetOutputStream(std::ostream *os)
Setting the output stream pointer.
Ipopt::J_USER9
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:94
Ipopt::StreamJournal::PrintImpl
virtual void PrintImpl(EJournalCategory category, EJournalLevel level, const char *str)
Print to the designated output location.
Ipopt::J_MOREDETAILED
Definition: IpJournalist.hpp:60
Ipopt::Journal::FlushBufferImpl
virtual void FlushBufferImpl()=0
Flush output buffer.
Ipopt::J_MOREMATRIX
Definition: IpJournalist.hpp:64
Ipopt::FileJournal::Open
virtual bool Open(const char *fname)
Open a new file for the output location.
Ipopt::Journal::PrintfImpl
virtual void PrintfImpl(EJournalCategory category, EJournalLevel level, const char *pformat, va_list ap)=0
Printf to the designated output location.
Ipopt::FileJournal::~FileJournal
virtual ~FileJournal()
Destructor.
Ipopt::Journal::print_levels_
Index print_levels_[J_LAST_CATEGORY]
vector of integers indicating the level for each category
Definition: IpJournalist.hpp:371
Ipopt::J_LAST_CATEGORY
Definition: IpJournalist.hpp:103
Ipopt::Journalist::PrintfIndented
virtual void PrintfIndented(EJournalLevel level, EJournalCategory category, Index indent_level, const char *format,...) const
Method to print a formatted string with indentation.
Ipopt::FileJournal::PrintImpl
virtual void PrintImpl(EJournalCategory category, EJournalLevel level, const char *str)
Print to the designated output location.
Ipopt::Journalist::operator=
void operator=(const Journalist &)
Overloaded Equals Operator.
Ipopt::J_DBG
Definition: IpJournalist.hpp:71
Ipopt::J_NLP
Definition: IpJournalist.hpp:83
Ipopt::J_ALL
Definition: IpJournalist.hpp:65
Ipopt::StreamJournal::os_
std::ostream * os_
pointer to output stream for the output destination
Definition: IpJournalist.hpp:490
Ipopt::Journal::SetAllPrintLevels
virtual void SetAllPrintLevels(EJournalLevel level)
Set the print level for all category.
Ipopt::J_USER8
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:93
Ipopt::Journalist::AddFileJournal
virtual SmartPtr< Journal > AddFileJournal(const std::string &location_name, const std::string &fname, EJournalLevel default_level=J_WARNING)
Add a new FileJournal.
Ipopt::Journal::name_
std::string name_
Name of the output location.
Definition: IpJournalist.hpp:368
Ipopt::FileJournal::operator=
void operator=(const FileJournal &)
Overloaded Equals Operator.
Ipopt::FileJournal::PrintfImpl
virtual void PrintfImpl(EJournalCategory category, EJournalLevel level, const char *pformat, va_list ap)
Printf to the designated output location.
Ipopt::StreamJournal::FlushBufferImpl
virtual void FlushBufferImpl()
Flush output buffer.
Ipopt::FileJournal::file_
FILE * file_
FILE pointer for the output destination.
Definition: IpJournalist.hpp:434
Ipopt::J_USER2
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:87
Ipopt::J_MAIN
Definition: IpJournalist.hpp:73
Ipopt::Journal::operator=
void operator=(const Journal &)
Overloaded Equals Operator.
Ipopt::EJournalLevel
EJournalLevel
Print Level Enum.
Definition: IpJournalist.hpp:51
Ipopt::J_USER5
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:90
Ipopt::J_USER17
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:102
Ipopt::FileJournal::FlushBufferImpl
virtual void FlushBufferImpl()
Flush output buffer.
Ipopt::J_INSUPPRESSIBLE
Definition: IpJournalist.hpp:52
Ipopt::StreamJournal::buffer_
char buffer_[32768]
buffer for sprintf.
Definition: IpJournalist.hpp:493
Ipopt::SmartPtr
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
Ipopt::StreamJournal::~StreamJournal
virtual ~StreamJournal()
Destructor.
Definition: IpJournalist.hpp:447
Ipopt::ReferencedObject
ReferencedObject class.
Definition: IpReferenced.hpp:174
Ipopt::J_VECTOR
Definition: IpJournalist.hpp:61
Ipopt::J_LAST_LEVEL
Definition: IpJournalist.hpp:66
Ipopt::J_USER_APPLICATION
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:85
Ipopt::J_LINEAR_ALGEBRA
Definition: IpJournalist.hpp:78
Ipopt::J_SOLVE_PD_SYSTEM
Definition: IpJournalist.hpp:76
Ipopt::Journal::PrintImpl
virtual void PrintImpl(EJournalCategory category, EJournalLevel level, const char *str)=0
Print to the designated output location.
Ipopt::StreamJournal::StreamJournal
StreamJournal()
Default Constructor.
Ipopt::J_ITERSUMMARY
Definition: IpJournalist.hpp:58
Ipopt::J_SUMMARY
Definition: IpJournalist.hpp:56
Ipopt::J_USER7
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:92
Ipopt::Journalist::VPrintf
virtual void VPrintf(EJournalLevel level, EJournalCategory category, const char *pformat, va_list ap) const
Method to print a formatted string using the va_list argument.
Ipopt::Journalist::Printf
virtual void Printf(EJournalLevel level, EJournalCategory category, const char *format,...) const
Method to print a formatted string.
Ipopt::J_USER12
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:97
Ipopt::Journalist::AddJournal
virtual bool AddJournal(const SmartPtr< Journal > jrnl)
Add a new journal.
Ipopt::J_DOCUMENTATION
Definition: IpJournalist.hpp:82
Ipopt::J_SOLUTION
Definition: IpJournalist.hpp:81
Ipopt::J_USER4
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:89
Ipopt::J_FRAC_TO_BOUND
Definition: IpJournalist.hpp:77
Ipopt::J_NONE
Definition: IpJournalist.hpp:53
Ipopt::Index
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
Ipopt::J_STRONGWARNING
Definition: IpJournalist.hpp:55
Ipopt::J_USER1
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:86
Ipopt::Journalist::Journalist
Journalist()
Constructor.
IpReferenced.hpp
Ipopt::Journalist::~Journalist
virtual ~Journalist()
Destructor...
Ipopt::J_USER3
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:88
Ipopt::Journalist::PrintStringOverLines
virtual void PrintStringOverLines(EJournalLevel level, EJournalCategory category, Index indent_spaces, Index max_length, const std::string &line) const
Method to print a long string including indentation.
Ipopt::J_ERROR
Definition: IpJournalist.hpp:54
IpoptConfig.h
Ipopt::StreamJournal::operator=
void operator=(const StreamJournal &)
Overloaded Equals Operator.
Ipopt::J_STATISTICS
Definition: IpJournalist.hpp:72
Ipopt::StreamJournal
StreamJournal class.
Definition: IpJournalist.hpp:440
Ipopt::Journalist
Class responsible for all message output.
Definition: IpJournalist.hpp:134
Ipopt::J_USER14
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:99
Ipopt::Journal::Printf
virtual void Printf(EJournalCategory category, EJournalLevel level, const char *pformat, va_list ap)
Printf to the designated output location.
Definition: IpJournalist.hpp:318
Ipopt::J_BARRIER_UPDATE
Definition: IpJournalist.hpp:75
Ipopt::Journalist::DeleteAllJournals
virtual void DeleteAllJournals()
Delete all journals curently known by the journalist.
Ipopt::FileJournal
FileJournal class.
Definition: IpJournalist.hpp:379
Ipopt::Journalist::ProduceOutput
virtual bool ProduceOutput(EJournalLevel level, EJournalCategory category) const
Method that returns true if there is a Journal that would write output for the given JournalLevel and...
Ipopt::J_USER16
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:101
Ipopt::Journalist::VPrintfIndented
virtual void VPrintfIndented(EJournalLevel level, EJournalCategory category, Index indent_level, const char *pformat, va_list ap) const
Method to print a formatted string with indentation, using the va_list argument.
Ipopt::J_DETAILED
Definition: IpJournalist.hpp:59
Ipopt::Journalist::journals_
std::vector< SmartPtr< Journal > > journals_
Definition: IpJournalist.hpp:264
Ipopt::Journalist::FlushBuffer
virtual void FlushBuffer() const
Method that flushes the current buffer for all Journalists.
Ipopt::FileJournal::FileJournal
FileJournal()
Default Constructor.
IpTypes.hpp
Ipopt::J_USER15
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:100
Ipopt::Journal
Journal class (part of the Journalist implementation.).
Definition: IpJournalist.hpp:273
Ipopt::Journal::SetPrintLevel
virtual void SetPrintLevel(EJournalCategory category, EJournalLevel level)
Set the print level for a particular category.
Ipopt::J_USER11
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:96
Ipopt::J_MATRIX
Definition: IpJournalist.hpp:63
Ipopt::J_USER6
This can be used by the user&#39;s application.
Definition: IpJournalist.hpp:91
Ipopt::EJournalCategory
EJournalCategory
Category Selection Enum.
Definition: IpJournalist.hpp:70
Ipopt::J_WARNING
Definition: IpJournalist.hpp:57
Ipopt::J_INITIALIZATION
Definition: IpJournalist.hpp:74
Ipopt::Journal::IsAccepted
virtual bool IsAccepted(EJournalCategory category, EJournalLevel level) const
Ask if a particular print level/category is accepted by the journal.
IpSmartPtr.hpp
Ipopt::StreamJournal::PrintfImpl
virtual void PrintfImpl(EJournalCategory category, EJournalLevel level, const char *pformat, va_list ap)
Printf to the designated output location.
Ipopt::Journalist::GetJournal
virtual SmartPtr< Journal > GetJournal(const std::string &location_name)
Get an existing journal.
Ipopt::J_TIMING_STATISTICS
Definition: IpJournalist.hpp:84
Ipopt::Journal::~Journal
virtual ~Journal()
Destructor.
Ipopt::Journal::Print
virtual void Print(EJournalCategory category, EJournalLevel level, const char *str)
Print to the designated output location.
Definition: IpJournalist.hpp:311
Ipopt::Journal::Name
virtual std::string Name()
Get the name of the Journal.