Scippy

SCIP

Solving Constraint Integer Programs

scip_dialog.c
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-2019 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 visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file scip_dialog.c
17  * @brief public methods for dialog handler plugins
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  * @author Gerald Gamrath
21  * @author Robert Lion Gottwald
22  * @author Stefan Heinz
23  * @author Gregor Hendel
24  * @author Thorsten Koch
25  * @author Alexander Martin
26  * @author Marc Pfetsch
27  * @author Michael Winkler
28  * @author Kati Wolter
29  *
30  * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #include <ctype.h>
36 #include <stdarg.h>
37 #include <assert.h>
38 #include <string.h>
39 #if defined(_WIN32) || defined(_WIN64)
40 #else
41 #include <strings.h> /*lint --e{766}*/
42 #endif
43 
44 
45 #include "lpi/lpi.h"
46 #include "nlpi/exprinterpret.h"
47 #include "nlpi/nlpi.h"
48 #include "scip/benders.h"
49 #include "scip/benderscut.h"
50 #include "scip/branch.h"
51 #include "scip/branch_nodereopt.h"
52 #include "scip/clock.h"
53 #include "scip/compr.h"
54 #include "scip/concsolver.h"
55 #include "scip/concurrent.h"
56 #include "scip/conflict.h"
57 #include "scip/conflictstore.h"
58 #include "scip/cons.h"
59 #include "scip/cons_linear.h"
60 #include "scip/cutpool.h"
61 #include "scip/cuts.h"
62 #include "scip/debug.h"
63 #include "scip/def.h"
64 #include "scip/dialog.h"
65 #include "scip/dialog_default.h"
66 #include "scip/disp.h"
67 #include "scip/event.h"
68 #include "scip/heur.h"
69 #include "scip/heur_ofins.h"
70 #include "scip/heur_reoptsols.h"
72 #include "scip/heuristics.h"
73 #include "scip/history.h"
74 #include "scip/implics.h"
75 #include "scip/interrupt.h"
76 #include "scip/lp.h"
77 #include "scip/mem.h"
78 #include "scip/message_default.h"
79 #include "scip/misc.h"
80 #include "scip/nlp.h"
81 #include "scip/nodesel.h"
82 #include "scip/paramset.h"
83 #include "scip/presol.h"
84 #include "scip/presolve.h"
85 #include "scip/pricer.h"
86 #include "scip/pricestore.h"
87 #include "scip/primal.h"
88 #include "scip/prob.h"
89 #include "scip/prop.h"
90 #include "scip/reader.h"
91 #include "scip/relax.h"
92 #include "scip/reopt.h"
93 #include "scip/retcode.h"
94 #include "scip/scipbuildflags.h"
95 #include "scip/scipcoreplugins.h"
96 #include "scip/scipgithash.h"
97 #include "scip/sepa.h"
98 #include "scip/sepastore.h"
99 #include "scip/set.h"
100 #include "scip/sol.h"
101 #include "scip/solve.h"
102 #include "scip/stat.h"
103 #include "scip/syncstore.h"
104 #include "scip/table.h"
105 #include "scip/tree.h"
106 #include "scip/var.h"
107 #include "scip/visual.h"
108 #include "xml/xml.h"
109 
110 #include "scip/scip_dialog.h"
111 
112 #include "scip/pub_dialog.h"
113 #include "scip/pub_message.h"
114 
115 
116 /* In debug mode, we include the SCIP's structure in scip.c, such that no one can access
117  * this structure except the interface methods in scip.c.
118  * In optimized mode, the structure is included in scip.h, because some of the methods
119  * are implemented as defines for performance reasons (e.g. the numerical comparisons)
120  */
121 #ifndef NDEBUG
122 #include "scip/struct_scip.h"
123 #endif
124 
125 /** creates and includes dialog
126  *
127  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
128  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
129  */
131  SCIP* scip, /**< SCIP data structure */
132  SCIP_DIALOG** dialog, /**< pointer to store the dialog */
133  SCIP_DECL_DIALOGCOPY ((*dialogcopy)), /**< copy method of dialog or NULL if you don't want to copy your plugin into sub-SCIPs */
134  SCIP_DECL_DIALOGEXEC ((*dialogexec)), /**< execution method of dialog */
135  SCIP_DECL_DIALOGDESC ((*dialogdesc)), /**< description output method of dialog, or NULL */
136  SCIP_DECL_DIALOGFREE ((*dialogfree)), /**< destructor of dialog to free user data, or NULL */
137  const char* name, /**< name of dialog: command name appearing in parent's dialog menu */
138  const char* desc, /**< description of dialog used if description output method is NULL */
139  SCIP_Bool issubmenu, /**< is the dialog a submenu? */
140  SCIP_DIALOGDATA* dialogdata /**< user defined dialog data */
141  )
142 {
143  assert(scip != NULL);
144  assert(dialog != NULL);
145 
146  /* check whether display column is already present */
147  if( dialogcopy != NULL && SCIPexistsDialog(scip, *dialog) )
148  {
149  SCIPerrorMessage("dialog <%s> already included.\n", name);
150  return SCIP_INVALIDDATA;
151  }
152 
153  SCIP_CALL( SCIPdialogCreate(dialog, dialogcopy, dialogexec, dialogdesc, dialogfree, name, desc, issubmenu, dialogdata) );
154  SCIP_CALL( SCIPsetIncludeDialog(scip->set, *dialog) );
155 
156  return SCIP_OKAY;
157 }
158 
159 /** returns if the dialog already exists
160  *
161  * @return TRUE is returned if the dialog exits, otherwise FALSE.
162  */
164  SCIP* scip, /**< SCIP data structure */
165  SCIP_DIALOG* dialog /**< dialog */
166  )
167 {
168  assert(scip != NULL);
169 
170  return SCIPsetExistsDialog(scip->set, dialog);
171 }
172 
173 /** captures a dialog
174  *
175  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
176  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
177  */
179  SCIP* scip, /**< SCIP data structure */
180  SCIP_DIALOG* dialog /**< dialog */
181  )
182 {
183  assert(scip != NULL);
184 
185  SCIPdialogCapture(dialog);
186 
187  return SCIP_OKAY;
188 }
189 
190 /** releases a dialog
191  *
192  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
193  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
194  */
196  SCIP* scip, /**< SCIP data structure */
197  SCIP_DIALOG** dialog /**< pointer to the dialog */
198  )
199 {
200  assert(scip != NULL);
201 
202  SCIP_CALL( SCIPdialogRelease(scip, dialog) );
203 
204  return SCIP_OKAY;
205 }
206 
207 /** makes given dialog the root dialog of SCIP's interactive user shell; captures dialog and releases former root dialog
208  *
209  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
210  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
211  */
213  SCIP* scip, /**< SCIP data structure */
214  SCIP_DIALOG* dialog /**< dialog to be the root */
215  )
216 {
217  assert(scip != NULL);
218 
219  SCIP_CALL( SCIPdialoghdlrSetRoot(scip, scip->dialoghdlr, dialog) );
220 
221  return SCIP_OKAY;
222 }
223 
224 /** returns the root dialog of SCIP's interactive user shell
225  *
226  * @return the root dialog of SCIP's interactive user shell is returned.
227  */
229  SCIP* scip /**< SCIP data structure */
230  )
231 {
232  assert(scip != NULL);
233 
234  return SCIPdialoghdlrGetRoot(scip->dialoghdlr);
235 }
236 
237 /** adds a sub dialog to the given dialog as menu entry and captures it
238  *
239  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
240  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
241  */
243  SCIP* scip, /**< SCIP data structure */
244  SCIP_DIALOG* dialog, /**< dialog to extend, or NULL for root dialog */
245  SCIP_DIALOG* subdialog /**< subdialog to add as menu entry in dialog */
246  )
247 {
248  assert(scip != NULL);
249 
250  if( dialog == NULL )
251  dialog = SCIPdialoghdlrGetRoot(scip->dialoghdlr);
252 
253  SCIP_CALL( SCIPdialogAddEntry(dialog, scip->set, subdialog) );
254 
255  return SCIP_OKAY;
256 }
257 
258 /** adds a single line of input which is treated as if the user entered the command line
259  *
260  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
261  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
262  */
264  SCIP* scip, /**< SCIP data structure */
265  const char* inputline /**< input line to add */
266  )
267 {
268  assert(scip != NULL);
269 
270  SCIP_CALL( SCIPdialoghdlrAddInputLine(scip->dialoghdlr, inputline) );
271 
272  return SCIP_OKAY;
273 }
274 
275 /** adds a single line of input to the command history which can be accessed with the cursor keys
276  *
277  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
278  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
279  */
281  SCIP* scip, /**< SCIP data structure */
282  const char* inputline /**< input line to add */
283  )
284 {
285  assert(scip != NULL);
286 
287  SCIP_CALL( SCIPdialoghdlrAddHistory(scip->dialoghdlr, NULL, inputline, FALSE) );
288 
289  return SCIP_OKAY;
290 }
291 
292 /** starts interactive mode of SCIP by executing the root dialog
293  *
294  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
295  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
296  *
297  * @pre This method can be called if @p scip is in one of the following stages:
298  * - \ref SCIP_STAGE_INIT
299  * - \ref SCIP_STAGE_FREE
300  *
301  * @post After calling this method \SCIP reaches one of the following stages depending on if and when the
302  * interactive shell was closed:
303  * - \ref SCIP_STAGE_PROBLEM if the interactive shell was closed after the problem was created
304  * - \ref SCIP_STAGE_TRANSFORMED if the interactive shell was closed after the problem was transformed
305  * - \ref SCIP_STAGE_PRESOLVING if the interactive shell was closed during presolving
306  * - \ref SCIP_STAGE_PRESOLVED if the interactive shell was closed after presolve
307  * - \ref SCIP_STAGE_SOLVING if the interactive shell was closed during the tree search
308  * - \ref SCIP_STAGE_SOLVED if the interactive shell was closed after the problem was solved
309  * - \ref SCIP_STAGE_FREE if the interactive shell was closed after the problem was freed
310  *
311  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
312  */
314  SCIP* scip /**< SCIP data structure */
315  )
316 {
317  SCIP_CALL( SCIPcheckStage(scip, "SCIPstartInteraction", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
318 
319  /* includes or updates the default dialog menus in SCIP */
321 
322  SCIP_CALL( SCIPdialoghdlrExec(scip->dialoghdlr, scip->set) );
323 
324  return SCIP_OKAY;
325 }
internal methods for separators
SCIP_RETCODE SCIPincludeDialogDefault(SCIP *scip)
#define NULL
Definition: def.h:246
internal methods for managing events
default message handler
trivialnegation primal heuristic
internal methods for storing primal CIP solutions
methods to interpret (evaluate) an expression tree "fast"
internal methods for branch and bound tree
SCIP_RETCODE SCIPdialogRelease(SCIP *scip, SCIP_DIALOG **dialog)
Definition: dialog.c:909
#define SCIP_DECL_DIALOGCOPY(x)
Definition: type_dialog.h:53
SCIP_RETCODE SCIPaddDialogEntry(SCIP *scip, SCIP_DIALOG *dialog, SCIP_DIALOG *subdialog)
Definition: scip_dialog.c:242
methods for implications, variable bounds, and cliques
internal methods for clocks and timing issues
internal methods for NLPI solver interfaces
interface methods for specific LP solvers
internal methods for displaying statistics tables
SCIP_RETCODE SCIPsetIncludeDialog(SCIP_SET *set, SCIP_DIALOG *dialog)
Definition: set.c:4869
#define FALSE
Definition: def.h:72
methods for the aggregation rows
internal methods for Benders&#39; decomposition
SCIP_Bool SCIPexistsDialog(SCIP *scip, SCIP_DIALOG *dialog)
Definition: scip_dialog.c:163
#define TRUE
Definition: def.h:71
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
methods commonly used by primal heuristics
internal methods for branching rules and branching candidate storage
datastructures for concurrent solvers
struct SCIP_DialogData SCIP_DIALOGDATA
Definition: type_dialog.h:42
internal methods for handling parameter settings
methods for creating output for visualization tools (VBC, BAK)
nodereopt branching rule
SCIP_RETCODE SCIPcaptureDialog(SCIP *scip, SCIP_DIALOG *dialog)
Definition: scip_dialog.c:178
internal methods for LP management
internal methods for branching and inference history
internal methods for collecting primal CIP solutions and primal informations
SCIP_DIALOGHDLR * dialoghdlr
Definition: struct_scip.h:64
void SCIPdialogCapture(SCIP_DIALOG *dialog)
Definition: dialog.c:899
internal methods for propagators
#define SCIP_DECL_DIALOGDESC(x)
Definition: type_dialog.h:73
SCIP_DIALOG * SCIPgetRootDialog(SCIP *scip)
Definition: scip_dialog.c:228
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)
Definition: scip_dialog.c:130
git hash methods
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:45
methods for block memory pools and memory buffers
SCIP_RETCODE SCIPaddDialogHistoryLine(SCIP *scip, const char *inputline)
Definition: scip_dialog.c:280
register additional core functionality that is designed as plugins
SCIP_RETCODE SCIPcheckStage(SCIP *scip, const char *method, SCIP_Bool init, SCIP_Bool problem, SCIP_Bool transforming, SCIP_Bool transformed, SCIP_Bool initpresolve, SCIP_Bool presolving, SCIP_Bool exitpresolve, SCIP_Bool presolved, SCIP_Bool initsolve, SCIP_Bool solving, SCIP_Bool solved, SCIP_Bool exitsolve, SCIP_Bool freetrans, SCIP_Bool freescip)
Definition: debug.c:2010
internal methods for presolvers
SCIP_Bool SCIPsetExistsDialog(SCIP_SET *set, SCIP_DIALOG *dialog)
Definition: set.c:4891
internal methods for NLP management
internal miscellaneous methods
internal methods for node selectors and node priority queues
internal methods for variable pricers
internal methods for global SCIP settings
internal methods for storing conflicts
#define SCIP_CALL(x)
Definition: def.h:358
SCIP main data structure.
internal methods for storing priced variables
internal methods for relaxators
internal methods for storing separated cuts
methods commonly used for presolving
methods for catching the user CTRL-C interrupt
internal methods for problem variables
data structures and methods for collecting reoptimization information
the function declarations for the synchronization store
SCIP_RETCODE SCIPdialogCreate(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)
Definition: dialog.c:811
internal methods for user interface dialog
#define SCIP_Bool
Definition: def.h:69
internal methods for input file readers
SCIP_RETCODE SCIPdialoghdlrAddInputLine(SCIP_DIALOGHDLR *dialoghdlr, const char *inputline)
Definition: dialog.c:684
methods for debugging
SCIP_RETCODE SCIPdialoghdlrSetRoot(SCIP *scip, SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG *dialog)
Definition: dialog.c:400
#define SCIP_DECL_DIALOGFREE(x)
Definition: type_dialog.h:61
reoptsols primal heuristic
SCIP_RETCODE SCIPstartInteraction(SCIP *scip)
Definition: scip_dialog.c:313
internal methods for storing cuts in a cut pool
Constraint handler for linear constraints in their most general form, .
SCIP_RETCODE SCIPdialoghdlrAddHistory(SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG *dialog, const char *command, SCIP_Bool escapecommand)
Definition: dialog.c:713
helper functions for concurrent scip solvers
internal methods for return codes for SCIP methods
#define SCIP_DECL_DIALOGEXEC(x)
Definition: type_dialog.h:87
SCIP_DIALOG * SCIPdialoghdlrGetRoot(SCIP_DIALOGHDLR *dialoghdlr)
Definition: dialog.c:423
internal methods for conflict analysis
internal methods for tree compressions
internal methods for main solving loop and node processing
SCIP_SET * set
Definition: struct_scip.h:62
public methods for message output
default user interface dialog
internal methods for problem statistics
internal methods for constraints and constraint handlers
public methods for dialog handler plugins
SCIP_RETCODE SCIPdialogAddEntry(SCIP_DIALOG *dialog, SCIP_SET *set, SCIP_DIALOG *subdialog)
Definition: dialog.c:951
declarations for XML parsing
SCIP_RETCODE SCIPreleaseDialog(SCIP *scip, SCIP_DIALOG **dialog)
Definition: scip_dialog.c:195
build flags methods
SCIP_RETCODE SCIPdialoghdlrExec(SCIP_DIALOGHDLR *dialoghdlr, SCIP_SET *set)
Definition: dialog.c:372
common defines and data types used in all packages of SCIP
internal methods for primal heuristics
SCIP_RETCODE SCIPsetRootDialog(SCIP *scip, SCIP_DIALOG *dialog)
Definition: scip_dialog.c:212
public methods for user interface dialog
internal methods for Benders&#39; decomposition cuts
SCIP_RETCODE SCIPaddDialogInputLine(SCIP *scip, const char *inputline)
Definition: scip_dialog.c:263
internal methods for displaying runtime statistics
OFINS - Objective Function Induced Neighborhood Search - a primal heuristic for reoptimization.