Scippy

GCG

Branch-and-Price & Column Generation for Everyone

objdialog.h
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
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-2026 Operations Research, RWTH Aachen University */
10/* Zuse Institute Berlin (ZIB) */
11/* */
12/* Licensed under the Apache License, Version 2.0 (the "License"); */
13/* you may not use this file except in compliance with the License. */
14/* You may obtain a copy of the License at */
15/* */
16/* http://www.apache.org/licenses/LICENSE-2.0 */
17/* */
18/* Unless required by applicable law or agreed to in writing, software */
19/* distributed under the License is distributed on an "AS IS" BASIS, */
20/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
21/* See the License for the specific language governing permissions and */
22/* limitations under the License. */
23/* */
24/* You should have received a copy of the Apache-2.0 license */
25/* along with GCG; see the file LICENSE. If not visit gcg.or.rwth-aachen.de.*/
26/* */
27/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
28
29/**@file objdialog.h
30 * @brief C++ wrapper for dialogs
31 * @author Kati Wolter
32 * @author Martin Bergner
33 */
34
35/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36
37#ifndef GCG_OBJDIALOG_H__
38#define GCG_OBJDIALOG_H__
39
40#include <cstring>
41
42#include "scip/scip.h"
44#include "gcg/gcg.h"
45
46
47namespace gcg
48{
49
50/**
51 * @brief C++ wrapper for dialogs
52 *
53 * This class defines the interface for dialogs implemented in C++. Note that there is a pure virtual function (this
54 * function has to be implemented). This function is: scip_exec().
55 */
57{
58public:
59 /*lint --e{1540}*/
60
61 /** GCG data structure */
63
64 /** name of the dialog */
66
67 /** description of the dialog */
69
70 /** default for whether the dialog is a menu */
72
73 /** default constructor */
75 GCG* gcgstruct, /**< GCG data structure */
76 const char* name, /**< name of the dialog */
77 const char* desc, /**< description of the dialog */
78 SCIP_Bool issubmenu /**< default for whether the dialog is a menu */
79 )
80 : gcg(gcgstruct),
81 scip_name_(0),
82 scip_desc_(0),
83 scip_issubmenu_(issubmenu)
84 {
85 /* the macro SCIPduplicateMemoryArray does not need the first argument: */
86 SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) );
87 SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) );
88 }
89
90 /** destructor */
91 virtual ~ObjDialog()
92 {
93 /* the macro SCIPfreeMemoryArray does not need the first argument: */
94 /*lint --e{64}*/
97 gcg = NULL;
98 }
99
100 /** destructor of dialog to free user data (called when SCIP is exiting)
101 *
102 * @see SCIP_DECL_DIALOGFREE(x) in type_dialog.h
103 */
104 virtual SCIP_DECL_DIALOGFREE(scip_free)
105 { /*lint --e{715}*/
106 return SCIP_OKAY;
107 }
108
109 /** description output method of dialog
110 *
111 * @see SCIP_DECL_DIALOGDESC(x) in type_dialog.h
112 */
113 virtual SCIP_DECL_DIALOGDESC(scip_desc)
114 { /*lint --e{715}*/
116 return SCIP_OKAY;
117 }
118
119 /** execution method of dialog
120 *
121 * @see SCIP_DECL_DIALOGEXEC(x) in type_dialog.h
122 */
123 virtual SCIP_DECL_DIALOGEXEC(scip_exec) = 0;
124};
125
126} /* namespace scip */
127
128
129
130/** creates the dialog for the given dialog object and includes it in SCIP
131 *
132 * The method should be called in one of the following ways:
133 *
134 * 1. The user is resposible of deleting the object:
135 * SCIP_CALL( SCIPcreate(&scip) );
136 * ...
137 * MyDialog* mydialog = new MyDialog(...);
138 * SCIP_CALL( GCGincludeObjDialog(gcg, &mydialog, FALSE) );
139 * ...
140 * SCIP_CALL( SCIPfree(&scip) );
141 * delete mydialog; // delete dialog AFTER SCIPfree() !
142 *
143 * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call:
144 * SCIP_CALL( SCIPcreate(&scip) );
145 * ...
146 * SCIP_CALL( GCGincludeObjDialog(gcg, new MyDialog(...), TRUE) );
147 * ...
148 * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyDialog is called here
149 */
152 GCG* gcg, /**< GCG data structure */
153 SCIP_DIALOG* parentdialog, /**< parent dialog */
154 gcg::ObjDialog* objdialog, /**< dialog object */
155 SCIP_Bool deleteobject /**< should the dialog object be deleted when dialog is freed? */
156 );
157
158#endif
C++ wrapper for dialogs.
Definition: objdialog.h:57
virtual SCIP_DECL_DIALOGDESC(scip_desc)
Definition: objdialog.h:113
virtual SCIP_DECL_DIALOGEXEC(scip_exec)=0
char * scip_desc_
Definition: objdialog.h:68
virtual SCIP_DECL_DIALOGFREE(scip_free)
Definition: objdialog.h:104
const SCIP_Bool scip_issubmenu_
Definition: objdialog.h:71
virtual ~ObjDialog()
Definition: objdialog.h:91
ObjDialog(GCG *gcgstruct, const char *name, const char *desc, SCIP_Bool issubmenu)
Definition: objdialog.h:74
char * scip_name_
Definition: objdialog.h:65
#define GCG_EXPORT
Definition: def.h:59
#define SCIP_Bool
#define SCIP_CALL_ABORT(x)
GCG interface methods.
void SCIPdialogMessage(SCIP *scip, FILE *file, const char *formatstr,...)
#define SCIPduplicateMemoryArray(scip, ptr, source, num)
#define SCIPfreeMemoryArray(scip, ptr)
#define NULL
GCG_EXPORT SCIP_RETCODE GCGincludeObjDialog(GCG *gcg, SCIP_DIALOG *parentdialog, gcg::ObjDialog *objdialog, SCIP_Bool deleteobject)
Definition: objdialog.cpp:126
Definition: struct_gcg.h:55
SCIP_OKAY
enum SCIP_Retcode SCIP_RETCODE