ampl_get_data
Fetch AMPL entity values as records. Supports suffixes for primal values, duals, reduced costs, and bounds, with pagination and CSV export for parameters, variables, sets, constraints, and objectives.
Instructions
Read an entity's values as records.
suffix selects val, dual, rc, slack, lb or ub, so this one
tool covers primal values, duals, reduced costs and bounds. At most one
suffix may be requested per call: results.entity_rows tells an indexed
(index, value) pair apart from a scalar value by checking for a 2-tuple,
so passing multiple suffixes to get_values() on a scalar entity would
be silently misread as an index/value pair.
Reading a PARAMETER can have a side effect: an indexed default that
has never been referenced is computed and cached by AMPL only when
read (documented AMPL laziness, not an amplpy quirk), and this tool
forces that computation, but ONLY when a plain read comes back empty or
short - never unconditionally - so a data-dependent default already
read here keeps the value it had when read rather than tracking later
changes to what it depends on; avoid reading such a parameter until you
are done changing the data it depends on. If some instances of a
PARAMETER (or VARIABLE) still have no value afterwards (a parameter
with no default that was only partially assigned), that is reported via
notes with ok: false, never silently reported as a complete,
successful read. This completeness check does not apply to sets,
constraints or objectives: num_instances() counts something other
than "rows returned" for those (e.g. 1 for a whole set regardless of
how many members it has), so comparing the two would misreport a
perfectly normal empty set as a failed read.
name must be a bare AMPL entity name; it is interpolated into an AMPL
statement, so anything else is an argument_error. limit is the page
size and must be at least 1 - a limit of 0 or less is an
argument_error, not an empty page reported as a successful read.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| limit | No | ||
| offset | No | ||
| suffix | No | ||
| to_csv | No | ||
| session | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||