[iss-45] OrdSetsAndMaps#53
Conversation
|
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. |
|
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: |
|
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: |
|
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: |
|
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. |
|
I suggest giving English names to all variables and functions to keep the same style for all the project. |
| auto liPrev = indices.before_begin(); | ||
| auto liCurr = indices.begin(); | ||
|
|
||
| bool doInt = (!(elementMax.menorThan(mdi.minElem())) && !(mdi.maxElem().menorThan(elementMin))); |
There was a problem hiding this comment.
In line 1163 Is the left side of the && necessary? We check that condition while advancing pos in line 1140.
There was a problem hiding this comment.
It was resolved with doInt auxiliary function, but
|
|
||
|
|
||
| Map::~Map() {} | ||
| Map::Map(const SetAF &fact) : fact_(fact), dom_(fact.createSet()) {} |
There was a problem hiding this comment.
Keep the writing style for all Map constructors.
|
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. |
|
Changes in pw_map.* are missing because we are getting errors while building saying that menorThan is non-existent now. |
|
In general we have used camel case for function names, and for variables underscores: |
| if (i.isEmpty()) | ||
| intervals_ = InterVector(); | ||
| { | ||
| if (i.isEmpty()){ |
There was a problem hiding this comment.
It's silly, but braces are not necessary.
|
|
||
| bool PWMap::operator==(const PWMap &other) const | ||
|
|
||
| bool mapEntryComp(const MapEntry &mpe1, const MapEntry &mpe2) |
There was a problem hiding this comment.
Maybe we can define bool operator<(const MapEntry &mpe1, const MapEntry &mpe2) instead of mapEntryComp?
| { | ||
| if (!m.dom().isEmpty()){ | ||
| MapEntry mpe = createMapEntry(m); | ||
| if (pieces_.empty() || pieces_.back().second.first < mpe.second.first) |
There was a problem hiding this comment.
Use mapEntryComp instead of pieces_.back().second.first < mpe.second.first.
| Map resComb = fact_.createMap(om.dom(), om.exp()); | ||
|
|
||
| if (doInt(osp, tsp)){ | ||
| Set oDom = om.dom(), new_dom = oDom.difference(dom()); |
There was a problem hiding this comment.
dom() can be calculated out of the loop.
| { | ||
| return delegate_->filterMap(f); | ||
| OrdPWMap res(fact_); | ||
| if (subdom.isEmpty()) |
There was a problem hiding this comment.
As in firstInv: if (isEmpty() || subdom.isEmpty()) can be used.
| Interval all(0, 1, Inf); | ||
| Set univ = fact_.createSet(SetPiece(arity(), all)); | ||
| OrdPWMapCRef othr = static_cast<OrdPWMapCRef>(other); | ||
| processMapsOrd(othr,univ, static_cast<OrdPWMapRef>(*res) , &OrdPWMap::processMinus,true); |
There was a problem hiding this comment.
If the purpose of the Set argument of processMapsOrd is to return a value (for example, like in equalImage), univ here should not be passed as argument.
Then, in minAdjMap is used to keep a register for visited values in the domain. I think that is better to modify the function processMapsOrd to take two Sets as arguments: one for input and the other for output.
| unsigned int OrdPWMap::emplaceHint(const Map &m ,unsigned int hint) | ||
| { | ||
| return delegate_->operator+(*other.delegate_); | ||
| auto end = pieces_.end(); |
There was a problem hiding this comment.
Check if m.dom().isEmpty() before inserting the element in the pw. This way in other functions:
if (!m.dom().isEmpty())
emplaceHint(...);
can be directly substituted by:
emplaceHint(...);
| for (const MapEntry &mpe : pieces_){ | ||
| const Map &inv = mpe.first.minInv(); | ||
| if(!inv.dom().isEmpty()) | ||
| res.pieces_.emplace_back(createMapEntry(inv)); |
There was a problem hiding this comment.
Use OrdPWMap::emplaceBack.
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.