Skip to content

[FEA] Expose solver parameter enumeration and config-file round-trip through the C API #1705

Description

@ramakrishnap-nv

Is your feature request related to a problem? Please describe.

Python can enumerate solver parameters and round-trip them through a config file. The C API cannot, so no C-ABI binding can either.

PR #1524 briefly added four entry points for this, promoted from a private shim in the Java bindings:

  • cuOptGetNumSolverParameters(cuopt_int_t*)
  • cuOptGetSolverParameterName(cuopt_int_t index, cuopt_int_t size, char* name)
  • cuOptLoadParametersFromFile(cuOptSolverSettings, const char* path)
  • cuOptDumpParametersToFile(cuOptSolverSettings, const char* path, cuopt_int_t hyperparameters_only, cuopt_int_t* dumped)

They were removed again before merge. They are convenience rather than necessity — nothing needs them to build, solve, or read a solution — and the preference was to keep the public C API lean. Filing this so the capability is recorded rather than lost, and so there is somewhere to point if a user asks.

Describe the solution you'd like

If this is revisited, the pieces are independent and can land separately:

Parameter enumerationcuOptGetNumSolverParameters plus cuOptGetSolverParameterName, backed by solver_settings_t::get_parameter_names(), which already exists. This is what lets a binding present the full parameter list without hard-coding it, and what backed Java's SolverSettings.getSolverSettingNames() and toDict().

Config file round-tripcuOptLoadParametersFromFile and cuOptDumpParametersToFile, backed by the existing load_parameters_from_file / dump_parameters_to_file.

Two notes for whoever picks this up:

  1. Do not expose the hyperparameters flag. The original cuOptDumpParametersToFile took a hyperparameters_only argument. Parameters are marked as hyperparameters precisely so they are not broadly advertised, so a public entry point should not name the concept. Dump the non-hyperparameter set unconditionally.
  2. The dump output is a template, not a snapshot. dump_parameters_to_file writes every parameter commented out (# name = value) as a starting point for the user to edit. Feeding it straight back to the loader therefore changes nothing, which is easy to mistake for a bug. The loader accepts name = value lines and ignores blanks and # comments.

Describe alternatives you've considered

  • Leave it out. Current state. Callers set parameters by name using the constants in constants.h, which the Java bindings surface through the generated CuOptConstants class. This covers the common case; what is lost is discovering the parameter set at runtime and persisting a configuration.
  • Expose the parameter list as a string-array attribute rather than an index-and-name pair. Would fit the attribute model better, but needs a settings-scoped attribute accessor, which does not exist.

Additional context

Removed in #1524 following review; see the discussion there. Related: #1202 (solver statistics, now exposed as solution attributes) and #1703 (problem-model accessors).

Metadata

Metadata

Assignees

Labels

awaiting responseThis expects a response from maintainer or contributor depending on who requested in last comment.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions