Skip to content
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

Predefined type String misses the fixed attribute #1797

Closed
modelica-trac-importer opened this issue Nov 4, 2018 · 6 comments
Closed

Predefined type String misses the fixed attribute #1797

modelica-trac-importer opened this issue Nov 4, 2018 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@modelica-trac-importer
Copy link
Collaborator

Reported by beutlich on 7 Oct 2015 07:37 UTC
According to MLS 3.3r1 section 4.8.4 the predefined type String misses the fixed attribute (as opposed to all other predefined types). However there is some relevance to have the fixed attribute as well, e.g., the following test model

model A
  discrete output String data(start="");
  equation
    when sample(0, 0.1) then
      data = String(time);
    end when;
end A;

raises a warning in pedantic mode.

The initial conditions for variables of type String are not fully specified.
Dymola has selected default initial conditions.

Assuming fixed default start value for the discrete non-states:
data(start = "")

Migrated-From: https://trac.modelica.org/Modelica/ticket/1797

@modelica-trac-importer
Copy link
Collaborator Author

Comment by hansolsson on 1 Apr 2016 13:34 UTC
Issue was also reported in #455.

@modelica-trac-importer
Copy link
Collaborator Author

Modified by beutlich on 5 Aug 2016 08:56 UTC

@modelica-trac-importer modelica-trac-importer added this to the Design91 milestone Nov 4, 2018
@modelica-trac-importer
Copy link
Collaborator Author

Comment by hansolsson on 12 Sep 2016 14:28 UTC
Design meeting:
Seems logical to add fixed-attribute for String.
Can pre be applied to a String? Yes - according to definition of pre.

--
One possibility: add fixed-attribute for String in the same way as for Boolean.

Another possibility would be that "fixed=true" is always true for String, but that wouldn't work for cases like:

model A
  discrete output String data(start="");
  equation
    when {initial(), sample(0, 0.1)} then
      data = String(time);
    end when;
end A;

Seems simplest to treat like other discrete variables (i.e. as Boolean), but would be ideal to clear it up for all non-Real variables - so "fixed=true" as default if start-attribute is specified.

Changing the default for "fixed" would not be good due to (and similarly with String-connector):

model B
  String a,b;
equation
  a=b;
  when sample(1,1) then
    b=String(time);
  end when;
end B;

--
For now just add "fixed" for String.
Favor: 8
Against: 1 (in favor of more powerful - for all non-real ones)
Rest abstain.

@modelica-trac-importer
Copy link
Collaborator Author

Comment by hansolsson on 23 Sep 2016 13:09 UTC
Resolved in r9490

@modelica-trac-importer
Copy link
Collaborator Author

Comment by beutlich on 2 Nov 2016 14:35 UTC
There still is "String parameters are also covered by this, since they lack a fixed-attribute they can never have fixed=false." in section 8.6.

By the way, it would be nice if blanks are used consistently in fixed=false. Currently I need to search for fixed=false and fixed = false to find all occurences of fixed-false variables. Same holds for fixed-true searches.

@modelica-trac-importer
Copy link
Collaborator Author

Comment by hansolsson on 3 Nov 2016 11:33 UTC
Replying to [comment:5 beutlich]:

There still is "String parameters are also covered by this, since they lack a fixed-attribute they can never have fixed=false." in section 8.6.

This is now done in r9517

By the way, it would be nice if blanks are used consistently in fixed=false. Currently I need to search for fixed=false and fixed = false to find all occurences of fixed-false variables. Same holds for fixed-true searches.

I agree that consistently is desirable, but this got me thinking, and I see another problem and don't want to change this before figuring out exactly how it should be.

For start-values we say start=startExpression indicating that there is a modifier expression for the start-value and that expression is called startExpression.

But when we write fixed=false we mean that the fixed-attribute has the value false; i.e. an expression that evaluates to false not only the expression false.

To me the intention is clear, but I think I rely more on what the specification should mean than on what it says - and would like to clarify this.

The syntax for checking if the value of the fixed-attribute is false would in Modelica be: fixed==false, but it would be odd to see == in some places and not in others - and start==startExpression is both semantically illegal (for Reals), and confusing since it is more a case of pattern-matching where startExpression is bound.

One possibility is to replace "For all variables declared as constant and parameter, with fixed = true" by "For all variables declared as constant and parameter, where the fixed-attribute is true", but it could be that some other variant is better, that fixed = true is clear enough, or that we should just add a clarification that attribute=literal mean that the attribute has the value literal, and attribute=expression mean that the attribute has a modifier and its value is expression.

This should probably be another ticket, and thus I close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests