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

Possible orders computing efficiency #34

Closed
stephanzwicknagl opened this issue Dec 5, 2023 · 0 comments
Closed

Possible orders computing efficiency #34

stephanzwicknagl opened this issue Dec 5, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@stephanzwicknagl
Copy link
Collaborator

All possible orders of the components of the program as well as the corresponding viasp graphs are calculated in preparation for the dragging of rules.

Efficiency issue: in a program with n independent rules, there are n! possible orders of the rules, thus n! graphs. But a reordering does not always mean that the nodes attached to the component change.

The calculation of possible orders can be simplified by an analysis of the heads of the rules.
E.g.

a.
b :- a.
c :- a.

and

a.
c :- a.
b :- a.
@stephanzwicknagl stephanzwicknagl added the enhancement New feature or request label Dec 5, 2023
@stephanzwicknagl stephanzwicknagl self-assigned this Dec 5, 2023
@stephanzwicknagl stephanzwicknagl changed the title Computing possible orders efficiency Possible orders computing efficiency Dec 20, 2023
stephanzwicknagl added a commit that referenced this issue Feb 21, 2024
This commit adds minimization support to the viASP cli and the python
API. The available options are equivalent to clingo. They are passed on
to the clingo control object to be tasked with optimization.

The graph creation has been optimized to be more efficient. Programs
with many rules and correspondingly many possible sorts are now created
on demand. This is done by generating only the graph from the primary
sort in the beginning. All possible sorts are calculated and stored in
the database. When the frontend requests a graph for one of the possible
sorts, it is created while the frontend shows a loading animation.

All data is stored in the sqlite database. It is created and destroyed
when the server is started and stopped.

Resolves: #34
stephanzwicknagl added a commit that referenced this issue Apr 13, 2024
This commit adds the first elements for an efficient (lazy) generation
of possible orders for transformations.

Contributes: #34
stephanzwicknagl added a commit that referenced this issue Apr 16, 2024
This approach prevents a huge computational load at the beginning of
the rendering process. Possible orders are calculated 'lazily', i.e.
when needed.

Upon the initial rendering of the graph, each component (transformation)
is analyzed in the current (primary) sort order. If the component can
be placed at a different index with all other transformations in the
same order, this new order is called "adjacent" to the current order.

This index is stored in a component's adjacent_sort_indices attribute.
Additionally the hash of this new order is generated and stored in a
the graphs database table. A database table "graph_relations" stores
this adjacency relation between the (current) graph's hash and the
adjacent graph's hash.

The frontend doesn't fetch possible orders directly, instead it follows
the possible orders defined in the component's attributes. When the user
drags a component to a new index, the new index is compared to the list
of possible indices in the component's adjacent_sort_indices attribute.

If the new index is in the list of possible indices, the component is
repositioned and the information about the moved component is sent to
the backend. The backend then calculates the adjacent_sort_indices for
the new order.

Contributes: #34
stephanzwicknagl added a commit that referenced this issue Apr 16, 2024
stephanzwicknagl added a commit that referenced this issue Apr 22, 2024
The rule container can be stored in the database, so that the input
program does never need to be parsed again. The Container has both the
AST representation as well as the string representation of the rules.

When the dependency graph is generated, the RuleContainer is created
from the input AST. A rule container can then be merged with another
to remove cycles/loops in the graph. A component of the viasp graph
then contains a RuleContainer.

This commit contains changes to the whole codebase to reflect the new
Container. Tests are updated.

Contributes: #34
stephanzwicknagl added a commit that referenced this issue Apr 22, 2024
stephanzwicknagl added a commit that referenced this issue Apr 22, 2024
More efficient way to store the possible indices of a transformation.

Contributes: #34
stephanzwicknagl added a commit that referenced this issue Apr 25, 2024
@stephanzwicknagl stephanzwicknagl added this to the 3.0 milestone May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant