Skip to content
This repository has been archived by the owner. It is now read-only.

Resolute collection semantics #91

Closed
kfhoech opened this issue Mar 8, 2018 · 2 comments
Closed

Resolute collection semantics #91

kfhoech opened this issue Mar 8, 2018 · 2 comments
Assignees

Comments

@kfhoech
Copy link
Contributor

@kfhoech kfhoech commented Mar 8, 2018

Presently the collection semantics in Resolute is that of lists.

There are models where this semantics is appropriate. @reteprelief provides the following where proper summation over the collection depends on allowing duplicate elements:

-- recursively total of weight budgets of all components
AddAllBudgets(self : component) : real =
      let subs :{component} = subcomponents(self);
      let totals: real = sum({AddAllBudgets(t) for (t: subs)}) + NetWeight(self);
      if (length(subs) = 0 or totals = 0.0) then
             WeightBudget(self)
      else
             totals

-- c omputational function to calculate total of weight budget from subcomponents
AddSubcomponentWeightBudgets(self: component) : real =
             sum({WeightBudget(t) for (t: subcomponents(self))})

WeightBudget(self:component): real =
   if (has_property(self,SEI::GrossWeight)) then property(self,SEI::GrossWeight,0.0 kg)
   else property(self,SEI::NetWeight,0.0 kg)

Conversely, there are models that depend on the semantics being those of sets. The Flight model is one such model. In this model a recursive function is used to walk over the connections in the model and collect the reachable set of destinations. This allows an argument as to whether there is separation between model elements and and answer can certain elements in the model reach (influence) other elements without traversing an intermediate such as a firewall or decryptor. In this model immediate problem encountered is that with duplicates allowed in the collections, the exit criterion for the recursive walk is never met, resulting in an infinite loop in the Resolute evaluator.

Accordingly, both set semantics and list semantics are wanted. For making this improvement in Resolute I propose:

  1. Changing the behavior back to sets.
  2. Adding grammar elements and evaluators for lists based on the existing code, but adding the missing list accessors (e.g. head, tail) so that it's possible to write recursive functions that operate on lists.
  3. adding fold (a.k.a accumulate) operator.
@konrad-slind
Copy link

@konrad-slind konrad-slind commented Mar 8, 2018

@kfhoech kfhoech self-assigned this Mar 12, 2018
kfhoech added a commit that referenced this issue Mar 19, 2018
Resolve Resolute collection semantics (Issue #91)
@kfhoech
Copy link
Contributor Author

@kfhoech kfhoech commented Mar 19, 2018

Resolved by Pull Request 95.

@kfhoech kfhoech closed this Mar 19, 2018
@kfhoech kfhoech added the v2.3.3 label Jul 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants