From 403cb9d1a9bf5da9b924d8ff22216d4e4cf992eb Mon Sep 17 00:00:00 2001 From: Marc Pfetsch Date: Sat, 23 Nov 2024 17:18:59 +0100 Subject: [PATCH 1/5] allow for "help " in command line interface --- src/scip/dialog_default.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/scip/dialog_default.c b/src/scip/dialog_default.c index eb21b2573a..4aca4a55bf 100644 --- a/src/scip/dialog_default.c +++ b/src/scip/dialog_default.c @@ -2030,7 +2030,42 @@ SCIP_DECL_DIALOGEXEC(SCIPdialogExecHelp) SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) ); SCIPdialogMessage(scip, NULL, "\n"); - SCIP_CALL( SCIPdialogDisplayMenu(SCIPdialogGetParent(dialog), scip) ); + + /* check whether the user entered "help " */ + if( ! SCIPdialoghdlrIsBufferEmpty(dialoghdlr) ) + { + SCIP_DIALOG* rootdialog; + SCIP_DIALOG* subdialog; + SCIP_Bool endoffile; + char* command; + + /* get command as next word on line */ + SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, NULL, &command, &endoffile) ); + + /* search for command */ + rootdialog = SCIPdialoghdlrGetRoot(dialoghdlr); + if ( SCIPdialogFindEntry(rootdialog, command, &subdialog) ) + { + /* if the command has subdialogs */ + if( SCIPdialogGetNSubdialogs(subdialog) > 0 ) + { + /* print information on command itself and its subdialogs */ + SCIP_CALL( SCIPdialogDisplayMenuEntry(subdialog, scip) ); + SCIPdialogMessage(scip, NULL, "\n"); + SCIP_CALL( SCIPdialogDisplayMenu(subdialog, scip) ); + } + else + { + /* print information on command */ + SCIP_CALL( SCIPdialogDisplayMenuEntry(subdialog, scip) ); + } + } + } + else + { + /* print information on all subdialogs */ + SCIP_CALL( SCIPdialogDisplayMenu(SCIPdialogGetParent(dialog), scip) ); + } SCIPdialogMessage(scip, NULL, "\n"); *nextdialog = SCIPdialogGetParent(dialog); @@ -4511,7 +4546,7 @@ SCIP_RETCODE SCIPincludeDialogDefaultBasic( SCIP_CALL( SCIPincludeDialog(scip, &dialog, NULL, SCIPdialogExecHelp, NULL, NULL, - "help", "display this help", FALSE, NULL) ); + "help", "display this help (add to show information on specific command)", FALSE, NULL) ); SCIP_CALL( SCIPaddDialogEntry(scip, root, dialog) ); SCIP_CALL( SCIPreleaseDialog(scip, &dialog) ); } From 2c767e6a37301d620e22dc27379901bf75f29c5d Mon Sep 17 00:00:00 2001 From: Marc Pfetsch Date: Sat, 23 Nov 2024 17:19:22 +0100 Subject: [PATCH 2/5] style --- src/scip/dialog_default.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scip/dialog_default.c b/src/scip/dialog_default.c index 4aca4a55bf..709b2b8a0b 100644 --- a/src/scip/dialog_default.c +++ b/src/scip/dialog_default.c @@ -2462,7 +2462,7 @@ SCIP_DECL_DIALOGEXEC(SCIPdialogExecSetSave) SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, filename, TRUE) ); - retcode = SCIPwriteParams(scip, filename, TRUE, FALSE); + retcode = SCIPwriteParams(scip, filename, TRUE, FALSE); if( retcode == SCIP_FILECREATEERROR ) { @@ -3399,7 +3399,7 @@ SCIP_DECL_DIALOGEXEC(SCIPdialogExecWriteLp) SCIP_RETCODE retcode; SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, filename, TRUE) ); - retcode = SCIPwriteLP(scip, filename); + retcode = SCIPwriteLP(scip, filename); if( retcode == SCIP_FILECREATEERROR ) { @@ -3589,7 +3589,7 @@ SCIP_DECL_DIALOGEXEC(SCIPdialogExecWriteNlp) SCIP_RETCODE retcode; SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, filename, TRUE) ); - retcode = SCIPwriteNLP(scip, filename); + retcode = SCIPwriteNLP(scip, filename); if( retcode == SCIP_FILECREATEERROR ) { From 31990ff0d1f42f6ae8ec9d615559fa981a078052 Mon Sep 17 00:00:00 2001 From: Marc Pfetsch Date: Sat, 23 Nov 2024 17:35:36 +0100 Subject: [PATCH 3/5] add possibility to hide dialogs in help list --- src/scip/dialog.c | 21 ++++++++++++++++++++- src/scip/pub_dialog.h | 10 ++++++++++ src/scip/struct_dialog.h | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/scip/dialog.c b/src/scip/dialog.c index 909a957e8b..8344851de1 100644 --- a/src/scip/dialog.c +++ b/src/scip/dialog.c @@ -861,6 +861,7 @@ SCIP_RETCODE SCIPdialogCreate( (*dialog)->subdialogssize = 0; (*dialog)->nuses = 0; (*dialog)->dialogdata = dialogdata; + (*dialog)->hidden = FALSE; /* capture dialog */ SCIPdialogCapture(*dialog); @@ -935,6 +936,24 @@ SCIP_RETCODE SCIPdialogRelease( return SCIP_OKAY; } +/** is dialog hidden */ +SCIP_Bool SCIPdialogIsHidden( + SCIP_DIALOG* dialog /**< dialog */ + ) +{ + assert(dialog != NULL); + return dialog->hidden; +} + +/** set dialog to be hidden */ +void SCIPdialogSetHidden( + SCIP_DIALOG* dialog /**< dialog */ + ) +{ + assert(dialog != NULL); + dialog->hidden = TRUE; +} + /** executes dialog */ SCIP_RETCODE SCIPdialogExec( SCIP_DIALOG* dialog, /**< dialog */ @@ -1090,7 +1109,7 @@ SCIP_RETCODE SCIPdialogDisplayMenu( /* display the dialog's menu options */ for( i = 0; i < dialog->nsubdialogs; ++i ) { - if( !SCIPdialogIsSubmenu(dialog->subdialogs[i]) ) + if( !SCIPdialogIsSubmenu(dialog->subdialogs[i]) && ! SCIPdialogIsHidden(dialog->subdialogs[i]) ) { SCIP_CALL( SCIPdialogDisplayMenuEntry(dialog->subdialogs[i], scip) ); } diff --git a/src/scip/pub_dialog.h b/src/scip/pub_dialog.h index 99b97f461f..ea5f552558 100644 --- a/src/scip/pub_dialog.h +++ b/src/scip/pub_dialog.h @@ -219,6 +219,16 @@ void SCIPdialogSetData( SCIP_DIALOGDATA* dialogdata /**< new dialog user data */ ); +/** is dialog hidden */ +SCIP_Bool SCIPdialogIsHidden( + SCIP_DIALOG* dialog /**< dialog */ + ); + +/** set dialog to be hidden */ +void SCIPdialogSetHidden( + SCIP_DIALOG* dialog /**< dialog */ + ); + /** writes command history to specified filename */ SCIP_EXPORT SCIP_RETCODE SCIPdialogWriteHistory( diff --git a/src/scip/struct_dialog.h b/src/scip/struct_dialog.h index 80b50c23d4..ca5ed4f7cd 100644 --- a/src/scip/struct_dialog.h +++ b/src/scip/struct_dialog.h @@ -57,6 +57,7 @@ struct SCIP_Dialog int subdialogssize; /**< size of subdialogs array */ int nuses; /**< number of times, the dialog is used */ SCIP_Bool issubmenu; /**< is the dialog a submenu? */ + SCIP_Bool hidden; /**< dialog is hidden in the help list? */ }; /** linked list of single input lines */ From e8d78319e05f971dfa25b679d9a1e6241d4606b0 Mon Sep 17 00:00:00 2001 From: Marc Pfetsch Date: Sat, 23 Nov 2024 17:35:57 +0100 Subject: [PATCH 4/5] add hidden command --- src/scip/dialog_default.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/scip/dialog_default.c b/src/scip/dialog_default.c index 709b2b8a0b..1c0857c994 100644 --- a/src/scip/dialog_default.c +++ b/src/scip/dialog_default.c @@ -4614,11 +4614,26 @@ SCIP_RETCODE SCIPincludeDialogDefaultBasic( SCIP_CALL( SCIPincludeDialog(scip, &dialog, NULL, SCIPdialogExecQuit, NULL, NULL, - "quit", "leave SCIP", FALSE, NULL) ); + "quit", "leave SCIP ( works as well)", FALSE, NULL) ); SCIP_CALL( SCIPaddDialogEntry(scip, root, dialog) ); SCIP_CALL( SCIPreleaseDialog(scip, &dialog) ); } + /* exit - same as quit */ + if( !SCIPdialogHasEntry(root, "exit") ) + { + SCIP_CALL( SCIPincludeDialog(scip, &dialog, + NULL, + SCIPdialogExecQuit, NULL, NULL, + "exit", "leave SCIP", FALSE, NULL) ); + SCIP_CALL( SCIPaddDialogEntry(scip, root, dialog) ); + + /* mark command as hidden, because "exit" is already there */ + SCIPdialogSetHidden(dialog); + + SCIP_CALL( SCIPreleaseDialog(scip, &dialog) ); + } + /* read */ if( !SCIPdialogHasEntry(root, "read") ) { From 9821f159bfa9520a3e9c7440cb9bc7180b3bd73f Mon Sep 17 00:00:00 2001 From: Marc Pfetsch Date: Sat, 23 Nov 2024 17:36:11 +0100 Subject: [PATCH 5/5] add CHANGELOG entries --- CHANGELOG | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 2d8e567bd9..0a7d90e0ac 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -50,6 +50,7 @@ Interface changes - SCIPnetmatdecCreate() and SCIPnetmatdecFree() for creating and deleting a network matrix decomposition. SCIPnetmatdecTryAddCol() and SCIPnetmatdecTryAddRow() are used to add columns and rows of the matrix to the decomposition. SCIPnetmatdecContainsRow() and SCIPnetmatdecContainsColumn() check if the decomposition contains the given row or columns. SCIPnetmatdecRemoveComponent() can remove connected components from the decomposition. SCIPnetmatdecCreateDiGraph() can be used to expose the underlying digraph. SCIPnetmatdecIsMinimal() and SCIPnetmatdecVerifyCycle() check if certain invariants of the decomposition are satisfied and are used in tests. - SCIPfreeReaderdataCor(), SCIPfreeReaderdataTim() and SCIPfreeReaderdataSto() for freeing the data for the COR, TIM and STO readers respectively. These readers are all used when reading an SMPS instance. +- SCIPdialogIsHidden(), SCIPdialogSetHidden() to determine whether a dialog should be hidden in help list ### Changes in preprocessor macros @@ -58,6 +59,10 @@ Interface changes ### Command line interface +- help now allows to display information on specific command. +- allow to hide certain commands in the help list +- add the (hidden) command "exit¨ to exit SCIP. + ### Interfaces to external software ### Changed parameters