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

TPA: Merge DAG nested loops #80

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

BritikovKI
Copy link
Contributor

This is an implementation of the merging of the nested loops into a single Transition System. It is done via the same approach as the transformation of the whole instance into the single System, but is adapted to only merge loops in the Graph structure into a single node.

@BritikovKI BritikovKI force-pushed the CPG-merge-nested-loops branch 2 times, most recently from c04111e to 51299f2 Compare September 1, 2024 12:53
Copy link
Member

@blishko blishko left a comment

Choose a reason for hiding this comment

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

Can you help we understand this by maybe providing some comments or pseudocode?

Also, can you build several benchmarks where you would compare the performance before and after?

@@ -46,6 +47,16 @@ VerificationResult TPAEngine::solve(ChcDirectedHyperGraph const & graph) {
auto translator = std::move(transformationResult.second);
if (transformedGraph->isNormalGraph()) {
auto normalGraph = transformedGraph->toNormalGraph();
if (options.hasOption(Options::SIMPLIFY_NESTED)) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you move this into the solve method that takes DirectedChcGraph?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

if (graph.getVertices().size() <= 3) { return loop; }
auto graphRepresentation = AdjacencyListsGraphRepresentation::from(graph);
auto vertices = reversePostOrder(graph, graphRepresentation);
std::unordered_set<int> visitedVertices;
Copy link
Member

Choose a reason for hiding this comment

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

These should be SymRefs, no? Not ints.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was supposed to be SymRef, but using it creates problems:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can go and try create default constructor for SymRef, but I'm not sure if it is an appropriate solution here

Copy link
Member

Choose a reason for hiding this comment

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

You just need to provide SymRefHash as additional template parameter.
std::unordered_set<SymRef, SymRefHash>.

You have to tell the set how it is supposed to hash your custom type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

std::move(originalGraph), graph, std::move(locationVars), std::move(argVars), simplifiedNodes);
}

void strongConnection(std::unordered_set<int> & visitedVertices, std::unordered_set<int> & verticesOnStack,
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a pseudocode or a reference, or an explanation?
It is not easy to follow what the algorithm is doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

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.

2 participants