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

#7 - Initial implementation #10

Merged
merged 17 commits into from
May 6, 2018
Merged

#7 - Initial implementation #10

merged 17 commits into from
May 6, 2018

Conversation

mforets
Copy link
Member

@mforets mforets commented Apr 24, 2018

Closes #7.

  • make option raw_dict=true
  • [ ] make option raw_dict=false (default)
  • [ ] add functions to docs

EDIT: i'm readdressing this issue:

  • output the hybrid automaton by default without any assumption on the system type
  • add unit tests
  • add functions to docs

this leaves for the next issue to transform the information of the hybrid automaton into a given system type, that is (A, B, X, U), where X, U have to be transformed from expressions to some LazySet representation.

@mforets mforets self-assigned this Apr 26, 2018
@mforets
Copy link
Member Author

mforets commented Apr 27, 2018

From my side this branch is ready to be merged.

@mforets mforets changed the title [WIP] #7 - Initial implementation #7 - Initial implementation Apr 27, 2018
Copy link
Member

@schillic schillic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only had a rough look.


`spaceex -g name.cfg -m name.xml --output-system-file new_name.xml`

However, note that the flattening process change the original model and may induce parsing errors. The parsing errors only appear when the constructed model is visualized/analyzed with the Model Editor or/and the Web Interface. There are no parsing errors with the source code/executable SpaceEx. A list of identified parsing problems follows below.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes

However, note that the flattening process change the original model and may induce parsing errors. The parsing errors only appear when the constructed model is visualized/analyzed with the Model Editor or/and the Web Interface. There are no parsing errors with the source code/executable SpaceEx. A list of identified parsing problems follows below.

1. Special symbols, e.g. ~, _ in the variable and location names
2. Characters and symbols in the notes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between characters and symbols?

Copy link
Collaborator

@nikos-kekatos nikos-kekatos May 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the best thing is to suggest that users employ only Latin alphabet and no special characters.

To answer your question, from my standpoint, symbols correspond to mathematical operations (,},/,*,+,_ and characters to non-latin characters, e.g. Greek or Russian letters


1. Special symbols, e.g. ~, _ in the variable and location names
2. Characters and symbols in the notes
3. Nondeterministic flows, e.g. x'==x+w, where 0<w1<0.1 (see bball_nondet)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"w" or "w1"?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct! w or w1 should be kept

3. Nondeterministic flows, e.g. x'==x+w, where 0<w1<0.1 (see bball_nondet)
4. Nondeterministic resets, e.g. v' == -0.75*v+w2 (see bball_nondet)
5. Naming issues, e.g. default variable name is component.subcomponent.variable
A visual model editor is available for download in the [SpaceEx website](http://spaceex.imag.fr/download-6).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in → on ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed!

src/io.jl Outdated
### Output

Hybrid system that corresponds to the given SX model and the given assumptions
on the system type. If `raw_dict=true`; otherwise, a dictionary with the Julia
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If raw_dict=true

Is there something missing?

src/parse.jl Outdated
### Output

The tuple `(q, r, G, A)` where `q` and `r` are the source mode and target mode
respectively for this location, `G` is the list of guards for this location,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

location → transition (2x)

src/parse.jl Outdated

The tuple `(q, r, G, A)` where `q` and `r` are the source mode and target mode
respectively for this location, `G` is the list of guards for this location,
and `A` is the list of assignments. Both objects are vectors of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both objects → Both G and A ?


### Notes

It is assumed that the "source" and "target" fields can be cast to integers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds strict. Is this reasonable?
Otherwise you could store the transitions in a temporary data structure and obtain the location IDs later from a dictionary "location name → location ID".

Copy link
Member Author

@mforets mforets May 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is given by the format, those id's are assigned automatically (for locations, transitions, etc). I don't remember if there is a way of editing these fields in the model editor.

test/runtests.jl Outdated
end

#=
@testset "Circle" begin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.

src/parse.jl Outdated

Consists of the following steps (in the given order):

- split the string with the `&` key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to allow parentheses? Since the formulas are purely conjunctive, they could just be ignored.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. as a by-product of parse, parentheses are ignored:

julia> parse_sxmath("(x == 0) & ((v <= 0))")
2-element Array{Expr,1}:
 :(x = 0)
 :(v <= 0)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that & is the same as && for SpaceEx

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that & is the same as && for SpaceEx

Thanks. I've updated the function parse_sxmath accordingly.

src/io.jl Outdated
- `invariants`
- `flows`
- `resetmaps`
- `switchings`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between resetmaps and switchings? Is there a reason to have both?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the association that i did (naively, subject to discussion) is:

  • resetmaps field in HybridSystems <-> assignments in SX
  • switchings field in HybridSystems <-> guards in SX

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, this is coming from HybridSystems. Makes sense.

Copy link
Member

@blegat blegat Apr 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guards (i.e. the sets in which the states need to be to do the switching should be in the resetmaps) as the constraint set X of Systems.jl. switchings is meant to be the nature of the switching (e.g. controlled switching vs autonomous switching of Section 1.1.3 of Liberzon "Switching in Systems and Control")
EDIT I have added documentation for it in the HybridSystems doc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hints, this helped a lot.

In the examples added up to now, the switchings are autonomous since they are defined by hypersurfaces for the states.

For the resetmaps, we take discrete constrained systems, whose state constraints are given by guards in SX (or eventually, input constraints), and the coefficient matrices are read from the assignments in SX.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems perfect :)

@mforets
Copy link
Member Author

mforets commented May 6, 2018

Thanks to all of you for the feedback.

@mforets mforets merged commit f01e1f4 into master May 6, 2018
@mforets mforets deleted the mforets/7 branch May 6, 2018 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants