Warning: session_start(): open(/var/lib/php/sessions/sess_1m3sak72uagmt5i8dev3f40v63, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
// simple probabilistic version of AllOnAll
// where you simply supply a function that calculates a probability for each pair
sclass AllOnAll_probabilistic implements Producer> {
new L aList;
new L bList;
LPair todo = new LinkedList; // this is still non-probabilistic
MultiSetMap> todo2 = multiSetMap_outerDescTreeMap_innerLinkedHashSet();
swappable double probabilityForPair(A a, B b) { ret 1.0; }
void addA(A a) { newA(a); }
void addAIfNotNull(A a) { if (a != null) newA(a); }
synchronized void newA(A a) {
add(aList, a);
addPair(todo, intRange_last(aList), intRange(0, l(bList)));
}
synchronized void newAs(Iterable l) {
fOr (A a : l) newA(a);
}
void addB(B b) { newB(b); }
void addBIfNotNull(B b) { if (b != null) newB(b); }
synchronized void newB(B b) {
add(bList, b);
addPair(todo, intRange(0, l(aList)), intRange_last(bList));
}
synchronized void newBs(Iterable l) {
fOr (B b : l) newB(b);
}
public synchronized Pair next() {
Pair p;
while ((p = popFirst(todo)) != null)
for (A a : subList(aList, p.a))
for (B b : subList(bList, p.b))
addAPair(a, b, probabilityForPair.get(a, b));
ret popFirstValueFromMultiSetMap(todo2);
}
private void addAPair(A a, B b, double probability) {
if (probability > 0)
todo2.put(probability, pair(a, b));
}
synchronized L cloneBList() {
ret clonedList(bList);
}
L getAs() { ret aList; }
L getBs() { ret bList; }
}