use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList in project eclipse-collections by eclipse.
the class ImmutableEmptySortedBagTest method collectInt.
@Override
@Test
public void collectInt() {
ImmutableSortedBag<Integer> bag = this.classUnderTest();
Assert.assertEquals(new IntArrayList(), bag.collectInt(PrimitiveFunctions.unboxIntegerToInt()));
}
use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList in project eclipse-collections by eclipse.
the class ImmutableEmptySortedBagTest method collectInt_target.
@Override
@Test
public void collectInt_target() {
ImmutableSortedBag<Integer> bag = this.classUnderTest();
Assert.assertEquals(new IntArrayList(), bag.collectInt(PrimitiveFunctions.unboxIntegerToInt(), new IntArrayList()));
ImmutableSortedBag<Integer> bag2 = this.classUnderTest();
Assert.assertEquals(new IntHashBag(), bag2.collectInt(PrimitiveFunctions.unboxIntegerToInt(), new IntHashBag()));
}
use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList in project narchy by automenta.
the class Subterms method indicesOf.
@Nullable
default IntArrayList indicesOf(Predicate<Term> t) {
IntArrayList a = new IntArrayList(1);
int s = subs();
for (int i = 0; i < s; i++) {
if (t.test(sub(i)))
a.add(i);
}
if (!a.isEmpty())
return a;
else
return null;
}
use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList in project narchy by automenta.
the class FastUndirGraph method initGraph.
// -----------------------------------------------------------------
@Override
protected void initGraph() {
final int max = g.size();
triangle = new BitSet[max];
for (int i = 0; i < max; ++i) {
in[i] = new IntArrayList();
triangle[i] = new BitSet(i);
}
for (int i = 0; i < max; ++i) {
int ii = i;
g.neighbors(i).forEach(out -> {
if (!g.isEdge(out, ii))
in[out].add(ii);
// But always add the link to the triangle
if (// make sure i>j
ii > out)
triangle[ii].set(out);
else
triangle[out].set(ii);
});
}
}
use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList in project narchy by automenta.
the class UCTNode method actionSelect.
/**
* determine the next action to play
*
* @param agent
* @param dfr
* @return
*/
private int actionSelect(Agent agent, int dfr) {
assert (agent.numActions() >= children.size());
final double[] maxValue = { Double.MIN_VALUE };
final int[] selectedAction = { 0 };
// at random
if (children.size() < agent.numActions()) {
IntArrayList unexplored = new IntArrayList();
for (int a = 0; a < agent.numActions(); a++) {
if (!children.containsKey(a)) {
unexplored.add(a);
}
}
selectedAction[0] = unexplored.get(Util.randRange(unexplored.size()));
} else {
// The general idea is to explore the most promising(with the
// highest expected reward) actions. But also
// explore other actions not to get stuck with wrong decisions.
children.forEachKeyValue((i, currNode) -> {
double value = 1.0 / (double) (dfr * (agent.maxReward() - agent.minReward())) * currNode.expectation() + explorationRatio * Math.sqrt(Math.log((double) visits) / (double) currNode.visits);
if (value > maxValue[0]) {
maxValue[0] = value;
selectedAction[0] = i;
}
});
}
return selectedAction[0];
}
Aggregations