Skip to content

Commit

Permalink
Merge branch 'release-8.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
DanySK committed Jul 3, 2019
2 parents 14b955b + c14053c commit 32dd408
Show file tree
Hide file tree
Showing 21 changed files with 318 additions and 263 deletions.
2 changes: 1 addition & 1 deletion alchemist/alchemist-incarnation-protelis/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {
* Check with:
* ./gradlew dependencyInsight --dependency org.eclipse.emf:org.eclipse.emf.ecore --configuration runtimeClasspath
*/
implementation("org.eclipse.emf:org.eclipse.emf.ecore:2.12.0") {
implementation(Libs.org_eclipse_emf_ecore) {
isForce = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ variables:
bp:
formula: 0.5
retain: &retain
formula: 1 / $minfreq
formula: 1 / minfreq
fc:
formula: "$time ? ($small ? $sp : $bp) : 0"
formula: "time ? (small ? sp : bp) : 0"
minfreq: &minfreq
formula: "$freq * (1 - $fc)"
formula: "freq * (1 - fc)"
maxfreq: &maxfreq
formula: "$freq * (1 + $fc)"
formula: "freq * (1 + fc)"
speed: &speed
language: scala
formula: "if ($time) 0 else 1"
formula: "if (time.asInstanceOf[Boolean]) 0 else 1"
seed: &seed
min: 0
max: 199
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@
*/
package it.unibo.alchemist.model;

import java.io.Serializable;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.math3.random.RandomGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import it.unibo.alchemist.expressions.implementations.Type;
import it.unibo.alchemist.expressions.interfaces.IExpression;
Expand All @@ -42,6 +31,16 @@
import it.unibo.alchemist.model.interfaces.Position;
import it.unibo.alchemist.model.interfaces.Reaction;
import it.unibo.alchemist.model.interfaces.TimeDistribution;
import org.apache.commons.math3.random.RandomGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
*
Expand Down Expand Up @@ -134,13 +133,8 @@ private double sapereProperty(final ILsaNode node, final ILsaMolecule molecule,

@Override
public ILsaMolecule createMolecule(final String s) {
try {
final String param = s.startsWith("{") && s.endsWith("}") ? s.substring(1, s.length() - 1) : s;
return new LsaMolecule(param);
} catch (RuntimeException e) {
L.info("Unable to load the requested molecule:\n" + e);
}
return null;
final String param = s.trim().startsWith("{") && s.endsWith("}") ? s.substring(1, s.length() - 1) : s;
return new LsaMolecule(param);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package it.unibo.alchemist.model.influencesphere.sensory

import it.unibo.alchemist.model.interfaces.Position2D
import it.unibo.alchemist.model.influencesphere.shapes.GeometricShape2D
import it.unibo.alchemist.model.interfaces.Position2D
import java.awt.geom.Arc2D

// To be better implemented following https://legends2k.github.io/2d-fov/design.html
// To be better implemented following http://archive.fo/Cwy38
class FieldOfView2D<P : Position2D<P>>(
originX: Double,
originY: Double,
Expand Down
6 changes: 5 additions & 1 deletion alchemist/alchemist-loading/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ dependencies {
implementation(project(":alchemist-time"))
implementation(project(":alchemist-maps"))
implementation(Libs.commons_lang3)
implementation(Libs.groovy)
implementation(Libs.guava)
implementation(Libs.jirf)
implementation(Libs.snakeyaml)

runtimeOnly(Libs.groovy_jsr223)
runtimeOnly(Libs.kotlin_scripting_jsr223_embeddable)
// runtimeOnly(Libs.kotlin_script_runtime)
// runtimeOnly("org.jetbrains.kotlin:kotlin-script-util:1.3.40")

testImplementation(project(":alchemist-engine"))
testImplementation(project(":alchemist-maps"))
testImplementation(Libs.gson)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package it.unibo.alchemist.loader;

import it.unibo.alchemist.loader.export.Extractor;
import it.unibo.alchemist.loader.variables.DependentVariable;
import it.unibo.alchemist.loader.variables.Variable;
import it.unibo.alchemist.model.interfaces.Environment;
import it.unibo.alchemist.model.interfaces.Position;
Expand All @@ -31,6 +32,15 @@ public interface Loader extends Serializable {
*/
<T, P extends Position<P>> Environment<T, P> getDefault();

/**
* Allows to access the currently defined dependent variable (those variables whose value can be determined given a
* valid set of values for the free variables).
*
* @return a {@link Map} between variable names and their actual
* representation
*/
Map<String, DependentVariable<?>> getDependentVariables();

/**
* @return a {@link Map} between variable names and their actual
* representation
Expand All @@ -51,6 +61,14 @@ public interface Loader extends Serializable {
*/
<T, P extends Position<P>> Environment<T, P> getWith(Map<String, ?> values);

/**
* Allows to access the currently defined constants, namely variables defined in the simulation file whose value is
* constant and does not depend on the value of any free variable (directly or indirectly).
*
* @return a {@link Map} between variable names and their computed value
*/
Map<String, Object> getConstants();

/**
* @return The data extractors
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@
import it.unibo.alchemist.loader.shapes.Shape;
import it.unibo.alchemist.loader.variables.ArbitraryVariable;
import it.unibo.alchemist.loader.variables.DependentVariable;
import it.unibo.alchemist.loader.variables.GroovyVariable;
import it.unibo.alchemist.loader.variables.JavascriptVariable;
import it.unibo.alchemist.loader.variables.JSR223Variable;
import it.unibo.alchemist.loader.variables.LinearVariable;
import it.unibo.alchemist.loader.variables.NumericConstant;
import it.unibo.alchemist.loader.variables.ScalaVariable;
import it.unibo.alchemist.loader.variables.ScriptVariable;
import it.unibo.alchemist.loader.variables.Variable;
import it.unibo.alchemist.model.implementations.environments.Continuous2DEnvironment;
import it.unibo.alchemist.model.implementations.linkingrules.NoLinks;
Expand Down Expand Up @@ -149,12 +146,6 @@ public final class YamlLoader implements Loader {
private static final String VALUE_FILTER = SYNTAX.getString("value-filter");
private static final String VALUES = SYNTAX.getString("values");
private static final String VARIABLES = SYNTAX.getString("variables");
@SuppressWarnings("deprecation")
private static final Map<String, Function<String, ScriptVariable<?>>> SUPPORTED_LANGUAGES = ImmutableMap.of(
"groovy", GroovyVariable::new,
"javascript", JavascriptVariable::new,
"scala", ScalaVariable::new
);
private static final Map<Class<?>, Map<String, Class<?>>> DEFAULT_MANDATORY_PARAMETERS = ImmutableMap.<Class<?>, Map<String, Class<?>>>builder()
.put(Layer.class, ImmutableMap.of(TYPE, CharSequence.class, MOLECULE, CharSequence.class))
.build();
Expand All @@ -172,8 +163,7 @@ public final class YamlLoader implements Loader {
final Object formula = m.get(FORMULA);
return formula instanceof Number
? new NumericConstant((Number) formula)
: SUPPORTED_LANGUAGES.get(m.getOrDefault(LANGUAGE, "groovy").toString().toLowerCase(Locale.ENGLISH))
.apply(formula.toString());
: new JSR223Variable<>(m.getOrDefault(LANGUAGE, "groovy").toString().toLowerCase(Locale.ENGLISH), formula.toString());
}));
private static final BuilderConfiguration<FilteringPolicy> FILTERING_CONFIG = new BuilderConfiguration<>(
ImmutableMap.of(NAME, CharSequence.class), ImmutableMap.of(), makeBaseFactory(), m -> CommonFilters.fromString(m.get(NAME).toString()));
Expand Down Expand Up @@ -393,6 +383,11 @@ public YamlLoader(final String yaml) {
this(new StringReader(yaml));
}

@Override
public ImmutableMap<String, Object> getConstants() {
return constants;
}

@Override
public List<Extractor> getDataExtractors() {
return Collections.unmodifiableList(extractors);
Expand All @@ -404,8 +399,13 @@ public <T, P extends Position<P>> Environment<T, P> getDefault() {
}

@Override
public Map<String, Variable<?>> getVariables() {
return Collections.unmodifiableMap(variables);
public ImmutableMap<String, DependentVariable<?>> getDependentVariables() {
return depVariables;
}

@Override
public ImmutableMap<String, Variable<?>> getVariables() {
return variables;
}

@Override
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 32dd408

Please sign in to comment.