Skip to content

Commit

Permalink
Merge branch 'release/11.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
DanySK committed May 18, 2021
2 parents 0cb6a8e + f9fd603 commit 3fae0fb
Show file tree
Hide file tree
Showing 37 changed files with 342 additions and 282 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: CI
on:
push:
tags: '*'
branches-ignore:
- 'autodelivery**'
- 'bump-**'
pull_request:
schedule:
- cron: '0 3 * * SUN'

Expand All @@ -9,7 +14,7 @@ jobs:
strategy:
matrix:
os: [windows, macos, ubuntu]
jvm_version: [8, 11, 14, 15]
jvm_version: [8, 11, 15]
runs-on: ${{ matrix.os }}-latest
env:
JAVA_VERSION: ${{ matrix.jvm_version }}
Expand Down Expand Up @@ -89,7 +94,7 @@ jobs:
if: ${{ env.REFERENCE == 'true' }}
uses: codecov/codecov-action@v1
- name: Deploy
if: ${{ env.REFERENCE == 'true' }}
if: ${{ env.REFERENCE == 'true' && github.event_name == 'push' }}
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -127,7 +132,7 @@ jobs:
Automerge:
needs: CI-Complete
runs-on: ubuntu-latest
if: always()
if: success()
steps:
- name: automerge
uses: "DanySK/yaagha@master"
Expand Down
83 changes: 0 additions & 83 deletions .github/workflows/build-external-pull-requests.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import org.apache.commons.math3.random.MersenneTwister
class TestSensory<T> : StringSpec({

"field of view" {
val env = Continuous2DEnvironment<T>(SupportedIncarnations.get<T, Euclidean2DPosition>("protelis").orElseThrow())
val env = Continuous2DEnvironment<T>(
SupportedIncarnations.get<T, Euclidean2DPosition>("protelis").orElseThrow()
)
val rand = MersenneTwister(1)
env.linkingRule = NoLinks()
val observed = HomogeneousPedestrian2D(env, rand)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ private void newStatus(final Status next) {
@Override
public void nodeAdded(final Node<T> node) {
checkCaller();
afterExecutionUpdates.add(new Addition(node));
afterExecutionUpdates.add(new NodeAddition(node));
}

@Override
Expand All @@ -329,7 +329,7 @@ public void nodeMoved(final Node<T> node) {
@Override
public void nodeRemoved(final Node<T> node, final Neighborhood<T> oldNeighborhood) {
checkCaller();
afterExecutionUpdates.add(new Removal(node));
afterExecutionUpdates.add(new NodeRemoval(node));
}

@Override
Expand All @@ -342,6 +342,21 @@ public void play() {
newStatus(RUNNING);
}

@Override
public void reactionAdded(final Reaction<T> reactionToAdd) {
reactionChanged(new ReactionAddition(reactionToAdd));
}

@Override
public void reactionRemoved(final Reaction<T> reactionToRemove) {
reactionChanged(new ReactionRemoval(reactionToRemove));
}

private void reactionChanged(final UpdateOnReaction update) {
checkCaller();
afterExecutionUpdates.add(update);
}

private Stream<Reaction<T>> reactionsToUpdateAfterExecution() {
return afterExecutionUpdates.stream()
.flatMap(Update::getReactionsToUpdate)
Expand Down Expand Up @@ -487,7 +502,7 @@ private Update(final Node<T> source) {
this.source = source;
}

public final Stream<Reaction<T>> getReactionsRelatedTo(final Node<T> source, final Neighborhood<T> neighborhood) {
protected final Stream<Reaction<T>> getReactionsRelatedTo(final Node<T> source, final Neighborhood<T> neighborhood) {
return Stream.of(
source.getReactions().stream(),
neighborhood.getNeighbors().stream()
Expand Down Expand Up @@ -523,28 +538,79 @@ public Stream<Reaction<T>> getReactionsToUpdate() {

}

private final class Removal extends Update {
private class UpdateOnNode extends Update {

private Removal(final Node<T> source) {
private final Function<Reaction<T>, Update> reactionLevelOperation;

private UpdateOnNode(final Node<T> source, final Function<Reaction<T>, Update> reactionLevelOperation) {
super(source);
this.reactionLevelOperation = reactionLevelOperation;
}

@Override
public final void performChanges() {
getSource().getReactions().stream()
.map(reactionLevelOperation)
.forEach(Update::performChanges);
}
}

private final class NodeRemoval extends UpdateOnNode {
private NodeRemoval(final Node<T> source) {
super(source, ReactionRemoval::new);
}
}

private final class NodeAddition extends UpdateOnNode {
private NodeAddition(final Node<T> source) {
super(source, ReactionAddition::new);
}
}

private abstract class UpdateOnReaction extends Update {

private final Reaction<T> actualSource;

private UpdateOnReaction(final Reaction<T> source) {
super(source.getNode());
actualSource = source;
}

@Override
public final Stream<Reaction<T>> getReactionsToUpdate() {
return Stream.of(actualSource);
}

@Override
public abstract void performChanges();

protected Reaction<T> getSourceReaction() {
return actualSource;
}
}

private final class ReactionRemoval extends UpdateOnReaction {

private ReactionRemoval(final Reaction<T> source) {
super(source);
}

@Override
public void performChanges() {
for (final Reaction<T> r : getSource().getReactions()) {
dependencyGraph.removeDependencies(r);
scheduler.removeReaction(r);
}
dependencyGraph.removeDependencies(getSourceReaction());
scheduler.removeReaction(getSourceReaction());
}
}

private final class Addition extends Update {
private Addition(final Node<T> source) {
private final class ReactionAddition extends UpdateOnReaction {

private ReactionAddition(final Reaction<T> source) {
super(source);
}

@Override
public void performChanges() {
getSource().getReactions().forEach(Engine.this::scheduleReaction);
Engine.this.scheduleReaction(getSourceReaction());
}
}

Expand All @@ -568,13 +634,13 @@ public Stream<Reaction<T>> getReactionsToUpdate() {
// source, target, and all their neighbors are candidates.
Stream.of(getSource(), target),
Stream.of(environment.getNeighborhood(getSource()), environment.getNeighborhood(getTarget()))
.flatMap(it -> it.getNeighbors().stream()))
.distinct()
.flatMap(it -> it.getReactions().stream())
.filter(it -> it.getInputContext() == Context.NEIGHBORHOOD),
// Global reactions
.flatMap(it -> it.getNeighbors().stream()))
.distinct()
.flatMap(it -> it.getReactions().stream())
.filter(it -> it.getInputContext() == Context.NEIGHBORHOOD),
// Global reactions
dependencyGraph.globalInputContextReactions().stream())
.reduce(Stream.empty(), Stream::concat);
.reduce(Stream.empty(), Stream::concat);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class TestImageEnvironment {
val incarnation = SupportedIncarnations.get<Any, Euclidean2DPosition>("protelis").orElseGet { TODO() }
images.asSequence()
.map { ResourceLoader.getResource(it).path }
.flatMap { sequenceOf(ImageEnvironment<Any>(incarnation, it), ImageEnvironment(incarnation, it, MAX, MAX, MAX)) }
.flatMap {
sequenceOf(ImageEnvironment<Any>(incarnation, it), ImageEnvironment(incarnation, it, MAX, MAX, MAX))
}
.map { it.obstacles }
.forEach { Assertions.assertTrue(it.isNotEmpty()) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ class PropertySerializationTester<T : Property<E>, E : Any>(
return if (deserialized == null) {
"deserialized property is null"
} else {
"property \"${origin.name}: ${origin.value}\" is different from property \"${deserialized.name}: ${deserialized.value}\""
"property \"${origin.name}: ${origin.value}\" " +
"is different than property \"${deserialized.name}: ${deserialized.value}\""
}
}
}
Expand Down Expand Up @@ -185,7 +186,7 @@ class SerializableEnumPropertySerializationTest : PropertySerializationTest() {
}

@Suppress("unused")
protected enum class TestEnum {
enum class TestEnum {
FOO, BAR, TEST
}

Expand Down
5 changes: 4 additions & 1 deletion alchemist-implementationbase/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

dependencies {
api(project(":alchemist-interfaces"))
api(alchemist("interfaces"))
api(apacheCommons("math3"))
api(Libs.java_quadtree)
api(Libs.guava)
Expand All @@ -19,6 +19,9 @@ dependencies {
implementation(Libs.concurrentlinkedhashmap_lru)
implementation(Libs.rtree)
implementation(Libs.trove4j)
testImplementation(alchemist("loading"))
testImplementation(alchemist("engine"))
testImplementation(alchemist("incarnation-protelis"))
}

publishing.publications {
Expand Down
Loading

0 comments on commit 3fae0fb

Please sign in to comment.