Expand description
Minimal AMPL .sol-format writer.
Format reference: David M. Gay, “Hooking Your Solver to AMPL”
(https://ampl.com/REFS/hooking2.pdf) §5 (“Returning Results to
AMPL”), cross-checked against the AMPL solver-library reference
implementation write_sol_ASL in
https://github.com/ampl/asl (solvers/writesol.c). We emit the
ASCII variant — the same one AMPL’s commands file produces by
default when reading back from solvers.
§Format
<message line 1>
<message line 2>
... (free text, ended by a blank line then "Options")
Options
<nopts> (int — number of integer option-words to follow)
<opt0> (... nopts lines)
...
<n_dual> (number of dual values written below)
<m> (constraint count)
<n_primal> (number of primal values written below)
<n> (variable count)
<lambda[0]> (... n_dual lines, dual values)
...
<x[0]> (... n_primal lines, primal values)
...
objno <objno> <status> (optional — selects which objective and the solver-return code)
suffix <kind> <nvalues> <namelen> <tablen> <tabline> (optional — one block per exported suffix)
<name> (the suffix name, on its own line)
<idx> <value>
...The four-integer count block is the canonical AMPL form: each
dimension count is paired with a “values written” partner so the
reader knows how many dual and primal lines to consume before
reaching objno. We always write every dual and primal, so
n_dual == m and n_primal == n. (Earlier pounce builds emitted
only the two bare counts <m>\n<n>\n; AMPL’s own reader and
Pyomo’s .sol reader both reject that short form.)
§Scope
Smallest writer that lets crate::nl_reader::NlSuffixes flow
from a pounce solve back through AMPL’s reader. Specifically the
pounce_sens binary (pounce#17) writes:
- The nominal primal and dual blocks (so AMPL sees
x*andλ*on the regular_var.X/_con.dualslots). - One or more sensitivity suffixes (
sens_sol_state_<N>) carrying the perturbed primal as a real-var suffix, matching upstreamMetadataMeasurement::SetSolution(ref/Ipopt/contrib/sIPOPT/src/SensMetadataMeasurement.cpp:128-150).
Structs§
- SolSuffix
- A single suffix block to write back into the
.solfile. Mirrors theS-segment shape ofcrate::nl_reader::NlSuffixesentries. - Solution
File - Solution payload bundled for a
.solwrite.
Enums§
Functions§
- format_
sol - Format
payloadinto AMPL.solASCII text. - write_
sol_ file - Convenience: write
payloadtopath(truncating any existing file). Returns the bytes written on success.