-
Notifications
You must be signed in to change notification settings - Fork 3
Sorting Matches and Constraints #308
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
Conversation
|
Thank you, @MarkBeB, for your effort in implementing this feature. What I tried:
Do you have an idea? |
|
Standing issues:
|
This PR tackles #260 by adding two new features to GIPS; match sorting and constraint sorting.
To enable match sorting, a sorter needs to be added via the API (
GipsEngineAPI.setMatchSorter(PatternMatch2MappingSorter)) after initialisation but before the problem is built.Once all the matches have been collected, the match sorter is called for each mapper, together with the matches that the mapper has collected. The returned list of matches is then added as mappings to the mapper in sorted order.
I have implemented a sorter (
PatternMatch2MappingSorterByURI) that sorts matches based on their location within the graph. This means that, regardless of the order in which matches are discovered, they can be sorted in the same sequence each time.Constraint sorting works in a very similar way. It can be enabled by setting a constraint sorter via the API (
GipsEngine.setConstraintSorter(ConstraintSorter)). The constraints are sorted before being passed to the solver.ConstraintSorterByNameprovides an implementation that sorts constraints by name. However, other implementations could group them e.g. by type.How to test:
Choose any GIPS project.
Note: The meta-model must be EMF. SmartEMF can only be supported once PR Feature: URI Fragments (SmartEMF) eMoflon/emoflon-core#161 has been merged.
Ensure that the LP path is set. The goal is to generate multiple LP files.
We compare the files to see how each run creates a slightly different LP.
Add both sorters.
api.setMatchSorter(new PatternMatch2MappingSorterByURI());api.setConstraintSorter(new ConstraintSorterByName());Again, run GIPS multiple times to generate one or more LP files.
Compare the newly generated LP files with each other.