naginterfaces.library.opt.handle_opt_set_file(handle, infile, io_manager=None)[source]

handle_opt_set_file is an option setting function for all solvers from the NAG optimization modelling suite. It can set one or more options from an external file.

For full information please refer to the NAG Library document for e04zp


The handle to the problem. It needs to be initialized (e.g., by handle_init()) and must not be changed between calls to the NAG optimization modelling suite.


The file identifier associated with the argument data file. Note: that the file needs to be opened in read mode.

io_managerFileObjManager, optional

Manager for I/O in this routine.

(errno )

has not been initialized.

(errno )

does not belong to the NAG optimization modelling suite, has not been initialized properly or is corrupted.

(errno )

has not been initialized properly or is corrupted.

(errno )

The options cannot be modified while solver is running.

(errno )

On entry, .

Constraint: .

(errno )

End-of-file or read error detected before BEGIN was found.

(errno )

BEGIN found, but end-of-file found before END.

(errno )

The provided on line was not recognized.

(errno )

The expected delimiter ‘’ was not found on line .

(errno )

The provided on line could not be converted to the expected numerical type.

(errno )

The provided on line for the integer option is out of bounds.

(errno )

The provided on line for the real option is out of bounds.

(errno )

The provided on line for the character option is not valid.


handle_opt_set_file may be used to supply values for options to the solver from an external file. It can only be called on handles which have been correctly initialized (e.g., by handle_init()) and before the call to the solver. handle_opt_set_file looks in the file for a specific section containing the optional parameters. The section must start with a line Begin and must finish with a line End. Anything outside the section is ignored. If there is more than one section like this, only the first one is processed. Any line within the section is either blank or a comment which is ignored or defines a single option as if it had been set by handle_opt_set(). The implied data type (character, integer or real) of each value to be set must match that expected by the corresponding option. It is only necessary to supply values for those arguments whose values are to be different from their default values. A comment begins with an asterisk (*) and all subsequent characters to the end of the line are ignored. Comments can also be placed after the option. The file is case insensitive.

Note that the options printed by the solver or by handle_print() are in the compatible format. An example of a valid options file is:

Begin * Example options file
   Print Level = 3
   Monitoring Level = 5 * output all details
   Monitoring File = 42 * to this file

See the E04 Introduction for more details about the NAG optimization modelling suite.