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

More EMG examples #31

Open
dandelion-lowcode opened this issue May 7, 2024 · 2 comments
Open

More EMG examples #31

dandelion-lowcode opened this issue May 7, 2024 · 2 comments

Comments

@dandelion-lowcode
Copy link
Contributor

dandelion-lowcode commented May 7, 2024

I don't really know how EMG works, and the Petri Net example was too academic, so I tinkered a bit with the Playground and generated a model for a seemingly simple scenario such as the projects metamodel to get a grasp of the language.

imagen

To my surprise, it involved a series of interesting challenges I discovered along the way:

  • I had to inject tasks and people names/titles to populate them. The language reference explains how to represent values as a model, but this injection is not possible in the Playground. I had to resort to long string sequences in pre which are consumed with nextFromCollection in the code; not ideal. Perhaps a CSV panel in the playground would help.
  • Constraints. Achieving these merely using list, @probability and straightforward patterns is tricky. Namely:
    • There should be no dettached elements (i.e., the entire model must have exactly one partonomy/object tree per project)
    • Projects should have >= 1 tasks
    • Projects should have >= 1 persons
    • Two efforts of the same task cannot be associated to the same person (arguable)
    • The sum of efforts of a task must equal 100
    • As a derived consequence, the number of efforts per task must be less than the number of people associated in the project
    • Persons associated to a project must be assigned at least to one task (arguable)

I managed to solve some of these constraints, but others may need more hacking or smarter EPL patterns.

Would an example like this be useful for the Playground? If so, with a bit of help for polishing, I think we could add it.

@kolovos
Copy link
Contributor

kolovos commented May 20, 2024

Many thanks for sharing this example; I had it on my to-do list to create an EMG example for the PSL metamodel but you beat me to it :) It'd be great if you could contribute it with a pull request under the "Basic Examples" category with the id "emg". A few minor comments on the example itself:

  • I'd suggest using camelCase instead of snake_case throughout the example
  • "The sum of efforts of a task must equal 100" <- This is not necessary as the percentage doesn't indicate the percentage of the task that is completed by the person but instead the percentage of the person's time that is allocated to the task (e.g. 40% means 2 days/week). I can see how this can be interpreted both ways though.
  • I know that in the EMG documentation page we use @list net but I think we should be using plural instead for lists i.e. @list nets, @list persons etc as it reads better.

@dandelion-lowcode
Copy link
Contributor Author

Thanks for the suggestions.

I'll leave it like this right now - https://eclipse.dev/epsilon/playground/?471036c1, and I'll open a PR soon.

Also, are we sure nextInt(n1, n2) exists? Playground backends seems to use 2.5.0. Hmm...

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

No branches or pull requests

2 participants