Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Java and epsilon ecl syncronizathion(Issues with the value of a variable)
Java and epsilon ecl syncronizathion [message #1861488] Mon, 16 October 2023 10:01 Go to next message
Mauro Sonzogni is currently offline Mauro SonzogniFriend
Messages: 10
Registered: October 2023
Junior Member
Good morning,
I'm having some issues with the value of a variable that gets modified within a rule in the "do" section. I initialize my variable during the "pre" phase, and then its value gets modified within the "do" section. However, what's happening is that when I attempt to retrieve the value on the Java side, I'm experiencing non-deterministic behavior. In other words, sometimes I get the default value, and other times I get the modified value (for safety, I've also tried setting both "guard" and "compare" to true). The execution of my module (module.execute()) is within a try-catch block, and I'm trying to retrieve the value only after the catch block (to avoid issues in case of an error).
Thank you in advance,
Mauro.
Re: Java and epsilon ecl syncronizathion [message #1861490 is a reply to message #1861488] Mon, 16 October 2023 11:04 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Mauro,

Thank you for your message. Could you please share a minimal example we can use to reproduce the issue you are encountering? You could use https://eclipse.dev/epsilon/playground/?eml as the starting point for your minimal example (click download, modify and share the downloaded Maven/Gradle/Eclipse project). I am aware that the Eclipse website is not accessible at the moment but I expect it won't be too long before it's back up again.

Thanks,
Dimitris
Re: Java and epsilon ecl syncronizathion [message #1861491 is a reply to message #1861490] Mon, 16 October 2023 13:53 Go to previous messageGo to next message
Mauro Sonzogni is currently offline Mauro SonzogniFriend
Messages: 10
Registered: October 2023
Junior Member
Here's the example code. It should be sufficient to compile the project and run the main. Sometimes the variable gets updated, and sometimes it doesn't; it depends on the executions. In the "new_report" folder, a CSV file is generated containing the values of the calculated variables. The error becomes evident when running it multiple times and setting a fixed value in the "do" part of the rule. My suspicion is that the problem might be related to running the modules within for loops.
Despite being a simple example, it's not small enough to upload here. Here is the link to the GitHub project https://github.com/maurosonzogni/ecl-example of the simplified project.

Thank you for your assistance, Mauro.
Re: Java and epsilon ecl syncronizathion [message #1861493 is a reply to message #1861491] Mon, 16 October 2023 14:10 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Mauro,

I'm afraid there's a bit too much going on in your code to serve as a minimal example. Could you please try to slim down your example so that it doesn't store to CSV, it just prints the non-deterministic value to System.out, it uses models/metamodels with a couple of elements each, it consists of a single Java class that launches your ECL script etc as per https://eclipse.dev/epsilon/doc/articles/minimal-examples/#a-minimal-version?

Thanks,
Dimitris
Re: Java and epsilon ecl syncronizathion [message #1861494 is a reply to message #1861493] Mon, 16 October 2023 14:17 Go to previous messageGo to next message
Mauro Sonzogni is currently offline Mauro SonzogniFriend
Messages: 10
Registered: October 2023
Junior Member
Okay, I have modified the code, and now it prints to the console. Please let me know if this works for you, otherwise, I will try to simplify it further. Thank you. Mauro.
Re: Java and epsilon ecl syncronizathion [message #1861495 is a reply to message #1861494] Mon, 16 October 2023 14:25 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Please simplify further as per my previous message.

Thanks,
Dimitris
Re: Java and epsilon ecl syncronizathion [message #1861496 is a reply to message #1861495] Mon, 16 October 2023 14:51 Go to previous messageGo to next message
Mauro Sonzogni is currently offline Mauro SonzogniFriend
Messages: 10
Registered: October 2023
Junior Member
Ok, I think I can't simplify it further without risking losing generality. The Epsilon version in use is 2.4.0. To reproduce the error, simply run the main.java, and you will see the output on the matrix written in the console. Now, by modifying the "editDistance" parameter inside the "do" block, even with a fixed value, you will notice that the matrix is not actually being written correctly.
Thanks,
Mauro
Re: Java and epsilon ecl syncronizathion [message #1861499 is a reply to message #1861496] Mon, 16 October 2023 17:09 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Mauro,

Thanks for your effort on this. The example doesn't need to have "generality"; it just needs to demonstrate the issue you are encountering with as little code as possible. Do you really need a nested for loop, five models with hundreds of model elements conforming to complex metamodels, and ~100 lines of ECL to demonstrate this issue? If you find further slimming down this example challenging, perhaps you could start with a simpler example (e.g. https://eclipse.dev/epsilon/playground/?eml - just the ECL part) and add complexity to it until the issue starts appearing there too.

Thanks,
Dimitris
Re: Java and epsilon ecl syncronizathion [message #1861500 is a reply to message #1861499] Mon, 16 October 2023 17:33 Go to previous messageGo to next message
Mauro Sonzogni is currently offline Mauro SonzogniFriend
Messages: 10
Registered: October 2023
Junior Member

I have modified the models, trying to simplify them, and removed everything that was unnecessary in the ECL file. I cannot remove the nested loops as I suspect the issue might be coming from there.
Thank you, Mauro.
Re: Java and epsilon ecl syncronizathion [message #1861501 is a reply to message #1861500] Mon, 16 October 2023 18:57 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

> I cannot remove the nested loops as I suspect the issue might be coming from there.

Well, one of us needs to test this hypothesis. If you suspect that multiple executions may be causing the issue, start by trying exactly 2 executions.

Thanks,
Dimitris
Re: Java and epsilon ecl syncronizathion [message #1861519 is a reply to message #1861501] Tue, 17 October 2023 07:55 Go to previous messageGo to next message
Mauro Sonzogni is currently offline Mauro SonzogniFriend
Messages: 10
Registered: October 2023
Junior Member
Hi,
I tried again with just two models as you suggested (actually, it was the basic step I started with), and it still seems to have issues. I've updated the code on GitHub. I apologize if I took this basic version for granted, but when I tested it, it always returned correct results (even now, sometimes it gives the correct result, other times it doesn't).
Thanks, Mauro.
Re: Java and epsilon ecl syncronizathion [message #1861521 is a reply to message #1861519] Tue, 17 October 2023 08:12 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

I've updated to the latest version of your example and every time I run the program I get "MATRIX 1.0" in the output. Do you get a different result sometimes? In case it makes a difference I'm using Java 17.0.5.

Thanks,
Dimitris

Re: Java and epsilon ecl syncronizathion [message #1861522 is a reply to message #1861521] Tue, 17 October 2023 08:23 Go to previous messageGo to next message
Mauro Sonzogni is currently offline Mauro SonzogniFriend
Messages: 10
Registered: October 2023
Junior Member
Yes, sometimes I get an output of 0.5, which is also the result I want to obtain. The Java version is the same.
Thank you, Mauro.
Re: Java and epsilon ecl syncronizathion [message #1861550 is a reply to message #1861522] Wed, 18 October 2023 12:19 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Changing line 13 of the ECL program to

editDistance=0.5.asDouble().println("Edit distance changed to: ");


doesn't print anything to the console in the current version of the code in the repo. This suggests that there are no matches for this rule. Is this expected?

Thanks,
Dimitris
Re: Java and epsilon ecl syncronizathion [message #1861552 is a reply to message #1861550] Wed, 18 October 2023 13:10 Go to previous messageGo to next message
Mauro Sonzogni is currently offline Mauro SonzogniFriend
Messages: 10
Registered: October 2023
Junior Member
Hi,
no, I didn't expect there to be no match either. Yesterday, while delving into this with my tutor Ludovico Iovino, he pointed out this issue to me. We tried changing the match, and at that point, it entered the rule correctly, but the result I was getting on the Java side still wasn't the one updated by the rule. Now he advised me to change my approach and use the match trace to achieve my goal. However, I have another question: how can I perform a match on subtypes? Currently, the rule wasn't returning a match because the match was made on `ComponentInstances` and not on its subtypes, `SystemInstance`. If I wanted to perform a match on `ComponentInstance` and its subtypes, how could I do that?
Thank you very much,
Mauro.
Re: Java and epsilon ecl syncronizathion [message #1861553 is a reply to message #1861552] Wed, 18 October 2023 13:26 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

https://eclipse.dev/epsilon/doc/ecl/#rule-execution-scheduling (search for "greedy") should help with the new question.

Thanks,
Dimitris
Re: Java and epsilon ecl syncronizathion [message #1861554 is a reply to message #1861553] Wed, 18 October 2023 13:38 Go to previous messageGo to next message
Mauro Sonzogni is currently offline Mauro SonzogniFriend
Messages: 10
Registered: October 2023
Junior Member
Thank you for the help and the time you have dedicated to me,
Mauro.
Re: Java and epsilon ecl syncronizathion [message #1861555 is a reply to message #1861553] Wed, 18 October 2023 14:22 Go to previous messageGo to next message
Mauro Sonzogni is currently offline Mauro SonzogniFriend
Messages: 10
Registered: October 2023
Junior Member

Hello, I've updated the code and set the rule as greedy. Now, it does find a match, but it still doesn't print the value to the console in the 'do' part, which I expected it to do at this point. In addition to this, I've tried adding information to the 'Info' map of the match trace, but without any results (I saw that you had answered a similar question in the past, but the link you provided leads to a 404 error, so I relied on what another user had responded). Could you please guide me on the correct way to do this?
Thanks, Mauro.
Re: Java and epsilon ecl syncronizathion [message #1861556 is a reply to message #1861555] Wed, 18 October 2023 14:33 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

You're missing a

compare: true 


within the rule.

Thanks,
Dimitris
Previous Topic:Method not found for child class based on a class from another model
Next Topic:Flexmi and load resources
Goto Forum:
  


Current Time: Sat Apr 27 08:04:23 GMT 2024

Powered by FUDForum. Page generated in 0.05165 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top