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

Implementation of a Coupled Similarity Checker #1619

Merged
merged 3 commits into from Jan 14, 2021

Conversation

Noxsense
Copy link
Contributor

@Noxsense Noxsense commented Aug 9, 2020

For my bachelor thesis I extended ltscompare with an algorithm which checks for Coupled Similarity[PS92]. Now I want to make it a merge-able and maintainable part of your code base.

By now it just compares the input and returns a boolean saying wether they are equal by definition with a suggested algorithm that uses a game theoretic approach [BN19].

Due to only limited insight to all possibilities this whole project offers, I might have not made very effective decisions and I am very thankful for any suggestions and tips for what I could improve, please.

I may also want to extend my contribution to ltsconvert at a later time.

Various tests will follow soonish.


[PS92] Parrow, Joachim and Sjödin, Peter: Multiway synchronization verified with coupled simulation. Springer Berlin Heidelberg, 1992.

[BN19] Bisping, Benjamin and Nestmann, Uwe: Computing Coupled Similarity. Springer International Publishing, 2019.

@tneele
Copy link
Member

tneele commented Aug 17, 2020

Thanks for this contribution! My response is somewhat delayed due to the holidays. On first glance, your code looks good. I think the data structures can be improved if you want to be able to handle larger transition systems. I will have a detailed look at it some time this week.

@Noxsense
Copy link
Contributor Author

Thanks for your response. I am looking forward to it. For my own usecases I had some
performance difficulties and I already thought this needs improvement,
so I am interested to see your ideas.

Copy link
Member

@tneele tneele left a comment

Choose a reason for hiding this comment

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

I have added some inline comments that may help you improve some details of the implementation. As for the data structures, I currently don't have a deep enough understanding of the algorithm to give a clear idea about what is optimal. I do have a hint that might guide you in the right direction: have a look at the data structures used for storing parity games in one of our libraries. Here, the nodes are stored in a vector and indexed by their position in the vector. This allows for much faster lookup than in a large map.

libraries/lts/include/mcrl2/lts/detail/liblts_coupledsim.h Outdated Show resolved Hide resolved
libraries/lts/include/mcrl2/lts/detail/liblts_coupledsim.h Outdated Show resolved Hide resolved
libraries/lts/include/mcrl2/lts/detail/liblts_coupledsim.h Outdated Show resolved Hide resolved
Comment on lines +366 to +369
stream << (l1.action_label(a));
move_label = stream.str();
stream.str("");
stream.clear();
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this can be simplified with the std::to_string function.

libraries/lts/include/mcrl2/lts/detail/liblts_coupledsim.h Outdated Show resolved Hide resolved
{
if (node_winner.find(n) == node_winner.end())
{
std::cerr
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to consistently use mCRL2log. That output also goes to stderr, by the way. You can always use a higher log level such as log::warning or log::error to ensure this output is shown.

}
else // just extend simply.
{
for (const auto &ntrans : next)
Copy link
Member

Choose a reason for hiding this comment

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

We allow C++17 code, so you can use a structured binding here to make the code even more compact.

This new equivalence checks the two root processes
for coupled simulation equivalence, introduced
by Parrow and Sjödin in 1992 [PS92].

The algorithm uses the game theoretic approach of
Bisping and Nestmann from 2019 [BN19].

The algorithm will return equality,
if the root processes are coupled similar.
Additionally it calculates the set R,
which can be shown with the `ltscompare` flag `--debug`.
@mlaveaux mlaveaux self-assigned this Dec 17, 2020

std::map<cs_game_move, bool> todo_if;

// TODO this includes also weak, as challenge giver invalid, solve!
Copy link
Member

Choose a reason for hiding this comment

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

Does this TODO item mean that the implemented algorithm is not yet fully correct? If so, what steps are necessary in order to finalise the algorithm. Same remark on line 419.

cs_game_node from, to;
size_t act;
std::string label_of_action;
bool weak;
Copy link
Member

Choose a reason for hiding this comment

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

This 'weak' field is only read from and never assigned to.

Comment on lines +224 to +228
if (len < 1) // no further steps.
{
continue;
}
else // just extend simply.
Copy link
Member

Choose a reason for hiding this comment

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

This is the same as if (len >= 1). Also on line 295.

@mlaveaux
Copy link
Member

mlaveaux commented Jan 11, 2021

This pull request has been open for some time and it is a worthwhile addition for our tool set. Therefore, I have resolved the relatively minor comments locally and have also added the small example from the 2019 paper as a test case. I cannot commit these changes to your branch, but I can apply them before merging the pull request. However, before I can merge it there is one remark about the TODO statement that I cannot resolve without your input.

EDIT: I can actually push my commits to your branch.

Comment on lines +214 to +216
if (true) // also just tau chains may be later used
// if (already_good) // (actually already) done
{
Copy link
Member

Choose a reason for hiding this comment

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

Here, the comments indicate an alternative condition, but it is not clear what should be chosen. Same on line 285.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this whole block, starting at L200, I wanted to create weak transitions, since I wasn't sure there was a already method supporting such things. So I created my own weak_transitions struct there and fetched all weak transitions.

The actual if (true) block had an old condition, I didn't use anymore and was later abused as indentation.

@Noxsense
Copy link
Contributor Author

Yeah, I am sorry, I have not fixed those issues yet, since I was busy and later
forgot it. Thanks for fixing the small issues.

My old TODOs are working and correct in a very naive way. But I added those
TODOs as Future Roadmap for my actual bachelor theses to also use a more
effective algorithm to calculate the coupled simulation preorder.

(And maintainers are allowed to edit for this commit.)

@mlaveaux
Copy link
Member

No problem. If the TODO's are only further performance improvements then I propose that we merge this pull request as it is now so that other users can also experiment with coupled similarity. Whenever the new algorithm is finished you can then open a new pull request to update the implementation.

@mlaveaux mlaveaux marked this pull request as ready for review January 14, 2021 14:15
@mlaveaux mlaveaux changed the title [WIP] Implementation of a Coupled Similarity Checker Implementation of a Coupled Similarity Checker Jan 14, 2021
@mlaveaux mlaveaux merged commit cdd52f3 into mCRL2org:master Jan 14, 2021
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.

None yet

3 participants