GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
objdialog.cpp
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.cpp
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/*lint -e64 disable useless NULL pointer errors */
37#include <cassert>
38#include "gcg/objdialog.h"
39
40
41/*
42 * Data structures
43 */
44
45/** dialog data */
47{
48 gcg::ObjDialog* objdialog; /**< dialog object */
49 SCIP_Bool deleteobject; /**< should the dialog object be deleted when dialog is freed? */
50};
51
52
53/*
54 * Callback methods of dialog
55 */
56
57extern "C"
58{
59
60#define dialogCopyObj NULL
61/** destructor of dialog to free user data (called when SCIP is exiting) */
62static
64{ /*lint --e{715}*/
65 SCIP_DIALOGDATA* dialogdata;
66
67 dialogdata = SCIPdialogGetData(dialog);
68 assert(dialogdata != 0);
69 assert(dialogdata->objdialog != 0);
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 */
87static
89{ /*lint --e{715}*/
90 SCIP_DIALOGDATA* dialogdata;
91
92 dialogdata = SCIPdialogGetData(dialog);
93 assert(dialogdata != 0);
94 assert(dialogdata->objdialog != 0);
95
96 /* call virtual method of dialog object */
97 SCIP_CALL( dialogdata->objdialog->scip_desc(scip, dialog) );
98
99 return SCIP_OKAY;
100}
101
102/** execution method of dialog */
103static
105{ /*lint --e{715}*/
106 SCIP_DIALOGDATA* dialogdata;
107
108 dialogdata = SCIPdialogGetData(dialog);
109 assert(dialogdata != 0);
110 assert(dialogdata->objdialog != 0);
111
112 /* call virtual method of dialog object */
113 SCIP_CALL( dialogdata->objdialog->scip_exec(scip, dialog, dialoghdlr, nextdialog) );
114
115 return SCIP_OKAY;
116}
117}
118
119
120
121/*
122 * dialog specific interface methods
123 */
124
125/** creates the dialog for the given dialog object and includes it in SCIP */
127 GCG* gcg, /**< GCG data structure */
128 SCIP_DIALOG* parentdialog, /**< parent dialog */
129 gcg::ObjDialog* objdialog, /**< dialog object */
130 SCIP_Bool deleteobject /**< should the dialog object be deleted when dialog is freed? */
131 )
132{/*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;
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;
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:57
char * scip_desc_
Definition objdialog.h:68
const SCIP_Bool scip_issubmenu_
Definition objdialog.h:71
char * scip_name_
Definition objdialog.h:65
#define SCIP_Bool
SCIP_DECL_DIALOGEXEC(SCIPdialogExecCountPresolve)
SCIP_DECL_DIALOGDESC(SCIPdialogDescSetParam)
SCIP * GCGgetOrigprob(GCG *gcg)
Definition gcg.cpp:87
SCIP_RETCODE SCIPreleaseDialog(SCIP *scip, SCIP_DIALOG **dialog)
SCIP_Bool SCIPdialogHasEntry(SCIP_DIALOG *dialog, const char *entryname)
SCIP_RETCODE SCIPincludeDialog(SCIP *scip, SCIP_DIALOG **dialog, SCIP_DECL_DIALOGCOPY((*dialogcopy)), SCIP_DECL_DIALOGEXEC((*dialogexec)), SCIP_DECL_DIALOGDESC((*dialogdesc)), SCIP_DECL_DIALOGFREE((*dialogfree)), const char *name, const char *desc, SCIP_Bool issubmenu, SCIP_DIALOGDATA *dialogdata)
SCIP_RETCODE SCIPaddDialogEntry(SCIP *scip, SCIP_DIALOG *dialog, SCIP_DIALOG *subdialog)
void SCIPdialogSetData(SCIP_DIALOG *dialog, SCIP_DIALOGDATA *dialogdata)
SCIP_DIALOGDATA * SCIPdialogGetData(SCIP_DIALOG *dialog)
static assert(heur !=NULL)
SCIP_CALL(SCIPgetExternBranchCands(origprob, &lpcands, &lpcandssol, NULL, &nlpcands, NULL, NULL, NULL, NULL))
SCIP_RETCODE retcode
static SCIP_DECL_DIALOGFREE(dialogFreeObj)
Definition objdialog.cpp:63
#define dialogCopyObj
Definition objdialog.cpp:60
SCIP_RETCODE GCGincludeObjDialog(GCG *gcg, SCIP_DIALOG *parentdialog, gcg::ObjDialog *objdialog, SCIP_Bool deleteobject)
C++ wrapper for dialogs.
gcg::ObjDialog * objdialog
Definition objdialog.cpp:48
SCIP_Bool deleteobject
Definition objdialog.cpp:49
struct SCIP_Dialog SCIP_DIALOG
struct SCIP_DialogData SCIP_DIALOGDATA
struct Gcg GCG
Definition type_gcg.h:44
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP