Skip to content

Commit

Permalink
Merge branch 'extend_command_line_commands' into 'master'
Browse files Browse the repository at this point in the history
Extend command line commands

See merge request integer/scip!3598
  • Loading branch information
pfetsch committed Dec 2, 2024
2 parents 346ad2f + 97c1449 commit 959072b
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,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

Expand All @@ -61,6 +62,10 @@ Interface changes

### Command line interface

- help <command> 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
Expand Down
21 changes: 20 additions & 1 deletion src/scip/dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ SCIP_RETCODE SCIPdialogCreate(
(*dialog)->subdialogssize = 0;
(*dialog)->nuses = 0;
(*dialog)->dialogdata = dialogdata;
(*dialog)->hidden = FALSE;

/* capture dialog */
SCIPdialogCapture(*dialog);
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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) );
}
Expand Down
62 changes: 56 additions & 6 deletions src/scip/dialog_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command>" */
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);
Expand Down Expand Up @@ -2427,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 )
{
Expand Down Expand Up @@ -3364,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 )
{
Expand Down Expand Up @@ -3554,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 )
{
Expand Down Expand Up @@ -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 <command> to show information on specific command)", FALSE, NULL) );
SCIP_CALL( SCIPaddDialogEntry(scip, root, dialog) );
SCIP_CALL( SCIPreleaseDialog(scip, &dialog) );
}
Expand Down Expand Up @@ -4579,8 +4614,23 @@ SCIP_RETCODE SCIPincludeDialogDefaultBasic(
SCIP_CALL( SCIPincludeDialog(scip, &dialog,
NULL,
SCIPdialogExecQuit, NULL, NULL,
"quit", "leave SCIP", FALSE, NULL) );
"quit", "leave SCIP (<exit> 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) );
}

Expand Down
10 changes: 10 additions & 0 deletions src/scip/pub_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/scip/struct_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 959072b

Please sign in to comment.