Scippy

GCG

Branch-and-Price & Column Generation for Everyone

objdialog.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program */
4 /* GCG --- Generic Column Generation */
5 /* a Dantzig-Wolfe decomposition based extension */
6 /* of the branch-cut-and-price framework */
7 /* SCIP --- Solving Constraint Integer Programs */
8 /* */
9 /* Copyright (C) 2010-2021 Operations Research, RWTH Aachen University */
10 /* Zuse Institute Berlin (ZIB) */
11 /* */
12 /* This program is free software; you can redistribute it and/or */
13 /* modify it under the terms of the GNU Lesser General Public License */
14 /* as published by the Free Software Foundation; either version 3 */
15 /* of the License, or (at your option) any later version. */
16 /* */
17 /* This program is distributed in the hope that it will be useful, */
18 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
19 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
20 /* GNU Lesser General Public License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with this program; if not, write to the Free Software */
24 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/
25 /* */
26 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27 
28 /**@file objdialog.cpp
29  * @brief C++ wrapper for dialogs
30  * @author Kati Wolter
31  * @author Martin Bergner
32  */
33 
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35 /*lint -e64 disable useless NULL pointer errors */
36 #include <cassert>
37 #include "objdialog.h"
38 
39 
40 /*
41  * Data structures
42  */
43 
44 /** dialog data */
46 {
47  gcg::ObjDialog* objdialog; /**< dialog object */
48  SCIP_Bool deleteobject; /**< should the dialog object be deleted when dialog is freed? */
49 };
50 
51 
52 /*
53  * Callback methods of dialog
54  */
55 
56 extern "C"
57 {
58 
59 #define dialogCopyObj NULL
60 /** destructor of dialog to free user data (called when SCIP is exiting) */
61 static
62 SCIP_DECL_DIALOGFREE(dialogFreeObj)
63 { /*lint --e{715}*/
64  SCIP_DIALOGDATA* dialogdata;
65 
66  dialogdata = SCIPdialogGetData(dialog);
67  assert(dialogdata != 0);
68  assert(dialogdata->objdialog != 0);
69  assert(dialogdata->objdialog->scip_ == scip);
70 
71  /* call virtual method of dialog object */
72  SCIP_CALL( dialogdata->objdialog->scip_free(scip, dialog) );
73 
74  /* free dialog object */
75  if( dialogdata->deleteobject )
76  delete dialogdata->objdialog;
77 
78  /* free dialog data */
79  delete dialogdata;
80  SCIPdialogSetData(dialog, 0); /*lint !e64*/
81 
82  return SCIP_OKAY;
83 }
84 
85 
86 /** description output method of dialog */
87 static
88 SCIP_DECL_DIALOGDESC(dialogDescObj)
89 { /*lint --e{715}*/
90  SCIP_DIALOGDATA* dialogdata;
91 
92  dialogdata = SCIPdialogGetData(dialog);
93  assert(dialogdata != 0);
94  assert(dialogdata->objdialog != 0);
95  assert(dialogdata->objdialog->scip_ == scip);
96 
97  /* call virtual method of dialog object */
98  SCIP_CALL( dialogdata->objdialog->scip_desc(scip, dialog) );
99 
100  return SCIP_OKAY;
101 }
102 
103 /** execution method of dialog */
104 static
105 SCIP_DECL_DIALOGEXEC(dialogExecObj)
106 { /*lint --e{715}*/
107  SCIP_DIALOGDATA* dialogdata;
108 
109  dialogdata = SCIPdialogGetData(dialog);
110  assert(dialogdata != 0);
111  assert(dialogdata->objdialog != 0);
112 
113  /* call virtual method of dialog object */
114  SCIP_CALL( dialogdata->objdialog->scip_exec(scip, dialog, dialoghdlr, nextdialog) );
115 
116  return SCIP_OKAY;
117 }
118 }
119 
120 
121 
122 /*
123  * dialog specific interface methods
124  */
125 
126 /** creates the dialog for the given dialog object and includes it in SCIP */
127 SCIP_RETCODE SCIPincludeObjDialog(
128  SCIP* scip, /**< SCIP data structure */
129  SCIP_DIALOG* parentdialog, /**< parent dialog */
130  gcg::ObjDialog* objdialog, /**< dialog object */
131  SCIP_Bool deleteobject /**< should the dialog object be deleted when dialog is freed? */
132  )
133 {/*lint --e{429} */
134  assert(scip != 0);
135  assert(objdialog != 0);
136  assert(parentdialog != 0);
137 
138  /* create, include, and release dialog */
139  if( !SCIPdialogHasEntry(parentdialog, objdialog->scip_name_) )
140  {
141  SCIP_DIALOGDATA* dialogdata; /*lint !e593*/
142  SCIP_DIALOG* dialog;
143  SCIP_RETCODE retcode;
144 
145  dialog = 0;
146 
147  /* create dialog data */
148  dialogdata = new SCIP_DIALOGDATA;
149  dialogdata->objdialog = objdialog;
150  dialogdata->deleteobject = deleteobject;
151 
152  retcode = SCIPincludeDialog(scip, &dialog, dialogCopyObj, dialogExecObj, dialogDescObj, dialogFreeObj,
153  objdialog->scip_name_, objdialog->scip_desc_, objdialog->scip_issubmenu_, dialogdata);
154  if( retcode != SCIP_OKAY )
155  {
156  delete dialogdata;
157  SCIP_CALL( retcode );
158  }
159  SCIP_CALL( SCIPaddDialogEntry(scip, parentdialog, dialog) ); /*lint !e593*/
160  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) ); /*lint !e593*/
161  } /*lint !e593*/
162 
163  return SCIP_OKAY; /*lint !e593*/
164 }
C++ wrapper for dialogs.
Definition: objdialog.h:53
const SCIP_Bool scip_issubmenu_
Definition: objdialog.h:68
SCIP_Bool deleteobject
Definition: objdialog.cpp:48
char * scip_desc_
Definition: objdialog.h:65
static SCIP_DECL_DIALOGEXEC(dialogExecObj)
Definition: objdialog.cpp:105
gcg::ObjDialog * objdialog
Definition: objdialog.cpp:47
C++ wrapper for dialogs.
#define dialogCopyObj
Definition: objdialog.cpp:59
static SCIP_DECL_DIALOGFREE(dialogFreeObj)
Definition: objdialog.cpp:62
char * scip_name_
Definition: objdialog.h:62
SCIP_RETCODE SCIPincludeObjDialog(SCIP *scip, SCIP_DIALOG *parentdialog, gcg::ObjDialog *objdialog, SCIP_Bool deleteobject)
Definition: objdialog.cpp:127
static SCIP_DECL_DIALOGDESC(dialogDescObj)
Definition: objdialog.cpp:88