Repository navigation
Buildings 13.0.0: 240 of the 246 example models that stopped in the frontend pass - #147
Merged
Merged
Conversation
…ocals Inside a for-loop, addIterator added the iterators of the loops and array constructors in its body to the enclosing loop's own scope (pushfirst! on the shared vector; omc conses onto an immutable list). The statements after them then saw those iterators: - a variable i assigned after an inner 'for i' was "Assignment to iterator 'i'" (Buildings 13.0.0, glassAbsInteriorIrradiationExteriorShading: the first error of 90 of its examples); - a second array constructor over j was "An iterator named 'j' is already declared in this scope" (2034 such warnings over 246 Buildings models). Test: iteratorScopeTests.jl (a function evaluated to 18.0; no warnings). Assisted-by: Claude Fable 5.2
…ch at typing A function's protected parameter bound to its inputs has no value before the call. 'parameter Integer n = size(r.v, 1)' used as a subscript marks n structural, and with it the input's field r.v; an if-expression over r.v in a later binding then had a structural condition and was evaluated to select its branch: "Constant r.v is used without having been given a value" (Buildings 13.0.0, Fluid.Movers.BaseClasses.Euler.getPeak: the first error of 128 of its examples once the iterator scope is right). In a function both branches are typed unless the condition is constant; branches whose types do not match still select by the condition. Buildings 13.0.0, the 246 models that stopped in the frontend on 4.0.0 (without the 13 over 30 s or crashing): 2 pass before, 10 with the iterator scope, 103 with this. Test: functionParameterTests.jl (the record evaluates to (2.0, 21.0)). Assisted-by: Claude Fable 5.2
… there
Sizes per element of an array of components (Buildings' conduction layers,
lay[nLay] with each layer's nSta):
- zeros(nSta), ones, fill: a size that evaluates to different values over
the elements stays an expression, a size per element when flattening, as
a ragged dimension (was "Type mismatch for positional argument 2 in
zeros(={{2, 4, 2}, ...})").
- an array constructor's range 2:nSta: a range kept as a range counts one
dimension more than its bounds, so a bound with values over the elements
is not taken as the range (was a start value over '2:{2, 3}').
A conditional component whose condition is false (the rooms'
'bouConExt(nCon = nConExt, conPar = datConExt) if haveConExt' with
'datConExt[max(1, nConExt)]'):
- inside a conditional component, a binding that does not fit its
component's type is an INVALID_BINDING with its messages: an error where
the component is flattened, none where the condition removes it (was
"Type mismatch in binding conPar = ..., expected array dimensions [0],
got [1]"); its value is still read where a size inside needs it. omc
does not type the children of such a component.
- a connect whose connector a condition removes is not matched for type.
- connect equations of deleted components are removed also where no
connection is left (the only connect of a model was "'sub.c' refers to a
component with a false condition").
Tests: the patterns of the earlier two fixes and these in one file,
libraryPatternTests.jl, one check each (4).
Buildings 13.0.0, the 246 models: 129 pass (103 before). MSL 4.1.0: 534 of
534 in the frontend. Suite 1516 of 1516.
Assisted-by: Claude Fable 5.2
…oked at only where the match fails Assisted-by: Claude Fable 5.2
…dren not typed As omc (typeComponent: the condition evaluated, is_deleted): a conditional component whose condition evaluates to false, for every element of an array of components, keeps the evaluated condition, is deleted for the passes after (Component.isDeleted), and its children, their bindings and its sections are not typed. A condition that does not evaluate removes nothing; the flattening decides as before, and marks the children deleted. This replaces 3709492's INVALID_BINDING for a binding inside a conditional component that fits no size (_matchBindingInConditional and what read its value): nothing inside such a component is matched now. typeConnect's check for a removed connector reads isDeleted; Component.isDeleted takes a condition that is not typed yet as not deleted (omc). Buildings 13.0.0, the 246 models: 150 pass (129 before), none that passed fails. MSL 4.1.0: 534 of 534 in the frontend, 9.3 s (9.8 s before, warm, one process). Suite 1516 of 1516. Assisted-by: Claude Fable 5.2
makeComponentBinding built one record from the fields' whole arrays and copied
it to every element. Each element's field then held the array:
- a record field: "got non-record binding" in Flatten.getRecordBindings
(Buildings' rooms, air(datConPar = datConPar): air.datConPar[1].layers bound
to the three constructions);
- a scalar field: bound to the array, no error
(final parameter Real air.dat[1].A = {10.0, 20.0, 30.0}).
Now as omc (mapCrefScalars): the cref expanded, one record per scalar element
from that element's fields. The cref of one element (dat[2]) keeps the one
record. A cref that does not expand keeps the old path.
Buildings 13.0.0, the 246 models that stopped in the frontend: 184 pass
(150 before), none that passed fails. MSL 4.1.0: 534 of 534, 8.8 to 9.5 s
(9.3 s before). Suite: 1517 of 1517.
Assisted-by: Claude Fable 5.2
A record field read inside a class instantiated as an array of components
(layers.nSta in Multi con[2](layers = {c1, c2})) evaluates to the value of every
element ({{2}, {3}}). It was treated as one value:
- layers.nSta[1] subscripted the enclosing dimension: con[1]'s {2}, not each
construction's first ({2, 3});
- sum(layers.nSta) summed over the constructions (5 for both);
- an iteration range (for i in layers.nSta) ran over the scalars of them all.
Every construction got the first one's sizes: "Subscript '3' for dimension 1
(size = 2) of T is out of bounds" (Buildings' MultiLayer in the rooms' arrays
of constructions), or sizes that were wrong without an error.
Now:
- the cref's own subscripts apply past the enclosing dimensions the value
keeps; a subscript without a value yet stays one subscripted expression;
- the value is marked as a binding propagated through the enclosing arrays
(BINDING_EXP), so operations run per element (bindingExpMap); a binding
whose value is so marked is one binding over both;
- bindingExpMap2 takes the sizes from an evaluated value's own elements
(constructions with 3 and 2 layers);
- an array constructor or reduction whose range is such a value runs per
element, with that element's range.
Buildings 13.0.0, the 246 models: 199 pass (184 before), none that passed
fails. MSL 4.1.0: 534 of 534, 8.8 to 9.6 s. Suite: 1518 of 1518.
Assisted-by: Claude Fable 5.2
Follows e3b5ff1 (values over enclosing component arrays). - evalRange: a bound over enclosing component arrays (1:nLay, nLay {3, 2} over the constructions) keeps its binding information, so the range is each element's own. It was stripped before the map: "evalRangeExp got invalid arguments (1, {3, 2})". - An array constructor or reduction is mapped over its body and its ranges together (_mapOverIterations), the ranges evaluated once. Mapped apart, body and range each ran over the constructions. - bindingExpMap4: a binding propagated through fewer dimensions takes the subscripts of the arrays it is propagated through (propagatedSubscripts), not always the innermost: nLay over the constructions, inside a binding over constructions and layers, took the layer's index. - recordElement: the field of a binding whose size is an expression not evaluated yet is taken from the expression it holds ("got invalid range size(layers.material, 1)"). Buildings 13.0.0, the 246 models: 206 pass (199 before), none that passed fails. MSL 4.1.0: 534 of 534, 8.7 to 9.6 s. Suite: 1518 of 1518 (before the test model was made ragged; its file passes in the session after). Assisted-by: Claude Fable 5.2
A reduction kept its form whatever its range: a for-equation's subscript
T[sum(layers.nSta[k] for k in 1:i - 1) + j] stayed
'con[2].T'[sum({3, 2}[k] for k in 1:0) + 1] in the flat model.
Now as omc's SimplifyExp.simplifyReduction: one iterator over an empty range
is the default value, over one element the expression for that element; a
reduction of constants and structural parameters is evaluated. The flat model
has 'con[2].T[4]' = 'con[2].lay[2].T[1]'.
Buildings 13.0.0, the 246 models: 206 pass, as before. MSL 4.1.0: 534 of 534,
8.8 to 9.0 s. Suite: 1519 of 1519.
Assisted-by: Claude Fable 5.2
redeclare replaceable X c constrainedby C(final k = ...) was "Trying to override final element k with modifier '= ...'": by its own modifier. The constraining modifier comes with the redeclare (MODIFIER_REDECLARE's constrainingMod, passed as the inner modifier), and instComponentDef merged it from the redeclaring element's definition a second time. Now as omc (instElementModifier does not merge it for a redeclared component): redeclareComponent, called for a redeclare modifier, says the constraining modifier is included, and instComponentDef leaves the element's out. An element redeclare keeps its own, as before. Buildings 13.0.0, the 246 models: 217 pass (206 before), none that passed fails; the reversible machines' safCtrPar and the ETS' conSup. MSL 4.1.0: 534 of 534, 9.4 to 9.5 s. Suite: 1520 of 1520. Assisted-by: Claude Fable 5.2
A scalar record without a binding of its own, inside an array of components
(per.pressure of Mover pum[2](m = {1, 2}), its V = m * {0, 1, 2}):
- made from its fields, it was one record holding every pump's values
(Curve({{0, 1, 2}, {0, 2, 4}}, ...)). Now one record for each element of
the enclosing arrays, marked as a binding propagated through them
(_recordOverEnclosing);
- made while one element's binding is evaluated, it was kept in the component
the elements share: pum[1]'s curve was every pump's. Not kept now, nor is a
binding evaluated from a value picked by the cref's enclosing subscripts
(_subscriptByEnclosingElements counts as an element read);
- subscriptEvaluatedBinding2: an enclosing array the cref names whole takes
the element the context names, else keeps its dimensions with the cref's
own subscripts past them ("{{0, 1, 2}, {0, 2, 4}}[3]" before).
Buildings' movers in arrays: "got non-record binding {peak(...), peak(...)}",
and in the small model the first pump's values for every pump without an
error.
Buildings 13.0.0, the 246 models: 222 pass (217 before), none that passed
fails; the 217 take 86.9 s (87.1 s before). MSL 4.1.0: 534 of 534, 8.8 to
9.6 s. Suite: 1521 of 1521.
Assisted-by: Claude Fable 5.2
The fallback case (unary, binary, ... expressions) called itself without maxDepth and requireFinal: the depth started over at the default 4. An if-equation's condition `not have_controlVolume`, bound through more levels of `final energyDynamics = energyDynamics`, was "not fixed", and its connects "may not be used inside if-equations with non-parametric conditions" (Buildings' PartialThreeWayResistance in the data center equipment). Buildings 13.0.0, the 246 models: 226 pass (222 before), none that passed fails. MSL 4.1.0: 534 of 534, 8.7 to 8.9 s. Suite: 1521 of 1521. No test added: the condition needs a chain of more than four levels. Assisted-by: Claude Fable 5.2
A structural if-expression's condition was evaluated twice (selectedBranch, then evaluateCondition), and a condition that could not be evaluated was an error: "Constant ets.datHeaPum.mEva_flow_nominal is used without having been given a value", a parameter whose value is an external function's (a table lookup, a file's peak load). Now evaluated once; where it does not evaluate no branch is selected (omc's typeIfExpression selects none), the messages of the attempt dropped. The five Buildings models (ETS heat recovery heat pump) get past this and stop at flatten: "Parameter ...per.peak_internal.eta has neither value nor start value" (a record binding that does not evaluate without the external values). Buildings 13.0.0, the 246 models: 226 pass, as before. MSL 4.1.0: 534 of 534. Suite: 1521 of 1521. Assisted-by: Claude Fable 5.2
B bui[2](Q = {Q1, Q2}) with Real Q[:, :]: Q's first dimension is the second
of the modifier's array, the first of Q1. typeArrayDim2 walks array literals
only and gave "Dimension 1 of Q could not be deduced from the component's
binding equation {Q1, Q2}" (Buildings' steam loads, QHeaLoa). omc has the
modifier subscripted by the element (a split index) and types that; here the
element reached (a cref, a matrix, a call) is asked for its own dimension
(typeExpDim).
Buildings 13.0.0, the 246 models: 227 pass (226 before), none that passed
fails; three more get past this point (the heat pump plants' controller
data). MSL 4.1.0: 534 of 534, 8.9 to 9.7 s. Suite: 1522 of 1522.
Assisted-by: Claude Fable 5.2
connect(src.y, bus.a) with src[2], `a` not declared in the expandable connector, was a MatchFailure in Connections.collect: the declared side expanded to two connectors, the undeclared side to one. - Connections.collect keeps both sides whole when either names an undeclared element (omc makeConnections); they get their elements when the connector is augmented. - makeVirtualConnector: the element's own type is the other side's without the dimensions of the expandable connector (bus[2]: each bus a scalar `a`; a scalar bus: `a` is Real[2]). The prefix of an undeclared element is not typed: its dimensions from its nodes. - An array of expandable connectors named whole is each of its elements: the variables (bus[1].a, bus[2].a) and the sets, so the elements reach a bus connected to one of them (connect(bus[1], b1)). - updateUndeclaredConnection: one connection for each scalar pair (omc: Connections.scalarize after the elaboration). Buildings 13.0.0, the 246 models: 231 pass (227 before), none that passed fails (the Templates' busTer[nVAV]). MSL 4.1.0: 534 of 534, 8.7 to 8.8 s. Suite: 1523 of 1523. Assisted-by: Claude Fable 5.2
…tural fields Two differences from omc, found by running the remaining Buildings models through omc (1.28.0-dev, a local build): - ComponentRef.isDeleted looked at the cref's last part only; omc's looks at every part. `connect(fanSupBlo.bus.V_flow, ...)`, fanSupBlo removed by its condition and V_flow not declared in the bus, was augmented into a bus without a class (a MethodError). omc does not flatten this model (VAVMultiZone: "unbalanced connection"). - Flatten.flattenSimpleComponent: a field of a record whose binding did not evaluate and became an initial equation gets fixed = false when it is a parameter; one marked structural did not, "Parameter ...per.peak_internal.eta has neither value nor start value". Now both, as omc's flat model has it (the ETS heat recovery heat pump: peak_internal = getPeak(...) over parameters whose values are external functions'). Buildings 13.0.0, the 246 models: 238 pass (231 before), none that passed fails. Of the 8 left omc does not flatten 6. MSL 4.1.0: 534 of 534, 8.8 to 8.9 s. Suite: 1523 of 1523. No test added. Assisted-by: Claude Fable 5.2
typeCref2 types a cref's prefix without its children in a dimension (omc: typeChildren = false), but a binding evaluated for the dimension was typed with ORIGIN_CLASS: evalComponentBinding2 did not pass the context on (omc: nodeContext(node, target.context)), and selectedBranch evaluated an if-expression's condition with a generic target. `datPum(typ = pum1.typ)`, typ read by a dimension of datPum (`V_flow = if typ <> None then ...`), typed pum1 with its children, among them `dat = datPum`, whose sizes need that dimension: "Dimension 1 of V_flow, ':', could not be evaluated due to a cyclic dependency" (Buildings' Templates.Components.Validation.Pumps). Buildings 13.0.0, the 246 models: 239 pass (238 before), none that passed fails. MSL 4.1.0: 534 of 534, 8.9 to 9.7 s. Suite: 1523 of 1523. No test added. Assisted-by: Claude Fable 5.2
…ions _liftToCrefDims left a value with bindings inside it as it was. An `each` binding is one value for every element whatever is inside it: `conPar[2](each layers = extConMat)`, a record with bound fields, read as `conPar.layers` stayed the one record. The binding `conExt[2](layers = conPar.layers)` then held one record under a type of two, and an element's subscript applied to it was a MatchFailure (subscriptEvaluatedBinding2) or "too few dimensions" (bindingExpMap4). Buildings 13.0.0, the 246 models: 240 pass (239 before), none that passed fails. The 6 left are the 6 that omc (1.28.0-dev) does not flatten either. MSL 4.1.0: 534 of 534, 9.2 to 9.6 s. Suite: 1523 of 1523. No test added. Assisted-by: Claude Fable 5.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Frontend fixes for Buildings 13.0.0 with MSL 4.1.0. Of the 246 example models that stopped in the frontend in the coverage run of 2026-11-27, 240 pass (2 on master). The 6 left also fail in omc 1.28.0-dev. Version unchanged (4.0.0).
What changed, 18 commits:
addIteratorcopies the scope's locals).eachbinding read as the whole array is lifted to the array's dimensions.zerosand ranges. A dimension deduced from an array element that is no array literal. A binding read for a dimension is typed in the dimension's context.simplifyReductionas omc (empty range, one element, structural).isExpressionNotFixedpasses the depth left on, as omc.fixed = false, as in omc's flat model.Some of the fixes also correct flat models that passed with wrong content: an array bound to a scalar field, the first element's sizes used for every element.
Checked on f2c9c50:
HeatExchangerSimulation, 14 FundamentalWave machines). Parameters keep their bindings where 4.0.0 wrote the evaluated literal (HEX.pipe_1.length = HEX.length, before= 20.0). omc writes the binding on the lines compared. From 147c1e2.test/libraryPatternTests.jl, 10 small models, 11 checks.The 6 models left:
Buildings.Obsolete.Utilities.IO.Python_3_8.Examples.SimpleRoom: a class is missing in the library. Same error in omc.Buildings.Templates.Plants.HeatPumps.Components.Validation.{HeatPumpGroupAirToWater, HeatRecoveryChiller, PumpsPrimaryDedicated, ValvesIsolation}: an expandable connector connected to an undeclared element of another. Same error in omc.Buildings.Templates.Plants.HeatPumps.Validation.AirToWater: cyclic dimension. omc fails with another message.Issues:
SimpleRoom).🤖 Generated with Claude Code