-
Notifications
You must be signed in to change notification settings - Fork 15
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
Union Intersection difference #60
Comments
It is a bit dirty but corresponds to the used data model and java conventions. |
Thanks,
|
The Cell object fields are reduced to a single integer from 0 to 80 inclusive which represents the cell position within the grid. You can simply compare the cellIndex or the whole cell object. |
I made a heavy-handed attempt at re-writing WXYZwing.java which should be now in the newTechniques branch and is much better than the one by sunny shine. It can work as a template for VWXYZ wing too which I'm happy to proceed with. Bigger wings are possible but would degrade speed significantly as each one would have more & more inner loops. They would be best reported through an ALS-xz technique which is either on the to-do list or possibly in sunny-shine's next update |
@SudokuMonster Congratulations for the good work! |
I'. going now to see if I can increase the efficiency of the wing algorithm preventing the same set of cells appearing again in batch mode. I already have a few solution(s) but it would be quicker if there is a way to get Cell.getVisibleCellIndexes() with the result showing only VisibleCellIndexes > CellIndex. I will attempt a few things!!!! |
I've improved efficiency by 5% through reducing duplication of same technique cells in both wxyz and vwxyz. I Added forwardVisibleCellIndex and forwardVisibleCellsSet to Grid.java |
The purpose of CellSet is to provide a more efficient way for storing and accessing unordered sets of cells, keeping the java-style coding. This has its negatives - inefficient code, limitations, etc.
What you need is to start not from 0 but from other known value.
but in its current form CellSet doesn't allow this. The more general question is whether heavily working with indexes on sparse sets is effective or not. In C/C++ I would use bitmaps instead of arrays of indexes in most of the code. |
I'm confessing that my solutions attempt using what is available without groundbreaking solutions. Like this
which effectively allows me (without checking) that yzCell is exactly how I want it to be My perceived efficiency improvement is in comparison to how I programmed it to start with. The current state may still be improved using better methods |
In your example the two constructors are very slow - they dynamically create array of integers, then a loop over the array sets all provided bits one by one. Using a predefined constant holding all 81 bits would accelerate the process, but cloning it (in order to modify) also takes resources - I don't know why, but cloning BitSet does take resources. The copy constructor in fact clones the given constant parameter but I didn't make precise measurements how faster it is compared to the cloning. Better is to add a CellSet constructor that takes one or two integers as parameters. It can build the underlying BitSet from scratch using the builtin BitSet method set(int fromIndex, int toIndex). Even better is to start from empty CellSet (requires new constructor, so far intentionally not implemented) and work with negate operations - instead of clearing, perform setting of the bits, and eventually negate the final result (requires new method Seems that your sequence is logically equivalent to CellSet yzCellRange = new CellSet(wxyzCell.getVisibleCells());
yzCellRange.addAll(wzCell.getVisibleCells());
yzCellRange.addAll(xzCell.getVisibleCells());
yzCellRange.add(wxyzCell);
yzCellRange.add(wzCell);
yzCellRange.add(xzCell); In C++ using the lookups and structures defined in fsss2.h and t_128.h I would use such sequence bm128 yzCellRange(constraints::visibleCells[wxyzCellIndex]); //accumulate needed cells here
yzCellRange |= constraints::visibleCells[wzCellIndex];
yzCellRange |= constraints::visibleCells[xzCellIndex];
yzCellRange.setBit(wxyzCellIndex); //unnecessary if it is seen by one of the other two cells
yzCellRange.setBit(wzCellIndex); //unnecessary if it is seen by one of the other two cells
yzCellRange.setBit(xzCellIndex); //unnecessary if it is seen by one of the other two cells
yzCellRange &= (bm128)constraints::mask81); //leave only bits in range 0..80 and would know that any of the operations takes few CPU ticks - sometimes less than one, several address calculations will be done, several memory reads, and zero memory writes. Also, looking at your first rows of code in VWXYZWing.java, you need a method !yzCell.getVisibleCells().contains(xzCell) instead of !(yzCell.getX() == xzCell.getX() || yzCell.getY() == xzCell.getY() || yzCell.getB() == xzCell.getB()) |
I didn't know that these existed! It is much easier to do them this way
makes sense. I'll look into that |
@dobrichev I have now paused adding techniques. I will update Master with the current clunky additions. Work would then if there is time on enhancements |
Close the issue? |
@dobrichev Anything in Cell or Grid that would achieve an intersection of VisibleCells or VisibleCellIndexes which then still retains the same properties as VisibleCells or VisibleCellIndexes?
The text was updated successfully, but these errors were encountered: