Skip to content

Apply controllers and implement set commands during lattice expansion#74

Merged
DavidSagan merged 1 commit into
mainfrom
sets-and-controllers
Jul 23, 2026
Merged

Apply controllers and implement set commands during lattice expansion#74
DavidSagan merged 1 commit into
mainfrom
sets-and-controllers

Conversation

@DavidSagan

Copy link
Copy Markdown
Member

Brings lattice expansion in line with pals#237 (Controller) and pals#268 (lattice expansion), plus the set and expand_lattice sections already on pals main.

Controllers

Controllers were evaluated but never appliedcontrol_type was read and ignored, so the lattice was untouched.

  • ABSOLUTE controllers now drive the parameters their parameter pattern matches, each set to the sum over the controllers driving it, replacing the element's own value. A parameter the element does not carry is created.
  • RELATIVE controllers take no part in expansion: the parameter keeps the value its element gives, and only the control expression is evaluated for the program that varies the knob later.
  • Applied after branch/fork expansion and before the bookkeeper, so reference, floor and dependent parameters are computed from the driven values.
  • Controllers driving another controller's variable form a hierarchy, evaluated top-down; cycles are reported. control_type defaults to ABSOLUTE and is materialized. A variable with no value is zero, and an initial value is a constant expression — neither it nor a control expression may reach outside its own controller.
  • Reported: circular hierarchy, a parameter driven by both types, a parameter both controlled and expr(...)-delayed, a target matching nothing, an unknown control_type.

set and expand_lattice

Both were absent entirely. An expand_lattice node now divides the facility list and the pipeline follows the documented order:

pre-expansion sets → branch/fork expansion → ABSOLUTE controllers → bookkeeper
  → post-expansion sets → ABSOLUTE controllers → bookkeeper
  • Before expand_lattice a set writes the element definitions, and only those defined earlier in the list — so every expanded copy inherits one value.
  • After it, a set writes each expanded element separately, and may use computed values (SELF.s_position).
  • value expressions take PARAMETER (the value being replaced) and SELF.<path> (the owning element). The compact sets: form is supported.
  • An unwritten parameter reads as zero, unless a member of its linked family is written — then its value is still to be derived and reading it is an error, per the Bs1/Ks1 example.
  • That same family notion lets a post-expansion set drop what it invalidated, so the second bookkeeper pass rebuilds it instead of flagging an inconsistency.

Not implemented

absolute_error/relative_error are parsed and reported rather than applied: the standard gives the error magnitude (absolute_error + relative_error * |value|) but not its distribution, and this library defers randomness everywhere else so expanded stays reproducible.

Tests

203 pass (was 174). New tests/test_sets.cpp (14 cases) and a rewritten tests/test_controllers.cpp.

🤖 Generated with Claude Code

Brings expansion in line with pals#237 (Controller) and pals#268 (lattice
expansion), neither of which the pipeline previously acted on.

Controllers were evaluated but never applied: control_type was read and
ignored, so the lattice was untouched. Now the ABSOLUTE controllers are
applied to the parameters they drive, each set to the sum over the
controllers driving it, and RELATIVE ones take no part in expansion. They
run after branch and fork expansion and before the bookkeeper, so the
reference and dependent parameters are computed from the driven values.
Controllers that drive another controller's variable form a hierarchy,
evaluated top-down with cycles reported; control_type defaults to ABSOLUTE;
a variable with no value is zero and an initial value is a constant
expression, since neither it nor a control expression may reach outside its
own controller.

set and expand_lattice were absent altogether. An expand_lattice node now
divides the facility list, and the pipeline follows the documented order:
pre-expansion sets, branch and fork expansion, controllers, bookkeeper,
post-expansion sets, controllers again, bookkeeper again. A set ahead of
expand_lattice writes the element definitions, and only those defined
before it in the list; one after it writes each expanded element
separately. An unwritten parameter reads as zero unless a member of its
linked family is written, in which case its value is still to be derived
and reading it is an error. That same family notion lets a post-expansion
set drop what it invalidated so the second bookkeeper pass rebuilds it
rather than flagging an inconsistency.

absolute_error/relative_error are reported rather than applied: the
standard gives the error magnitude but not its distribution, and this
library defers randomness everywhere else for reproducibility.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@DavidSagan
DavidSagan merged commit f38a626 into main Jul 23, 2026
3 checks passed
@DavidSagan
DavidSagan deleted the sets-and-controllers branch July 23, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant