Skip to content

Cyclic dependency between variable and its start attribute #3918

Description

@phannebohm

According to MLS section 4.9.6

The attributes start and fixed define the initial conditions for a variable.

Consider the following model:

model CyclicStartAttribute
  parameter Real p(fixed = false);
  Real x(start = p);
initial equation
  1 = p^2 + x^2;
equation
  x = p + time;
end CyclicStartAttribute;

My interpretation is that CyclicStartAttribute is illegal because x.start and x cyclically depend on each other and have no initial guess available. Is this correct? Should it be made explicit in the MLS?

Now consider the following model:

model ReverseStartAttribute
  parameter Real p(fixed = false);
  Real x(start = p);
initial equation
  1 = p^2 + x^2;
equation
  x = time;
end ReverseStartAttribute;

Here x.start depends on x but is not part of an algebraic loop and in this case x.start is not needed because x can be computed directly from its defining equation. Should a compiler ignore x.start or should ReverseStartAttribute also be illegal?

Related Issues

This is similar but not identical to #2668 and #3278.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions