New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolute collection semantics #91

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

Comments

Projects
None yet
2 participants
@kfhoech
Contributor

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

This comment has been minimized.

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

Merge pull request #95 from smaccm/develop_issue91
Resolve Resolute collection semantics (Issue #91)
@kfhoech

This comment has been minimized.

Contributor

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 join this conversation on GitHub. Already have an account? Sign in to comment