ampl / mp

An open-source library for mathematical programming
https://mp.ampl.com
Other
229 stars 42 forks source link

Using tech:optionfile in mosek_options #231

Open 4er4er4er opened 10 months ago

4er4er4er commented 10 months ago

A user would like to specify the value of the MSK_DPAR_INTPNT_TOL_PFEAS parameter for MOSEK. I thought that should be possible using this option:

tech:optionfile (optionfile, option:file) Name of solver option file to read (surrounded by 'single' or "double" quotes if the name contains blanks). Lines that start with # are ignored. Otherwise, each nonempty line should contain "name=value".

I created a file mosekopt.txt containing this line,

MSK_DPAR_INTPNT_TOL_PFEAS=1e-6

and I gave this command to AMPL before solving:

option mosek_options 'optionfile=mosekopt.txt';

It appears that MOSEK found the file, but rejected the contents:

MOSEK 10.0.43: Unknown option or invalid key "MSK_DPAR_INTPNT_TOL_PFEAS"

Can MSK_DPAR_INTPNT_TOL_PFEAS be specified using this option? And if so, how should it be written?

glebbelov commented 10 months ago

tech:optionfile means file with driver options (outlev etc.)

What you mean are the solver native options: https://mp.ampl.com/features-guide.html#native-solver-options. This is not implemented for Mosek, I can add this, and hope we can release today or tomorrow.

Any suggestions on clearer option names and help text to distinguish driver options vs native options?

glebbelov commented 10 months ago

Currently native parameters can be controlled via exporting the model as LP/MPS/JTASK etc. and solving by Mosek command-line tool.

Implemented and documented the following options for Mosek (and for Gurobi, which had them already, names were changed accordingly):

tech:optionfile (optionfile, option:file)
      Name of an AMPL solver option file to read (surrounded by 'single' or
      "double" quotes if the name contains blanks). Lines that start with #
      are ignored. Otherwise, each nonempty line should contain "name=value",
      e.g., "lim:iter=500".

tech:optionnative (optionnative, optnative, tech:param)
      General way to specify values of both documented and undocumented Mosek
      parameters; value should be a quoted string (delimited by ' or ")
      containing a parameter name, a space, and the value to be assigned to
      the parameter. Can appear more than once. Cannot be used to query
      current parameter values.

tech:optionnativeread (optionnativeread, tech:param:read, param:read)
      Name of Mosek parameter file (surrounded by 'single' or "double" quotes
      if the name contains blanks) to be read.

tech:optionnativewrite (optionnativewrite, tech:param:write, param:write)
      Name of Mosek parameter file (surrounded by 'single' or "double" quotes
      if the name contains blanks) to be written.

Among other solvers, only SCIP and GCG have tech:optionnativeread (tech:param:read).

4er4er4er commented 10 months ago

Thanks! Using tech:optionnativeread with MOSEK, what format is recognized for lines in the file that is read? I have tried

MSK_IPAR_LOG=1
MSK_DPAR_MIO_MAX_TIME=3

and

MSK_IPAR_LOG 1
MSK_DPAR_MIO_MAX_TIME 3

but I get a No parameters found warning and the options don't appear to take effect. (I do not get a Could not open the parameter file warning, so I think the file is being found.)

glebbelov commented 10 months ago

easiest is to say optionnativewrite=opt_default.prom and modify that.

Moses docs has no file format description. Basically it adds some header and footer.

4er4er4er commented 10 months ago

OK, now I see it. I can specify, say,

option mosek_options 'tech:optionnativeread=mosekopt.txt';

and then in the file mosekopt.txt I can put

BEGIN MOSEK
MSK_IPAR_LOG 1
MSK_DPAR_MIO_MAX_TIME 3
END MOSEK

The MOSEK docs could describe this format, with a reference to one of the MOSEK parameter listing pages, maybe https://docs.mosek.com/latest/cmdtools/param-groups.html.

glebbelov commented 10 months ago

Changed option text as follows (to appear in the next release):

tech:optionnativeread (optionnativeread, tech:param:read, param:read)
      Name of Mosek parameter file (surrounded by 'single' or "double" quotes
      if the name contains blanks) to be read. File format:

      BEGIN MOSEK
      MSK_DPAR_MIO_MAX_TIME 3
      END MOSEK

      Parameter descriptions:
      docs.mosek.com/latest/cmdtools/param-groups.html.