dialog_gcg.c
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-2017 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 
37 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
38 
39 #include <assert.h>
40 #include <string.h>
41 
42 #include "scip/pub_dialog.h"
43 #include "scip/type_dialog.h"
44 #include "scip/dialog_default.h"
45 
46 #include "gcg.h"
47 
48 #include "dialog_gcg.h"
49 #include "relax_gcg.h"
50 #include "pricer_gcg.h"
51 #include "cons_decomp.h"
52 #include "pub_gcgheur.h"
53 #include "stat.h"
54 #include "reader_dec.h"
55 
56 /* display the reader information */
57 static
59  SCIP* scip,
60  SCIP_Bool reader,
61  SCIP_Bool writer
62  )
63 {
64  SCIP_READER** readers;
65  int nreaders;
66  int r;
67 
68  assert( scip != NULL );
69 
70  readers = SCIPgetReaders(scip);
71  nreaders = SCIPgetNReaders(scip);
72 
73  /* display list of readers */
74  SCIPdialogMessage(scip, NULL, "\n");
75  SCIPdialogMessage(scip, NULL, " file reader extension description\n");
76  SCIPdialogMessage(scip, NULL, " ----------- --------- -----------\n");
77  for( r = 0; r < nreaders; ++r )
78  {
79  if( (reader && SCIPreaderCanRead(readers[r])) || (writer && SCIPreaderCanWrite(readers[r])) )
80  {
81  SCIPdialogMessage(scip, NULL, " %-20s ", SCIPreaderGetName(readers[r]));
82  if( strlen(SCIPreaderGetName(readers[r])) > 20 )
83  SCIPdialogMessage(scip, NULL, "\n %20s ", "-->");
84  SCIPdialogMessage(scip, NULL, "%9s ", SCIPreaderGetExtension(readers[r]));
85  SCIPdialogMessage(scip, NULL, "%s", SCIPreaderGetDesc(readers[r]));
86  SCIPdialogMessage(scip, NULL, "\n");
87  }
88  }
89  SCIPdialogMessage(scip, NULL, "\n");
90 }
91 
92 
94 static
96  SCIP* scip,
97  SCIP_DIALOG* dialog,
98  SCIP_DIALOGHDLR* dialoghdlr,
99  SCIP_DIALOG** nextdialog
100  )
101 {
102 
103  char* filename;
104  char* dirname;
105  SCIP_Bool endoffile;
106 
107  if( SCIPconshdlrDecompGetNDecdecomps(scip) == 0 )
108  {
109  SCIPdialogMessage(scip, NULL, "No decomposition to write, please read or detect one first.\n");
110  SCIPdialoghdlrClearBuffer(dialoghdlr);
111  *nextdialog = NULL;
112  return SCIP_OKAY;
113  }
114 
115  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "enter directory and/or extension: ", &dirname, &endoffile) );
116  if( endoffile )
117  {
118  *nextdialog = NULL;
119  return SCIP_OKAY;
120  }
121 
122  if( SCIPdialoghdlrIsBufferEmpty(dialoghdlr) )
123  {
124  filename = dirname;
125  dirname = NULL;
126  }
127  else
128  {
129  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "enter extension: ", &filename, &endoffile) );
130  }
131 
132  if( filename[0] != '\0' )
133  {
134  char* extension;
135  extension = filename;
136  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, extension, TRUE) );
137 
138  do
139  {
140  SCIP_RETCODE retcode = DECwriteAllDecomps(scip, dirname, extension);
141 
142  if( retcode == SCIP_FILECREATEERROR )
143  {
144  SCIPdialogMessage(scip, NULL, "error creating files\n");
145  SCIPdialoghdlrClearBuffer(dialoghdlr);
146  break;
147  }
148  else if( retcode == SCIP_WRITEERROR )
149  {
150  SCIPdialogMessage(scip, NULL, "error writing files\n");
151  SCIPdialoghdlrClearBuffer(dialoghdlr);
152  break;
153  }
154  else if( retcode == SCIP_PLUGINNOTFOUND )
155  {
156  /* ask user once for a suitable reader */
157  if( extension == NULL )
158  {
159  SCIPdialogMessage(scip, NULL, "no reader for requested output format\n");
160 
161  SCIPdialogMessage(scip, NULL, "following readers are avaliable for writing:\n");
162  displayReaders(scip, FALSE, TRUE);
163 
164  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog,
165  "select a suitable reader by extension (or return): ", &extension, &endoffile) );
166 
167  if( extension[0] == '\0' )
168  break;
169  }
170  else
171  {
172  SCIPdialogMessage(scip, NULL, "no reader for output in <%s> format\n", extension);
173  extension = NULL;
174  }
175  }
176  else
177  {
178  /* check for unexpected errors */
179  SCIP_CALL( retcode );
180 
181  /* print result message if writing was successful */
182  SCIPdialogMessage(scip, NULL, "written all decompositions %s\n", extension);
183  break;
184  }
185  }
186  while (extension != NULL );
187  }
188 
189  return SCIP_OKAY;
190 }
191 
193 SCIP_DECL_DIALOGEXEC(GCGdialogExecDisplayStatistics)
194 { /*lint --e{715}*/
195  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
196 
197  SCIP_CALL( GCGprintStatistics(scip, NULL) );
198 
199  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
200 
201  return SCIP_OKAY;
202 }
203 
205 SCIP_DECL_DIALOGEXEC(GCGdialogExecDisplayDecomposition)
206 { /*lint --e{715}*/
207  DEC_DECOMP* decomp;
208  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
209 
210  decomp = DECgetBestDecomp(scip);
211  if( decomp != NULL )
212  {
213  SCIP_CALL( GCGwriteDecomp(scip, NULL, decomp) );
214  }
215 
216  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
217 
218  return SCIP_OKAY;
219 }
220 
221 
223 SCIP_DECL_DIALOGEXEC(GCGdialogExecDisplayAdditionalStatistics)
224 { /*lint --e{715}*/
225  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
226  if( SCIPgetStage(scip) == SCIP_STAGE_SOLVING || SCIPgetStage(scip) == SCIP_STAGE_SOLVED )
227  {
228  if( SCIPgetStage(GCGgetMasterprob(scip)) < SCIP_STAGE_PRESOLVED )
229  {
230  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), NULL, "No Dantzig-Wolfe reformulation applied. No decomposition statistics available.\n");
231  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
232  return SCIP_OKAY;
233  }
234 
235  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), NULL, "\nAdditional statistics:\n");
237  {
238  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(GCGgetMasterprob(scip)), NULL, "\n");
239  SCIP_CALL( GCGwriteDecompositionData(scip) );
240 
241  }
242  else
243  {
245  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(GCGgetMasterprob(scip)), NULL, "\n");
246  SCIP_CALL( GCGwriteDecompositionData(scip) );
247  SCIP_CALL( GCGwriteVarCreationDetails(GCGgetMasterprob(scip)) );
248  }
249  }
250  else
251  {
252  SCIPdialogMessage(scip, NULL, "Problem needs to solved first for additional statistics");
253  }
254  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
255 
256  return SCIP_OKAY;
257 }
258 
259 
261 SCIP_DECL_DIALOGEXEC(GCGdialogExecDisplayDetectors)
262 { /*lint --e{715}*/
263  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
264 
266  SCIPdialogMessage(scip, NULL, "\n");
267 
268  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
269 
270  return SCIP_OKAY;
271 }
272 
274 SCIP_DECL_DIALOGEXEC(GCGdialogExecDisplaySolvers)
275 { /*lint --e{715}*/
276  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
277 
279  SCIPdialogMessage(scip, NULL, "\n");
280 
281  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
282 
283  return SCIP_OKAY;
284 }
285 
287 SCIP_DECL_DIALOGEXEC(GCGdialogExecSetMaster)
288 { /*lint --e{715}*/
289  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
290 
291  if( SCIPgetStage(GCGgetMasterprob(scip)) != SCIP_STAGE_INIT )
292  {
293  SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "switching to the master problem shell is only possible before the solving process is started\n");
294 
295  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
296 
297  return SCIP_OKAY;
298  }
299 
300  SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "switching to the master problem...\n");
301  SCIP_CALL( SCIPstartInteraction(GCGgetMasterprob(scip)) );
302  SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "back in the original problem...\n");
303 
304  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
305 
306  return SCIP_OKAY;
307 }
308 
310 SCIP_DECL_DIALOGEXEC(GCGdialogExecSetLoadmaster)
311 { /*lint --e{715}*/
312  SCIP* masterprob;
313  char* filename;
314  SCIP_Bool endoffile;
315 
316  masterprob = GCGgetMasterprob(scip);
317  assert(masterprob != NULL);
318 
319  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "enter filename: ", &filename, &endoffile) );
320  if( endoffile )
321  {
322  *nextdialog = NULL;
323  return SCIP_OKAY;
324  }
325 
326  if( filename[0] != '\0' )
327  {
328  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, filename, TRUE) );
329 
330  if( SCIPfileExists(filename) )
331  {
332  SCIP_CALL( SCIPreadParams(masterprob, filename) );
333  SCIPdialogMessage(scip, NULL, "loaded master parameter file <%s>\n", filename);
334  }
335  else
336  {
337  SCIPdialogMessage(scip, NULL, "file <%s> not found\n", filename);
338  SCIPdialoghdlrClearBuffer(dialoghdlr);
339  }
340  }
341 
342  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
343 
344  return SCIP_OKAY;
345 }
346 
348 SCIP_DECL_DIALOGEXEC(GCGdialogExecDetect)
349 { /*lint --e{715}*/
350  SCIP_RESULT result;
351 
352  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
353 
354  SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "Starting detection\n");
355  if( SCIPgetStage(scip) > SCIP_STAGE_INIT )
356  {
357  SCIP_CALL( DECdetectStructure(scip, &result) );
358  if( result == SCIP_SUCCESS )
359  SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "Detection was successful.\n");
360  else
361  SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "Detection was not successful.\n");
362  }
363  else
364  SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "No problem exists");
365 
366  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
367 
368  return SCIP_OKAY;
369 }
370 
372 SCIP_DECL_DIALOGEXEC(GCGdialogExecOptimize)
373 { /*lint --e{715}*/
374  SCIP_RESULT result;
375  int presolrounds;
376  presolrounds = -1;
377 
378  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
379 
380  SCIPdialogMessage(scip, NULL, "\n");
381  switch( SCIPgetStage(scip) )
382  {
383  case SCIP_STAGE_INIT:
384  SCIPdialogMessage(scip, NULL, "No problem exists\n");
385  break;
386 
387  case SCIP_STAGE_PROBLEM:
388  case SCIP_STAGE_TRANSFORMED:
389  case SCIP_STAGE_PRESOLVING:
390  if( DEChasDetectionRun(scip) || (DECgetBestDecomp(scip) != NULL) )
391  {
392  SCIP_CALL( SCIPgetIntParam(scip, "presolving/maxrounds", &presolrounds) );
393  SCIP_CALL( SCIPsetIntParam(scip, "presolving/maxrounds", 0) );
394  }
395 
396  SCIP_CALL( SCIPpresolve(scip) ); /*lint -fallthrough*/
397 
398  case SCIP_STAGE_PRESOLVED:
399  if( !DEChasDetectionRun(scip) )
400  {
401  SCIP_CALL( DECdetectStructure(scip, &result) );
402  if( result == SCIP_DIDNOTFIND )
403  {
404  assert(DECgetBestDecomp(scip) == NULL && DEChasDetectionRun(scip));
405  SCIPdialogMessage(scip, NULL, "No decomposition exists or could be detected. You need to specify one.\n");
406  break;
407  }
408  }
409  else if( DECgetBestDecomp(scip) == NULL )
410  {
411  assert(DECgetBestDecomp(scip) == NULL && DEChasDetectionRun(scip));
412  SCIPdialogMessage(scip, NULL, "No decomposition exists or could be detected. You need to specify one.\n");
413  break;
414  }
415  /*lint -fallthrough*/
416  case SCIP_STAGE_SOLVING:
417  SCIP_CALL( SCIPsolve(scip) );
418  break;
419 
420  case SCIP_STAGE_SOLVED:
421  SCIPdialogMessage(scip, NULL, "Problem is already solved\n");
422  break;
423 
424  case SCIP_STAGE_TRANSFORMING:
425  case SCIP_STAGE_INITPRESOLVE:
426  case SCIP_STAGE_EXITPRESOLVE:
427  case SCIP_STAGE_INITSOLVE:
428  case SCIP_STAGE_EXITSOLVE:
429  case SCIP_STAGE_FREETRANS:
430  case SCIP_STAGE_FREE:
431  default:
432  SCIPerrorMessage("Invalid SCIP stage\n");
433  return SCIP_INVALIDCALL;
434  }
435  SCIPdialogMessage(scip, NULL, "\n");
436 
437  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
438 
439  if( presolrounds != -1 )
440  {
441  SCIP_CALL( SCIPsetIntParam(scip, "presolving/maxrounds", presolrounds) );
442  }
443 
444  return SCIP_OKAY;
445 }
446 
448 static
449 SCIP_DECL_DIALOGEXEC(GCGdialogExecWriteAllDecompositions)
450 {
451  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
452 
453  if( SCIPgetStage(scip) >= SCIP_STAGE_PROBLEM )
454  {
455  SCIP_CALL( writeAllDecompositions(scip, dialog, dialoghdlr, nextdialog) );
456  }
457  else
458  SCIPdialogMessage(scip, NULL, "no problem available\n");
459 
460  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
461 
462  return SCIP_OKAY;
463 }
464 
466 static
467 SCIP_DECL_DIALOGEXEC(GCGdialogExecWriteStatistics)
468 {
469  char* filename;
470  SCIP_Bool endoffile;
471 
472  SCIPdialogMessage(scip, NULL, "\n");
473 
474  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "enter filename: ", &filename, &endoffile) );
475  if( endoffile )
476  {
477  *nextdialog = NULL;
478  return SCIP_OKAY;
479  }
480  if( filename[0] != '\0' )
481  {
482  FILE* file;
483 
484  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, filename, TRUE) );
485 
486  file = fopen(filename, "w");
487  if( file == NULL )
488  {
489  SCIPdialogMessage(scip, NULL, "error creating file <%s>\n", filename);
490  SCIPprintSysError(filename);
491  SCIPdialoghdlrClearBuffer(dialoghdlr);
492  }
493  else
494  {
495  SCIP_RETCODE retcode;
496  retcode = GCGprintStatistics(scip, file);
497  if( retcode != SCIP_OKAY )
498  {
499  fclose(file);
500  SCIP_CALL( retcode );
501  }
502  else
503  {
504  SCIPdialogMessage(scip, NULL, "written statistics to file <%s>\n", filename);
505  fclose(file);
506  }
507  }
508  }
509 
510  SCIPdialogMessage(scip, NULL, "\n");
511 
512  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
513 
514  return SCIP_OKAY;
515 }
517 SCIP_DECL_DIALOGEXEC(SCIPdialogExecSetDetectorsAggressive)
518 { /*lint --e{715}*/
519  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
520 
521  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
522 
523  SCIP_CALL( GCGsetDetection(scip, SCIP_PARAMSETTING_AGGRESSIVE, FALSE) );
524 
525  return SCIP_OKAY;
526 }
527 
529 SCIP_DECL_DIALOGEXEC(SCIPdialogExecSetDetectorsDefault)
530 { /*lint --e{715}*/
531  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
532 
533  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
534 
535  SCIP_CALL( GCGsetDetection(scip, SCIP_PARAMSETTING_DEFAULT, FALSE) );
536 
537  return SCIP_OKAY;
538 }
539 
541 SCIP_DECL_DIALOGEXEC(SCIPdialogExecSetDetectorsOff)
542 { /*lint --e{715}*/
543  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
544 
545  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
546 
547  SCIP_CALL( GCGsetDetection(scip, SCIP_PARAMSETTING_OFF, FALSE) );
548 
549  return SCIP_OKAY;
550 }
551 
553 SCIP_DECL_DIALOGEXEC(SCIPdialogExecSetDetectorsFast)
554 { /*lint --e{715}*/
555  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
556 
557  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
558 
559  SCIP_CALL( GCGsetDetection(scip, SCIP_PARAMSETTING_FAST, FALSE) );
560 
561  return SCIP_OKAY;
562 }
563 
565 SCIP_DECL_DIALOGEXEC(GCGdialogExecSetHeuristicsAggressive)
566 { /*lint --e{715}*/
567  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
568 
569  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
570 
571  SCIP_CALL( SCIPsetHeuristics(scip, SCIP_PARAMSETTING_AGGRESSIVE, FALSE) );
572  SCIP_CALL( GCGsetHeuristics(scip, SCIP_PARAMSETTING_AGGRESSIVE) );
573 
574  return SCIP_OKAY;
575 }
576 
578 SCIP_DECL_DIALOGEXEC(GCGdialogExecSetHeuristicsOff)
579 { /*lint --e{715}*/
580  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
581 
582  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
583 
584  SCIP_CALL( SCIPsetHeuristics(scip, SCIP_PARAMSETTING_OFF, FALSE) );
585  SCIP_CALL( GCGsetHeuristics(scip, SCIP_PARAMSETTING_OFF) );
586 
587  return SCIP_OKAY;
588 }
589 
591 SCIP_DECL_DIALOGEXEC(GCGdialogExecSetHeuristicsFast)
592 { /*lint --e{715}*/
593  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) );
594 
595  *nextdialog = SCIPdialoghdlrGetRoot(dialoghdlr);
596 
597  SCIP_CALL( SCIPsetHeuristics(scip, SCIP_PARAMSETTING_FAST, FALSE) );
598  SCIP_CALL( GCGsetHeuristics(scip, SCIP_PARAMSETTING_FAST) );
599 
600  return SCIP_OKAY;
601 }
602 
604 SCIP_RETCODE GCGcreateRootDialog(
605  SCIP* scip,
606  SCIP_DIALOG** root
607  )
608 {
609  SCIP_CALL( SCIPincludeDialog(scip, root, NULL, SCIPdialogExecMenuLazy, NULL, NULL,
610  "GCG", "GCG's main menu", TRUE, NULL) );
611 
612  SCIP_CALL( SCIPsetRootDialog(scip, *root) );
613  SCIP_CALL( SCIPreleaseDialog(scip, root) );
614  *root = SCIPgetRootDialog(scip);
615 
616  return SCIP_OKAY;
617 }
618 
620 static
622  SCIP* scip,
623  SCIP_DIALOG* root,
624  SCIP_DIALOG** submenu
625  )
626 {
627  if( !SCIPdialogHasEntry(root, "emphasis") )
628  {
629  SCIP_CALL( SCIPincludeDialog(scip, submenu,
630  NULL, SCIPdialogExecMenu, NULL, NULL,
631  "emphasis", "predefined parameter settings", TRUE, NULL) );
632  SCIP_CALL( SCIPaddDialogEntry(scip, root, *submenu) );
633  SCIP_CALL( SCIPreleaseDialog(scip, submenu) );
634  }
635  else if( SCIPdialogFindEntry(root, "emphasis", submenu) != 1 )
636  {
637  SCIPerrorMessage("emphasis sub menu not found\n");
638  return SCIP_PLUGINNOTFOUND;
639  }
640 
641  assert(*submenu != NULL);
642 
643  return SCIP_OKAY;
644 }
645 
647 SCIP_RETCODE SCIPincludeDialogGcg(
648  SCIP* scip
649  )
650 {
651  SCIP_DIALOG* root;
652  SCIP_DIALOG* submenu;
653  SCIP_DIALOG* dialog;
654  SCIP_DIALOG* setmenu;
655  SCIP_DIALOG* emphasismenu;
656 
657  /* root menu */
658  root = SCIPgetRootDialog(scip);
659  if( root == NULL )
660  {
661  SCIP_CALL( GCGcreateRootDialog(scip, &root) );
662  }
663 
664  /* display */
665  if( !SCIPdialogHasEntry(root, "display") )
666  {
667  SCIP_CALL( SCIPincludeDialog(scip, &submenu, NULL, SCIPdialogExecMenu, NULL, NULL,
668  "display", "display information", TRUE, NULL) );
669  SCIP_CALL( SCIPaddDialogEntry(scip, root, submenu) );
670  SCIP_CALL( SCIPreleaseDialog(scip, &submenu) );
671  }
672  if( SCIPdialogFindEntry(root, "display", &submenu) != 1 )
673  {
674  SCIPerrorMessage("display sub menu not found\n");
675  return SCIP_PLUGINNOTFOUND;
676  }
677 
678  /* display statistics */
679  if( !SCIPdialogHasEntry(submenu, "statistics") )
680  {
681  SCIP_CALL( SCIPincludeDialog(scip, &dialog, NULL, GCGdialogExecDisplayStatistics, NULL, NULL,
682  "statistics", "display problem and optimization statistics", FALSE, NULL) );
683  SCIP_CALL( SCIPaddDialogEntry(scip, submenu, dialog) );
684  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
685  }
686  /* display decomposition */
687  if( !SCIPdialogHasEntry(submenu, "decomposition") )
688  {
689  SCIP_CALL( SCIPincludeDialog(scip, &dialog, NULL, GCGdialogExecDisplayDecomposition, NULL, NULL,
690  "decomposition", "display decomposition", FALSE, NULL) );
691  SCIP_CALL( SCIPaddDialogEntry(scip, submenu, dialog) );
692  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
693  }
694 
695  /* display additionalstatistics */
696  if( !SCIPdialogHasEntry(submenu, "additionalstatistics") )
697  {
698  SCIP_CALL( SCIPincludeDialog(scip, &dialog, NULL, GCGdialogExecDisplayAdditionalStatistics, NULL, NULL,
699  "additionalstatistics", "display additional solving statistics", FALSE, NULL) );
700  SCIP_CALL( SCIPaddDialogEntry(scip, submenu, dialog) );
701  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
702  }
703 
704  /* display detectors */
705  if( !SCIPdialogHasEntry(submenu, "detectors") )
706  {
707  SCIP_CALL( SCIPincludeDialog(scip, &dialog, NULL, GCGdialogExecDisplayDetectors, NULL, NULL,
708  "detectors", "display available detectors", FALSE, NULL) );
709  SCIP_CALL( SCIPaddDialogEntry(scip, submenu, dialog) );
710  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
711  }
712 
713  /* display solvers */
714  if( !SCIPdialogHasEntry(submenu, "solvers") )
715  {
716  SCIP_CALL( SCIPincludeDialog(scip, &dialog, NULL, GCGdialogExecDisplaySolvers, NULL, NULL,
717  "solvers", "display available pricing problem solvers", FALSE, NULL) );
718  SCIP_CALL( SCIPaddDialogEntry(scip, submenu, dialog) );
719  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
720  }
721 
722  /* master */
723  if( !SCIPdialogHasEntry(root, "master") )
724  {
725  SCIP_CALL( SCIPincludeDialog(scip, &dialog, NULL, GCGdialogExecSetMaster, NULL, NULL,
726  "master", "switch to the interactive shell of the master problem", FALSE, NULL) );
727  SCIP_CALL( SCIPaddDialogEntry(scip, root, dialog) );
728  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
729  }
730 
731  /* optimize */
732  if( !SCIPdialogHasEntry(root, "optimize") )
733  {
734  SCIP_CALL( SCIPincludeDialog(scip, &dialog,
735  NULL,
736  GCGdialogExecOptimize, NULL, NULL,
737  "optimize", "solve the problem", FALSE, NULL) );
738  SCIP_CALL( SCIPaddDialogEntry(scip, root, dialog) );
739  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
740  }
741 
742 
743  /* detect */
744  if( !SCIPdialogHasEntry(root, "detect") )
745  {
746  SCIP_CALL( SCIPincludeDialog(scip, &dialog, NULL, GCGdialogExecDetect, NULL, NULL,
747  "detect", "Detect structure", FALSE, NULL) );
748  SCIP_CALL( SCIPaddDialogEntry(scip, root, dialog) );
749  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
750  }
751 
752  /* quit */
753  if( !SCIPdialogHasEntry(root, "quit") )
754  {
755  SCIP_CALL( SCIPincludeDialog(scip, &dialog,
756  NULL,
757  SCIPdialogExecQuit, NULL, NULL,
758  "quit", "leave GCG", FALSE, NULL) );
759  SCIP_CALL( SCIPaddDialogEntry(scip, root, dialog) );
760  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
761  }
762 
763  /* set */
764  if( !SCIPdialogHasEntry(root, "set") )
765  {
766  SCIP_CALL( SCIPincludeDialog(scip, &submenu,
767  NULL, SCIPdialogExecMenu, NULL, NULL,
768  "set", "load/save/change parameters", TRUE, NULL) );
769  SCIP_CALL( SCIPaddDialogEntry(scip, root, submenu) );
770  SCIP_CALL( SCIPreleaseDialog(scip, &submenu) );
771  }
772  if( SCIPdialogFindEntry(root, "set", &setmenu) != 1 )
773  {
774  SCIPerrorMessage("set sub menu not found\n");
775  return SCIP_PLUGINNOTFOUND;
776  }
777 
778  /* set loadmaster */
779  if( !SCIPdialogHasEntry(setmenu, "loadmaster") )
780  {
781  SCIP_CALL( SCIPincludeDialog(scip, &dialog,
782  NULL,
783  GCGdialogExecSetLoadmaster, NULL, NULL,
784  "loadmaster", "load parameter settings for master problem from a file", FALSE, NULL) );
785  SCIP_CALL( SCIPaddDialogEntry(scip, setmenu, dialog) );
786  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
787  }
788 
789  /* set detectors */
790  if( !SCIPdialogHasEntry(setmenu, "detectors") )
791  {
792  SCIP_CALL( SCIPincludeDialog(scip, &submenu,
793  NULL,
794  SCIPdialogExecMenu, NULL, NULL,
795  "detectors", "change parameters for detectors", TRUE, NULL) );
796  SCIP_CALL( SCIPaddDialogEntry(scip, setmenu, submenu) );
797  SCIP_CALL( SCIPreleaseDialog(scip, &submenu) );
798  }
799  if( SCIPdialogFindEntry(setmenu, "detectors", &submenu) != 1 )
800  {
801  SCIPerrorMessage("detectors sub menu not found\n");
802  return SCIP_PLUGINNOTFOUND;
803  }
804 
805  /* create set detectors emphasis */
806  SCIP_CALL( createEmphasisSubmenu(scip, submenu, &emphasismenu) );
807  assert(emphasismenu != NULL);
808 
809  /* set detectors emphasis aggressive */
810  if( !SCIPdialogHasEntry(emphasismenu, "aggressive") )
811  {
812  SCIP_CALL( SCIPincludeDialog(scip, &dialog,
813  NULL, SCIPdialogExecSetDetectorsAggressive, NULL, NULL,
814  "aggressive", "sets detectors <aggressive>", FALSE, NULL) );
815  SCIP_CALL( SCIPaddDialogEntry(scip, emphasismenu, dialog) );
816  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
817  }
818 
819  /* set detectors emphasis default */
820  if( !SCIPdialogHasEntry(emphasismenu, "default") )
821  {
822  SCIP_CALL( SCIPincludeDialog(scip, &dialog,
823  NULL, SCIPdialogExecSetDetectorsDefault, NULL, NULL,
824  "default", "sets detectors <default>", FALSE, NULL) );
825  SCIP_CALL( SCIPaddDialogEntry(scip, emphasismenu, dialog) );
826  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
827  }
828 
829  /* set detectors emphasis fast */
830  if( !SCIPdialogHasEntry(emphasismenu, "fast") )
831  {
832  SCIP_CALL( SCIPincludeDialog(scip, &dialog,
833  NULL, SCIPdialogExecSetDetectorsFast, NULL, NULL,
834  "fast", "sets detectors <fast>", FALSE, NULL) );
835  SCIP_CALL( SCIPaddDialogEntry(scip, emphasismenu, dialog) );
836  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
837  }
838 
839  /* set detectors emphasis off */
840  if( !SCIPdialogHasEntry(emphasismenu, "off") )
841  {
842  SCIP_CALL( SCIPincludeDialog(scip, &dialog,
843  NULL, SCIPdialogExecSetDetectorsOff, NULL, NULL,
844  "off", "turns <off> all detectors", FALSE, NULL) );
845  SCIP_CALL( SCIPaddDialogEntry(scip, emphasismenu, dialog) );
846  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
847  }
848 
849  /* set heuristics */
850  if( !SCIPdialogHasEntry(setmenu, "heuristics") )
851  {
852  SCIP_CALL( SCIPincludeDialog(scip, &submenu,
853  NULL,
854  SCIPdialogExecMenu, NULL, NULL,
855  "heuristics", "change parameters for primal heuristics", TRUE, NULL) );
856  SCIP_CALL( SCIPaddDialogEntry(scip, setmenu, submenu) );
857  SCIP_CALL( SCIPreleaseDialog(scip, &submenu) );
858  }
859  if( SCIPdialogFindEntry(setmenu, "heuristics", &submenu) != 1 )
860  {
861  SCIPerrorMessage("heuristics sub menu not found\n");
862  return SCIP_PLUGINNOTFOUND;
863  }
864 
865  /* create set heuristics emphasis */
866  SCIP_CALL( createEmphasisSubmenu(scip, submenu, &emphasismenu) );
867  assert(emphasismenu != NULL);
868 
869  /* set heuristics emphasis aggressive */
870  if( !SCIPdialogHasEntry(emphasismenu, "aggressive") )
871  {
872  SCIP_CALL( SCIPincludeDialog(scip, &dialog,
873  NULL, GCGdialogExecSetHeuristicsAggressive, NULL, NULL,
874  "aggressive", "sets heuristics <aggressive>", FALSE, NULL) );
875  SCIP_CALL( SCIPaddDialogEntry(scip, emphasismenu, dialog) );
876  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
877  }
878 
879  /* set heuristics emphasis fast */
880  if( !SCIPdialogHasEntry(emphasismenu, "fast") )
881  {
882  SCIP_CALL( SCIPincludeDialog(scip, &dialog,
883  NULL, GCGdialogExecSetHeuristicsFast, NULL, NULL,
884  "fast", "sets heuristics <fast>", FALSE, NULL) );
885  SCIP_CALL( SCIPaddDialogEntry(scip, emphasismenu, dialog) );
886  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
887  }
888 
889  /* set heuristics emphasis off */
890  if( !SCIPdialogHasEntry(emphasismenu, "off") )
891  {
892  SCIP_CALL( SCIPincludeDialog(scip, &dialog,
893  NULL, GCGdialogExecSetHeuristicsOff, NULL, NULL,
894  "off", "turns <off> all heuristics", FALSE, NULL) );
895  SCIP_CALL( SCIPaddDialogEntry(scip, emphasismenu, dialog) );
896  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
897  }
898 
899  /* write */
900  if( !SCIPdialogHasEntry(root, "write") )
901  {
902  SCIP_CALL( SCIPincludeDialog(scip, &submenu, NULL, SCIPdialogExecMenu, NULL, NULL,
903  "write", "write information to file", TRUE, NULL) );
904  SCIP_CALL( SCIPaddDialogEntry(scip, root, submenu) );
905  SCIP_CALL( SCIPreleaseDialog(scip, &submenu) );
906  }
907  if( SCIPdialogFindEntry(root, "write", &submenu) != 1 )
908  {
909  SCIPerrorMessage("write sub menu not found\n");
910  return SCIP_PLUGINNOTFOUND;
911  }
912 
913  /* write alldecompositions */
914  if( !SCIPdialogHasEntry(submenu, "alldecompositions") )
915  {
916  SCIP_CALL( SCIPincludeDialog(scip, &dialog, NULL, GCGdialogExecWriteAllDecompositions, NULL, NULL,
917  "alldecompositions",
918  "write all known decompostions to file (format is given by file extension, e.g., {dec,blk,ref})",
919  FALSE, NULL) );
920  SCIP_CALL( SCIPaddDialogEntry(scip, submenu, dialog) );
921  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
922  }
923 
924  /* write statistics */
925  if( !SCIPdialogHasEntry(submenu, "statistics") )
926  {
927  SCIP_CALL( SCIPincludeDialog(scip, &dialog, NULL, GCGdialogExecWriteStatistics, NULL, NULL,
928  "statistics",
929  "write statistics to file",
930  FALSE, NULL) );
931  SCIP_CALL( SCIPaddDialogEntry(scip, submenu, dialog) );
932  SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
933  }
934 
935 
936  return SCIP_OKAY;
937 }
SCIP_RETCODE GCGprintStatistics(SCIP *scip, FILE *file)
Definition: misc.c:432
SCIP_RETCODE GCGwriteDecompositionData(SCIP *scip)
Definition: stat.c:46
GCG interface methods.
DEC_DECOMP * DECgetBestDecomp(SCIP *scip)
Definition: cons_decomp.c:735
static SCIP_RETCODE writeAllDecompositions(SCIP *scip, SCIP_DIALOG *dialog, SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG **nextdialog)
Definition: dialog_gcg.c:95
SCIP * GCGgetMasterprob(SCIP *scip)
Definition: relax_gcg.c:2868
DEC file reader for structure information.
Prints information about the best decomposition.
void GCGpricerPrintStatistics(SCIP *scip, FILE *file)
DEC_DECTYPE DECdecompGetType(DEC_DECOMP *decomp)
Definition: decomp.c:529
SCIP_RETCODE GCGcreateRootDialog(SCIP *scip, SCIP_DIALOG **root)
Definition: dialog_gcg.c:604
SCIP_RETCODE DECdetectStructure(SCIP *scip, SCIP_RESULT *result)
Definition: cons_decomp.c:505
static SCIP_RETCODE createEmphasisSubmenu(SCIP *scip, SCIP_DIALOG *root, SCIP_DIALOG **submenu)
Definition: dialog_gcg.c:621
void GCGpricerPrintListOfSolvers(SCIP *scip)
SCIP_DECL_DIALOGEXEC(GCGdialogExecDisplayStatistics)
Definition: dialog_gcg.c:193
static void displayReaders(SCIP *scip, SCIP_Bool reader, SCIP_Bool writer)
Definition: dialog_gcg.c:58
GCG relaxator.
SCIP_RETCODE DECwriteAllDecomps(SCIP *scip, char *directory, char *extension)
Definition: cons_decomp.c:654
GCG variable pricer.
SCIP_RETCODE GCGsetHeuristics(SCIP *scip, SCIP_PARAMSETTING paramsetting)
Definition: gcgheur.c:152
int SCIPconshdlrDecompGetNDecdecomps(SCIP *scip)
Definition: cons_decomp.c:338
SCIP_RETCODE SCIPincludeDialogGcg(SCIP *scip)
Definition: dialog_gcg.c:647
SCIP_RETCODE GCGwriteDecomp(SCIP *scip, FILE *file, DEC_DECOMP *decdecomp)
Definition: reader_dec.c:1085
GCG user interface dialog.
constraint handler for structure detection
struct DecDecomp DEC_DECOMP
Definition: type_decomp.h:43
SCIP_Bool DEChasDetectionRun(SCIP *scip)
Definition: cons_decomp.c:806
SCIP_RETCODE GCGsetDetection(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: cons_decomp.c:958
SCIP_RETCODE GCGwriteVarCreationDetails(SCIP *scip)
Definition: stat.c:100
void DECprintListOfDetectors(SCIP *scip)
Definition: cons_decomp.c:776
public methods for GCG heuristics