Scippy

SCIP

Solving Constraint Integer Programs

objdisp.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2016 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License. */
12 /* along with SCIP; see the file COPYING. If not email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file objdisp.h
17  * @brief C++ wrapper for display columns
18  * @author Kati Wolter
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #ifndef __SCIP_OBJDISP_H__
24 #define __SCIP_OBJDISP_H__
25 
26 #include <cstring>
27 
28 #include "scip/scip.h"
29 #include "objscip/objcloneable.h"
30 
31 namespace scip
32 {
33 
34 /**
35  * @brief C++ wrapper for display columns
36  *
37  * This class defines the interface for display columns implemented in C++. Note that there is a pure virtual function
38  * (this function has to be implemented). This function is: scip_output().
39  *
40  * - \ref DISP "Instructions for implementing a display column"
41  * - \ref DISPLAYS "List of available display columns"
42  * - \ref type_disp.h "Corresponding C interface"
43  */
44 class ObjDisp : public ObjCloneable
45 {
46 public:
47  /*lint --e{1540}*/
48 
49  /** SCIP data structure */
51 
52  /** name of the display column */
53  char* scip_name_;
54 
55  /** description of the display column */
56  char* scip_desc_;
57 
58  /** head line of the display column */
59  char* scip_header_;
60 
61  /** width of the display column (no. of chars used) */
62  const int scip_width_;
63 
64  /** priority of the display column */
65  const int scip_priority_;
66 
67  /** relative position of the display column */
68  const int scip_position_;
69 
70  /** should the column be separated with a line from its right neighbour? */
72 
73  /** default constructor */
75  SCIP* scip, /**< SCIP data structure */
76  const char* name, /**< name of display column */
77  const char* desc, /**< description of display column */
78  const char* header, /**< head line of display column */
79  int width, /**< width of display column (no. of chars used) */
80  int priority, /**< priority of display column */
81  int position, /**< relative position of display column */
82  SCIP_Bool stripline /**< should the column be separated with a line from its right neighbour? */
83  )
84  : scip_(scip),
85  scip_name_(0),
86  scip_desc_(0),
87  scip_header_(0),
88  scip_width_(width),
89  scip_priority_(priority),
90  scip_position_(position),
91  scip_stripline_(stripline)
92  {
93  /* the macro SCIPduplicateMemoryArray does not need the first argument: */
94  SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) );
95  SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) );
96  SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_header_, header, std::strlen(header)+1) );
97  }
98 
99  /** destructor */
100  virtual ~ObjDisp()
101  {
102  /* the macro SCIPfreeMemoryArray does not need the first argument: */
103  /*lint --e{64}*/
104  SCIPfreeMemoryArray(scip_, &scip_name_);
105  SCIPfreeMemoryArray(scip_, &scip_desc_);
106  SCIPfreeMemoryArray(scip_, &scip_header_);
107  }
108 
109  /** destructor of display column to free user data (called when SCIP is exiting)
110  *
111  * @see SCIP_DECL_DISPFREE(x) in @ref type_disp.h
112  */
113  virtual SCIP_DECL_DISPFREE(scip_free)
114  { /*lint --e{715}*/
115  return SCIP_OKAY;
116  }
117 
118  /** initialization method of display column (called after problem was transformed)
119  *
120  * @see SCIP_DECL_DISPINIT(x) in @ref type_disp.h
121  */
122  virtual SCIP_DECL_DISPINIT(scip_init)
123  { /*lint --e{715}*/
124  return SCIP_OKAY;
125  }
126 
127  /** deinitialization method of display column (called before transformed problem is freed)
128  *
129  * @see SCIP_DECL_DISPEXIT(x) in @ref type_disp.h
130  */
131  virtual SCIP_DECL_DISPEXIT(scip_exit)
132  { /*lint --e{715}*/
133  return SCIP_OKAY;
134  }
135 
136  /** solving process initialization method of display column (called when branch and bound process is about to begin)
137  *
138  * @see SCIP_DECL_DISPINITSOL(x) in @ref type_disp.h
139  */
140  virtual SCIP_DECL_DISPINITSOL(scip_initsol)
141  { /*lint --e{715}*/
142  return SCIP_OKAY;
143  }
144 
145  /** solving process deinitialization method of display column (called before branch and bound process data is freed)
146  *
147  * @see SCIP_DECL_DISPEXITSOL(x) in @ref type_disp.h
148  */
149  virtual SCIP_DECL_DISPEXITSOL(scip_exitsol)
150  { /*lint --e{715}*/
151  return SCIP_OKAY;
152  }
153 
154  /** output method of display column to output file stream 'file'
155  *
156  * @see SCIP_DECL_DISPOUTPUT(x) in @ref type_disp.h
157  */
158  virtual SCIP_DECL_DISPOUTPUT(scip_output) = 0;
159 };
160 
161 } /* namespace scip */
162 
163 
164 
165 /** creates the display column for the given display column object and includes it in SCIP
166  *
167  * The method should be called in one of the following ways:
168  *
169  * 1. The user is resposible of deleting the object:
170  * SCIP_CALL( SCIPcreate(&scip) );
171  * ...
172  * MyDisp* mydisp = new MyDisp(...);
173  * SCIP_CALL( SCIPincludeObjDisp(scip, &mydisp, FALSE) );
174  * ...
175  * SCIP_CALL( SCIPfree(&scip) );
176  * delete mydisp; // delete disp AFTER SCIPfree() !
177  *
178  * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call:
179  * SCIP_CALL( SCIPcreate(&scip) );
180  * ...
181  * SCIP_CALL( SCIPincludeObjDisp(scip, new MyDisp(...), TRUE) );
182  * ...
183  * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyDisp is called here
184  */
185 extern
187  SCIP* scip, /**< SCIP data structure */
188  scip::ObjDisp* objdisp, /**< display column object */
189  SCIP_Bool deleteobject /**< should the display column object be deleted when display column is freed? */
190  );
191 
192 /** returns the display column object of the given name, or 0 if not existing */
193 extern
195  SCIP* scip, /**< SCIP data structure */
196  const char* name /**< name of display column */
197  );
198 
199 /** returns the display column object for the given display column */
200 extern
202  SCIP* scip, /**< SCIP data structure */
203  SCIP_DISP* disp /**< display column */
204  );
205 
206 #endif
const int scip_width_
Definition: objdisp.h:62
scip::ObjDisp * SCIPfindObjDisp(SCIP *scip, const char *name)
C++ wrapper for display columns.
Definition: objdisp.h:44
struct SCIP_Disp SCIP_DISP
Definition: type_disp.h:52
#define SCIPfreeMemoryArray(scip, ptr)
Definition: scip.h:20544
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
char * scip_header_
Definition: objdisp.h:59
const SCIP_Bool scip_stripline_
Definition: objdisp.h:71
definition of base class for all clonable classes
virtual ~ObjDisp()
Definition: objdisp.h:100
char * scip_name_
Definition: objdisp.h:53
virtual SCIP_DECL_DISPEXITSOL(scip_exitsol)
Definition: objdisp.h:149
SCIP * scip_
Definition: objdisp.h:50
struct Scip SCIP
Definition: type_scip.h:30
virtual SCIP_DECL_DISPINIT(scip_init)
Definition: objdisp.h:122
#define SCIP_Bool
Definition: def.h:53
#define SCIPduplicateMemoryArray(scip, ptr, source, num)
Definition: scip.h:20540
scip::ObjDisp * SCIPgetObjDisp(SCIP *scip, SCIP_DISP *disp)
virtual SCIP_DECL_DISPOUTPUT(scip_output)=0
const int scip_priority_
Definition: objdisp.h:65
Definition of base class for all clonable classes.
Definition: objcloneable.h:38
char * scip_desc_
Definition: objdisp.h:56
virtual SCIP_DECL_DISPEXIT(scip_exit)
Definition: objdisp.h:131
const int scip_position_
Definition: objdisp.h:68
ObjDisp(SCIP *scip, const char *name, const char *desc, const char *header, int width, int priority, int position, SCIP_Bool stripline)
Definition: objdisp.h:74
virtual SCIP_DECL_DISPINITSOL(scip_initsol)
Definition: objdisp.h:140
SCIP_RETCODE SCIPincludeObjDisp(SCIP *scip, scip::ObjDisp *objdisp, SCIP_Bool deleteobject)
#define SCIP_CALL_ABORT(x)
Definition: def.h:245
virtual SCIP_DECL_DISPFREE(scip_free)
Definition: objdisp.h:113
SCIP callable library.