Skip to content

[iss-45] OrdSetsAndMaps #53

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

Open
wants to merge 18 commits into
base: sb-graph-dev
Choose a base branch
from
Open

Conversation

LucasCavagna
Copy link
Collaborator

I decided to implement a new version for all ordered set operations. I used linked lists and different conditions to minimize the number of operations in the intersection process, supporting sets with multiple dimensions and variable steps. Then, I wrote a new version for union, difference, minus, and complement operations to also support multiple dimensions and variable steps.

@LucasCavagna LucasCavagna added the enhancement New feature or request label Mar 26, 2025
@LucasCavagna LucasCavagna added this to the SB-Graph 4.0.0 milestone Mar 26, 2025
@LucasCavagna LucasCavagna self-assigned this Mar 26, 2025
@LucasCavagna LucasCavagna linked an issue Mar 26, 2025 that may be closed by this pull request
@Kalashnikovni Kalashnikovni moved this from To do to In progress in SB-Graph library issue tracker. Mar 26, 2025
@LucasCavagna
Copy link
Collaborator Author

Commit from Apr 10, 2025

MODIFICATIONS:

Ordered intersection has been modified — not optimal yet.

interForComl has been added — not the final version.

Ordered complement has been modified — still not final.

Multi-dimensional tests have been added to set_perf.

COMMENTS: The changes to the ordered complement have resulted in improved performance during the tests — approximately 5X faster than the previous implementation.

@LucasCavagna
Copy link
Collaborator Author

Commit from Apr 16, 2025

MODIFICATIONS:

The ordered intersection has been updated — this is supposed to be the final version.

interForComl has been modified — we removed unnecessary intersections.

The ordered complement has been updated — almost final version. In the end, there's no need to use the Boost library or perform sorting, either here or in the intersection.

Multi-dimensional tests have been added to set_perf — specifically those that test the conditions added to interForComl.

COMMENTS:
The changes to the ordered complement have led to improved performance during testing — approximately 2X faster than the previous implementation.

@LucasCavagna
Copy link
Collaborator Author

Commit from Apr 23, 2025

MODIFICATIONS:

All operations for ordered pwmaps have been implemented except for: reduce, minMap, minAdj, and compact — these are not final versions yet.

The emplaceHint function was added. It inserts a map element into an ordered pwmap in an ordered manner based on a given hint — it attempts to place the element linearly starting from the hint.

COMMENTS:
Operations on ordered pwmaps generally perform as well as or better than those on unordered pwmaps. However, it is only due to the image of the maps that certain operations—like inverse—end up being more costly.

@LucasCavagna
Copy link
Collaborator Author

Commit from May 12, 2025

MODIFICATIONS:

Minimal updates applied to orderedSet operations.

Special cases added to enhance behavior in certain operations.

Refactored interForCompl and intersection to separate the search criterion from the search starting point selection.

Variable names updated to be more representative and improve code clarity.

COMMENTS:
These changes are minor and do not significantly impact the performance of operations on orderedSets.

@LucasCavagna
Copy link
Collaborator Author

Commit from May 25, 2025

MODIFICATIONS:

The traverse function was removed, and its logic was directly integrated into the disjoint union function.

The interForCompl function was renamed to intersectionComp and its algorithm was optimized.

The algorithms for complement and intersection were modified and optimized.

COMMENTS:

The following results were obtained:

Intersection time reduced by 93% compared to the unordered sets version.

Union time reduced by 34% compared to the unordered sets version.

Difference time reduced by 47% compared to the unordered sets version.

Complement time reduced by 51% compared to the unordered sets version.

Disjoint union time reduced by 40% compared to the unordered sets version.

Time reduction of over 90% in union, intersection, difference, and complement when handling 3 dimensions, compared to the unordered sets version.

@LucasCavagna
Copy link
Collaborator Author

Commit from Jun 5, 2025

MODIFICATIONS:

Minor modification in intersectionComp to eliminate additional redundant cases.

Adjustments to the synthetic tests to ensure fair performance measurement across operations.

Fixed the use of the minimum and maximum domain bounds of a map for sorting purposes. The map structure was updated to store its peripheral minimum and maximum bounds upon creation and to leverage this information effectively.

Implemented one-dimensional examples for half of the operations defined on pwmaps.

COMMENTS:

The mapInf operation does not perform compositions because it starts with n equal to zero. Should this be the expected behavior?

@LucasCavagna
Copy link
Collaborator Author

Commit from Jun 8, 2025

MODIFICATIONS:

A bug in the synthetic test cases that caused a segmentation fault was fixed.

COMMENTS:

The current implementation of minimum and maximum perimeter recalculates each time they are needed; it would be good to avoid this without negatively affecting the maps implementation when they are unordered.

@Kalashnikovni
Copy link
Collaborator

I suggest giving English names to all variables and functions to keep the same style for all the project.

sbg/set.cpp Outdated
auto liPrev = indices.before_begin();
auto liCurr = indices.begin();

bool doInt = (!(elementMax.menorThan(mdi.minElem())) && !(mdi.maxElem().menorThan(elementMin)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

In line 1163 Is the left side of the && necessary? We check that condition while advancing pos in line 1140.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was resolved with doInt auxiliary function, but

Map::~Map() {}
Map::Map(const SetAF &fact) : fact_(fact), dom_(fact.createSet()) {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Keep the writing style for all Map constructors.

@LucasCavagna
Copy link
Collaborator Author

Commit from Jun 12, 2025

MODIFICATIONS:

All changes committed are based on the previous comments.

Some auxiliary functions have been added to set.cpp for OrderedSets.

COMMENTS:

There is a conflict with some files. I suppose this is because Git is comparing the branches in preparation for a possible merge.

@Kalashnikovni
Copy link
Collaborator

Kalashnikovni commented Jun 18, 2025

Changes in pw_map.* are missing because we are getting errors while building saying that menorThan is non-existent now.

@Kalashnikovni
Copy link
Collaborator

In general we have used camel case for function names, and for variables underscores:

void someFunction() {
  int my_variable = 10;
  return x*my_variable;
}

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
Development

Successfully merging this pull request may close these issues.

OrdMultiDimSets
2 participants