Skip to content

Commit

Permalink
Merge branch 'release/11.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
DanySK committed Jul 6, 2021
2 parents 3fae0fb + 4c9a4cb commit aca7aef
Show file tree
Hide file tree
Showing 83 changed files with 592 additions and 468 deletions.
5 changes: 4 additions & 1 deletion .github/scripts/build
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/bin/bash
set -e
./gradlew assemble shadowJar dokkaJavadoc orchidBuild --parallel --scan --stacktrace
./gradlew assemble shadowJar dokkaJavadoc --parallel --scan --stacktrace
if $REFERENCE; then
./gradlew orchidBuild --parallel --scan --stacktrace
fi
2 changes: 1 addition & 1 deletion .github/scripts/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ if [ $GITHUB_REPOSITORY = 'AlchemistSimulator/Alchemist' ]
./gradlew publishKotlinMavenPublicationToCentralS01Repository
# Publish on GitHub. Fails due to overwritings, so it's ok to give up
./gradlew publishKotlinMavenPublicationToGithubRepository --continue || true
./gradlew orchidDeploy
if [ -n "$TAG" ] || [ "$BRANCH" = 'develop' ]
then
./gradlew orchidDeploy
echo Installing surge
sudo npm install --global surge
echo Deploying ${STABILITY_MARKER}javadoc on surge
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [windows, macos, ubuntu]
jvm_version: [8, 11, 15]
jvm_version: [8, 11, 15, 16]
runs-on: ${{ matrix.os }}-latest
env:
JAVA_VERSION: ${{ matrix.jvm_version }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ buildProfile/
.idea/codeStyleSettings.xml
.idea/inspectionProfiles/profiles_settings.xml
.idea/jarRepositories.xml
.idea/dataSources.local.xml

# MacOS
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# 11.3.0

Maintenance release. This release only includes dependency updates and tweaks to allow the simulator to run and build under Java 16.

* Updated Protelis to 15.0.0. This allows the simulator to run Protelis on Java 16.
* The legacy swing effects serialization has been updated to be able to work with Java 16
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,5 @@ class BeliefDanger(
)

private fun List<CognitiveAgent>.aggregateDangerBeliefs() =
if (size > 0) {
this.sumByDouble { it.cognitive.dangerBelief() } / size
} else 0.0
if (isEmpty()) 0.0 else sumOf { it.cognitive.dangerBelief() } / size
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,5 @@ class Fear(
)

private fun List<CognitiveAgent>.aggregateFears() =
if (size > 0) {
this.sumByDouble { it.cognitive.fear() } / this.size
} else 0.0
if (isEmpty()) 0.0 else sumOf { it.cognitive.fear() } / this.size
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class CognitiveOrientingPedestrian2D<T, N : ConvexPolygon, E> @JvmOverloads cons
private val consciousness: CognitivePedestrian2D<T> =
CognitivePedestrian2D(environment, randomGenerator, age, gender, danger, group)
) : HomogeneousOrientingPedestrian2D<T, N, E>(
environment,
randomGenerator,
knowledgeDegree = knowledgeDegree,
group = group
),
environment,
randomGenerator,
knowledgeDegree = knowledgeDegree,
group = group
),
CognitiveAgent by consciousness {

override fun speed() = consciousness.speed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ open class HomogeneousOrientingPedestrian2D<T, N : ConvexPolygon, E> @JvmOverloa
private val maxSide: Double = 60.0,
group: PedestrianGroup2D<T>? = null
) : AbstractOrientingPedestrian2D<T, Ellipse, N, E>(
knowledgeDegree,
randomGenerator,
environment,
group
),
knowledgeDegree,
randomGenerator,
environment,
group
),
Pedestrian2D<T> {

override val shape by lazy { super.shape }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ interface Pedestrian2D<T> : Pedestrian<T, Euclidean2DPosition, Euclidean2DTransf
* The shape of any pedestrian in the Euclidean world.
* Implementors should override this property to prevent the continuous creation of new [Euclidean2DShape]s.
*/
@JvmDefault
override val shape: Euclidean2DShape get() = environment.shapeFactory.circle(defaultRadius)

/**
* The field of view of a pedestrian in the Euclidean world.
* Implementors should override this property to prevent the continuous creation of new [FieldOfView2D]s.
*/
@JvmDefault
val fieldOfView: FieldOfView2D<T> get() =
FieldOfView2D(environment, this, defaultFieldOfViewDepth, defaultFieldOfViewAperture)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TestFeelsTransmission<T, P> : StringSpec({

"danger layer affects cognitive pedestrians" {
fun Environment<T, P>.perceivedDanger() = nodes.filterIsInstance<CognitiveAgent>()
.sumByDouble { it.cognitive.dangerBelief() }
.sumOf { it.cognitive.dangerBelief() }
fun EuclideanEnvironment<T, P>.dangerIsLoaded() = this.also {
nodes.filterIsInstance<AbstractCognitivePedestrian<*, *, *, *>>().forEach {
it.danger shouldNotBe null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
/**
* This class tests some basic Commands, like pause and start.
*/
public class TestConcurrency {
class TestConcurrency {

private Environment<Object, Euclidean2DPosition> env;

Expand Down Expand Up @@ -72,7 +72,7 @@ public void setUp() {
value = "RV_RETURN_VALUE_IGNORED_BAD_PRACTICE",
justification = "We don't need the status of the Runnable"
)
public void testCommandInterleaving() throws InterruptedException, ExecutionException {
void testCommandInterleaving() throws InterruptedException, ExecutionException {
final int inWaitCount = 100;
final Simulation<?, ?> sim = new Engine<>(env, 10);
sim.pause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,16 @@ import it.unibo.alchemist.model.interfaces.EuclideanEnvironment
*/
interface Euclidean2DEnvironment<T> : EuclideanEnvironment<T, Euclidean2DPosition> {

@JvmDefault
override val origin: Euclidean2DPosition get() = Companion.origin

/**
* Creates a new [Euclidean2DPosition].
*/
@JvmDefault
fun makePosition(x: Double, y: Double): Euclidean2DPosition = Euclidean2DPosition(x, y)

/**
* Creates a new [Euclidean2DPosition].
*/
@JvmDefault
override fun makePosition(vararg coordinates: Double): Euclidean2DPosition =
if (coordinates.size == 2) makePosition(coordinates[0], coordinates[1])
else throw IllegalArgumentException("Illegal coordinates (required 2): ${coordinates.contentToString()}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,37 @@ interface Segment2D<P : Vector2D<P>> {
/**
* The length of the segment.
*/
@JvmDefault
val length: Double get() = toVector.magnitude

/**
* Indicates if the two endpoints coincide (= segment has zero length).
*/
@JvmDefault
val isDegenerate: Boolean get() = fuzzyEquals(first, second)

/**
* Indicates if the segment is aligned to the x-axis, this is true if [isDegenerate].
*/
@JvmDefault
val isHorizontal: Boolean get() = fuzzyEquals(first.y, second.y)

/**
* Indicates if the segment is aligned to the y-axis, this is true if [isDegenerate].
*/
@JvmDefault
val isVertical: Boolean get() = fuzzyEquals(first.x, second.x)

/**
* The medium point of the segment.
*/
@JvmDefault
val midPoint: P get() = first.newFrom((first.x + second.x) / 2, (first.y + second.y) / 2)

/**
* The vector representing the movement from [first] to [second].
*/
@JvmDefault
val toVector: P get() = second - first

/**
* @returns the [Line2D] passing through [first] and [second]. Throws an [UnsupportedOperationException] if the
* segment [isDegenerate].
*/
@JvmDefault
fun toLine(): Line2D<P> = when {
isDegenerate -> throw UnsupportedOperationException("degenerate segment can't be converted to line")
else -> SlopeInterceptLine2D.fromSegment(this)
Expand All @@ -76,15 +69,13 @@ interface Segment2D<P : Vector2D<P>> {
/**
* Checks if the segment contains a [point].
*/
@JvmDefault
fun contains(point: P): Boolean = isCollinearWith(point) &&
point.x fuzzyIn rangeFromUnordered(first.x, second.x) &&
point.y fuzzyIn rangeFromUnordered(first.y, second.y)

/**
* Finds the point of the segment which is closest to the provided [point].
*/
@JvmDefault
fun closestPointTo(point: P): P = when {
isDegenerate -> first
contains(point) -> point
Expand All @@ -108,13 +99,11 @@ interface Segment2D<P : Vector2D<P>> {
/**
* Computes the shortest distance between the segment and the given [point].
*/
@JvmDefault
fun distanceTo(point: P): Double = closestPointTo(point).distanceTo(point)

/**
* Computes the shortest distance between two segments (= the shortest distance between any two of their points).
*/
@JvmDefault
fun distanceTo(other: Segment2D<P>): Double = when {
intersect(other) !is Intersection2D.None -> 0.0
else -> listOf(
Expand All @@ -129,7 +118,6 @@ interface Segment2D<P : Vector2D<P>> {
* Checks if two segments are parallel. Throws an [UnsupportedOperationException] if any of the two segment
* [isDegenerate].
*/
@JvmDefault
fun isParallelTo(other: Segment2D<P>): Boolean = when {
isDegenerate || other.isDegenerate ->
throw UnsupportedOperationException("parallelism check is meaningless for degenerate segments")
Expand All @@ -139,13 +127,11 @@ interface Segment2D<P : Vector2D<P>> {
/**
* Checks if [first], [second] and [point] lie on a single line.
*/
@JvmDefault
fun isCollinearWith(point: P): Boolean = isDegenerate || toLine().contains(point)

/**
* Checks if two segments lie on a single line.
*/
@JvmDefault
fun isCollinearWith(other: Segment2D<P>): Boolean = when {
isDegenerate -> other.isCollinearWith(first)
else -> isCollinearWith(other.first) && isCollinearWith(other.second)
Expand All @@ -154,14 +140,12 @@ interface Segment2D<P : Vector2D<P>> {
/**
* Checks if two segments overlap (= are collinear and share one or more points).
*/
@JvmDefault
fun overlapsWith(other: Segment2D<P>): Boolean = isCollinearWith(other) &&
(contains(other.first) || contains(other.second) || other.contains(first) || other.contains(second))

/**
* Intersects two segments.
*/
@JvmDefault
fun intersect(other: Segment2D<P>): Intersection2D<P> = when {
isDegenerate ->
Intersection2D.None.takeUnless { other.contains(first) } ?: Intersection2D.SinglePoint(first)
Expand All @@ -184,7 +168,6 @@ interface Segment2D<P : Vector2D<P>> {
/**
* Intersects a segment and a circle.
*/
@JvmDefault
fun intersectCircle(center: P, radius: Double): Intersection2D<P> = when {
isDegenerate ->
Intersection2D.None
Expand All @@ -198,7 +181,6 @@ interface Segment2D<P : Vector2D<P>> {
* @returns a shrunk version of the segment, [factor] is a percentage in [0, 0.5] indicating how much
* the segment should be reduced on each size.
*/
@JvmDefault
fun shrunk(factor: Double): Segment2D<P> = when (factor) {
!in 0.0..0.5 -> throw IllegalArgumentException("$factor not in [0, 0.5]")
else -> copyWith(
Expand All @@ -211,7 +193,6 @@ interface Segment2D<P : Vector2D<P>> {
* Checks if this segment is inside a rectangular region described by an [origin], [width] and
* [height] (must be positive).
*/
@JvmDefault
fun isInRectangle(origin: Vector2D<*>, width: Double, height: Double) =
first.isInRectangle(origin, width, height) && second.isInRectangle(origin, width, height)

Expand All @@ -222,7 +203,6 @@ interface Segment2D<P : Vector2D<P>> {
* This can be useful e.g. to represent portions of axis-aligned segments without creating
* new ones.
*/
@JvmDefault
fun toRange(getXCoords: Boolean = this.isHorizontal): ClosedRange<Double> = when {
getXCoords -> rangeFromUnordered(first.x, second.x)
else -> rangeFromUnordered(first.y, second.y)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ interface NodeWithShape<T, S : Vector<S>, A : GeometricTransformation<S>> : Node
/**
* The shape of the node.
*/
@JvmDefault
val shape: GeometricShape<S, A>
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
*
*/
public final class TestContinuous2DEnvironment {
final class TestContinuous2DEnvironment {

private static final double [] ZEROS = {0, 0};
private static final double [] P2_3 = {2, 3};
Expand All @@ -51,7 +51,7 @@ public void setUp() {
* Test size initialization and change.
*/
@Test
public void testEnvironmentSize() {
void testEnvironmentSize() {
assertEquals(0, environment.getNodeCount());
assertArrayEquals(ZEROS, environment.getSize(), TOLERANCE);
environment.addNode(new IntNode(environment), new Euclidean2DPosition(P2_3));
Expand All @@ -66,7 +66,7 @@ public void testEnvironmentSize() {
* Test environment offset.
*/
@Test
public void testEnvironmentOffset() {
void testEnvironmentOffset() {
assertEquals(0, environment.getNodeCount());
assertTrue(Double.isNaN(environment.getOffset()[0]));
assertTrue(Double.isNaN(environment.getOffset()[1]));
Expand All @@ -82,7 +82,7 @@ public void testEnvironmentOffset() {
* Test failure on wrong queries.
*/
@Test
public void testNegativeRangeQuery() {
void testNegativeRangeQuery() {
assertEquals(0, environment.getNodeCount());
final Node<Integer> dummy = new IntNode(environment);
environment.addNode(dummy, new Euclidean2DPosition(ZEROS));
Expand All @@ -98,7 +98,7 @@ public void testNegativeRangeQuery() {
* Test failure on wrong queries.
*/
@Test
public void testZeroRangeQuery() {
void testZeroRangeQuery() {
assertEquals(0, environment.getNodeCount());
final Node<Integer> dummy = new IntNode(environment);
final Node<Integer> dummy2 = new IntNode(environment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/**
*/
public class TestContinuous2DObstacle {
class TestContinuous2DObstacle {

private static final RectObstacle2D<Euclidean2DPosition> R1021 = new RectObstacle2D<>(1, 0, 1, 1);
private static final RectObstacle2D<Euclidean2DPosition> R0527 = new RectObstacle2D<>(0, 5, 2, -2);
Expand All @@ -29,7 +29,7 @@ public class TestContinuous2DObstacle {
*
*/
@Test
public void test() {
void test() {
final var incarnation = SupportedIncarnations.<Integer, Euclidean2DPosition>get("protelis").orElseThrow();
final Continuous2DObstacles<Integer> env = new Continuous2DObstacles<>(incarnation);
env.setLinkingRule(new NoLinks<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private static <T> void registerTypeAdaptersFor(
classes.stream()
.filter(c -> Arrays.stream(c.getMethods())
.filter(m -> Modifier.isStatic(m.getModifiers()))
.anyMatch(m -> m.getName().equals(TARGET_METHOD_NAME)))
.anyMatch(m -> TARGET_METHOD_NAME.equals(m.getName())))
.forEach(c -> {
try {
builder.registerTypeAdapter(c, c.getMethod(TARGET_METHOD_NAME).invoke(null));
Expand Down
Loading

0 comments on commit aca7aef

Please sign in to comment.