Skip to content

Commit

Permalink
mvn chain fixed with the port of processor 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hqnghi88 committed Dec 27, 2020
1 parent ab8f0de commit e717e34
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 154 deletions.
Expand Up @@ -71,6 +71,8 @@ public static void ERROR(final Exception e) {
public static String CORE_TESTS = "tests";
public static String CURRENT_PLUGIN_NAME = CORE_PLUGIN.getSymbolicName();
public static String ADDITIONS = "gaml.additions.GamlAdditions";
public static final String ADDITIONS_PACKAGE_BASE = "gaml.additions";
public static final String ADDITIONS_CLASS_NAME = "GamlAdditions";
public static String GRAMMAR_EXTENSION_DEPRECATED = "gaml.grammar.addition";
public static String GRAMMAR_EXTENSION = "gaml.extension";
public static String CREATE_EXTENSION = "gama.create";
Expand Down Expand Up @@ -135,7 +137,7 @@ public static void preBuildContributions() throws Exception {
} catch (final Exception e2) {
ERR(ERROR_MESSAGE);
ERR("Error in loading plugin " + CORE_PLUGIN.getSymbolicName() + ": " + e2.getMessage());
System.exit(0);
// System.exit(0);
return;
}
// We then build the other extensions to the language
Expand All @@ -146,7 +148,7 @@ public static void preBuildContributions() throws Exception {
} catch (final Exception e1) {
ERR(ERROR_MESSAGE);
ERR("Error in loading plugin " + CORE_PLUGIN.getSymbolicName() + ": " + e1.getMessage());
System.exit(0);
// System.exit(0);
return;
}
}
Expand All @@ -164,7 +166,7 @@ public static void preBuildContributions() throws Exception {
} catch (final Exception e1) {
ERR(ERROR_MESSAGE);
ERR("Error in loading CreateStatement delegate : " + e1.getMessage());
System.exit(0);
// System.exit(0);
return;

}
Expand All @@ -180,7 +182,7 @@ public static void preBuildContributions() throws Exception {

ERR(ERROR_MESSAGE);
ERR("Error in loading EventLayerStatement delegate : " + e1.getMessage());
System.exit(0);
// System.exit(0);
return;

}
Expand Down Expand Up @@ -219,10 +221,16 @@ public static void preBuildContributions() throws Exception {
@SuppressWarnings ("unchecked")
public static void preBuild(final Bundle bundle) throws Exception {
TIMER_WITH_EXCEPTIONS(PAD("> GAMA: " + bundle.getSymbolicName(), 45) + " loaded in ", () -> {
String shortcut = bundle.getSymbolicName();
shortcut = shortcut.substring(shortcut.lastIndexOf('.') + 1);
GamaClassLoader.getInstance().addBundle(bundle);
Class<IGamlAdditions> gamlAdditions = null;
try {
gamlAdditions = (Class<IGamlAdditions>) bundle.loadClass(ADDITIONS);
// gamlAdditions = (Class<IGamlAdditions>) bundle.loadClass(ADDITIONS);

gamlAdditions = (Class<IGamlAdditions>) bundle
.loadClass(ADDITIONS_PACKAGE_BASE + "." + shortcut + "." + ADDITIONS_CLASS_NAME);

} catch (final ClassNotFoundException e1) {
ERR(">> Impossible to load additions from " + bundle.toString() + " because of " + e1);
throw e1;
Expand Down
@@ -1,47 +1,47 @@
/**
* Name: multicriteria
* Author: Patrick Taillandier
* Description: Tests multi-criteria decision making operators
* Tags: multi_criteria, test
/**
* Name: multicriteria
* Author: Patrick Taillandier
* Description: Tests multi-criteria decision making operators
* Tags: multi_criteria, test
*/

model multicriteriaTest

experiment TopologyTests type: test {
list<list<float>> candidates <- [[1.0,1.0,1.0],[2.0,0.0,1.0],[0.0,0.0,0.0],[1.0,2.0,0.0],[0.0,0.5,3.0]];

test "weighted_means_DM"{
list criteria_WM <- [["name"::"C1", "weight" :: 1.0],["name"::"C2", "weight" :: 2.0],["name"::"C3", "weight" ::3.0]];
int choice <- weighted_means_DM(candidates,criteria_WM);
assert choice = 4;
}

test "electre_DM"{
list criteria_WM <- [["name"::"C1", "weight" :: 1.0, "p"::2.0, "q"::0.0, "v"::2.0, "maximize" :: true],["name"::"C2", "weight" :: 2.0, "p"::2.0, "q"::0.0, "v"::2.0, "maximize" :: true],["name"::"C3", "weight" ::3.0, "p"::2.0, "q"::0.0, "v"::2.0, "maximize" :: true]];
int choice <- electre_DM(candidates,criteria_WM, 0.7);
assert choice = 4;
}

test "promethee_DM"{
list criteria_Promethee <- [["name"::"C1", "weight" :: 1.0, "p"::2.0, "q"::0.0, "s"::3.0, "maximize" :: true],["name"::"C2", "weight" :: 2.0, "p"::2.0, "q"::0.0, "s"::3.0, "maximize" :: true],["name"::"C3", "weight" ::1.0, "p"::2.0, "q"::0.0, "s"::3.0, "maximize" :: true]];
int choice <- promethee_DM(candidates,criteria_Promethee);
assert choice = 3;
}

test "evidence_theory_DM"{
list criteria_ET <- [["name"::"C1", "s1"::0.0, "s2"::3.0, "v1p"::0.0, "v2p"::1.0, "v1c"::0.0, "v2c"::0.0,"maximize" :: true],["name"::"C2", "s1"::0.0, "s2"::3.0, "v1p"::0.0, "v2p"::2.0, "v1c"::0.0, "v2c"::0.0,"maximize" :: true],["name"::"C3", "s1"::0.0, "s2"::3.0, "v1p"::0.0, "v2p"::3.0, "v1c"::0.0, "v2c"::0.0,"maximize" :: true]];
int choice <- evidence_theory_DM(candidates,criteria_ET, true);
assert choice = 4;

choice <- evidence_theory_DM(candidates,criteria_ET, false);
assert choice = 0;
}

test "fuzzy_choquet_DM"{
map<list<string>,float> criteria_FC <- ([["C1"]::1.0, ["C2"]::2.0, ["C3"]:: 3.0,["C1","C2"]::1.0]);
int choice <- fuzzy_choquet_DM(candidates,["C1", "C2", "C3"],criteria_FC);
assert choice = 4;
}
}


model multicriteriaTest
experiment TopologyTests type: test {
list<list<float>> candidates <- [[1.0,1.0,1.0],[2.0,0.0,1.0],[0.0,0.0,0.0],[1.0,2.0,0.0],[0.0,0.5,3.0]];
test "weighted_means_DM"{
list criteria_WM <- [["name"::"C1", "weight" :: 1.0],["name"::"C2", "weight" :: 2.0],["name"::"C3", "weight" ::3.0]];
int choice <- weighted_means_DM(candidates,criteria_WM);
assert choice = 4;
}
test "electre_DM"{
list criteria_WM <- [["name"::"C1", "weight" :: 1.0, "p"::2.0, "q"::0.0, "v"::2.0, "maximize" :: true],["name"::"C2", "weight" :: 2.0, "p"::2.0, "q"::0.0, "v"::2.0, "maximize" :: true],["name"::"C3", "weight" ::3.0, "p"::2.0, "q"::0.0, "v"::2.0, "maximize" :: true]];
int choice <- electre_DM(candidates,criteria_WM, 0.7);
assert choice = 4;
}
test "promethee_DM"{
list criteria_Promethee <- [["name"::"C1", "weight" :: 1.0, "p"::2.0, "q"::0.0, "s"::3.0, "maximize" :: true],["name"::"C2", "weight" :: 2.0, "p"::2.0, "q"::0.0, "s"::3.0, "maximize" :: true],["name"::"C3", "weight" ::1.0, "p"::2.0, "q"::0.0, "s"::3.0, "maximize" :: true]];
int choice <- promethee_DM(candidates,criteria_Promethee);
assert choice = 3;
}
test "evidence_theory_DM"{
list criteria_ET <- [["name"::"C1", "s1"::0.0, "s2"::3.0, "v1p"::0.0, "v2p"::1.0, "v1c"::0.0, "v2c"::0.0,"maximize" :: true],["name"::"C2", "s1"::0.0, "s2"::3.0, "v1p"::0.0, "v2p"::2.0, "v1c"::0.0, "v2c"::0.0,"maximize" :: true],["name"::"C3", "s1"::0.0, "s2"::3.0, "v1p"::0.0, "v2p"::3.0, "v1c"::0.0, "v2c"::0.0,"maximize" :: true]];
int choice <- evidence_theory_DM(candidates,criteria_ET, true);
assert choice = 4;
choice <- evidence_theory_DM(candidates,criteria_ET, false);
assert choice = 0;
}
test "fuzzy_choquet_DM"{
map<list<string>,float> criteria_FC <- ([["C1"]::1.0, ["C2"]::2.0, ["C3"]:: 3.0,["C1","C2"]::1.0]);
int choice <- fuzzy_choquet_DM(candidates,["C1", "C2", "C3"],criteria_FC);
assert choice = 4;
}
}
90 changes: 45 additions & 45 deletions msi.gama.core/tests/Spatial Tests/models/Operators.experiment
@@ -1,47 +1,47 @@
/**
* Name: Spatial Operators
* Author: Patrick Taillandier
* Description: Tests various spatial operators
* Tags: spatial, operators, test
*/
/**
* Name: Spatial Operators
* Author: Patrick Taillandier
* Description: Tests various spatial operators
* Tags: spatial, operators, test
*/

experiment OperatorsTest type: test {
test "add_point" {
assert (geometry(nil) add_point {20,20}) = nil;
assert ({10,10} add_point point(nil)) = {10,10};
assert ({10,10} add_point {20,20}) = line([{10,10},{20,20}]);
assert (line([{10,10},{20,20}]) add_point {30,30}) = line([{10,10},{20,20},{30,30}]);
assert (line([{10,10},{20,20},{30,30}]) add_point {0,0}) = line([{0,0},{10,10},{20,20},{30,30}]);
assert (line([{10,10},{20,20},{30,30}]) add_point {25,22}) = line([{10,10},{20,20},{25,22},{30,30}]);
assert ((square(10) at_location {50,50}) add_point {50,35}) = polygon([{45,55}, {55,55}, {55,45}, {50,35},{45,45}]);
assert ((square(10) at_location {50,50}) add_point {50,50}) = polygon([{45,55}, {50,50}, {55,55},{55,45},{45,45}]);
}
test "inter" {
assert geometry(nil) inter {10,10} = nil;
assert {10,10} inter geometry(nil) = nil;
assert {10,10} inter {20,10} = nil;
assert {10,10} inter {10,10} = {10,10};
assert line([{10,10},{20,20}]) inter {10,10} = {10,10};
assert line([{10,10},{20,20}]) inter {20,10} = nil;
assert line([{10,10},{20,20}]) inter line([{5,5},{15,15}]) = line([{10,10},{15,15}]);
assert line([{10,5},{10,20}]) inter line([{5,15},{30,15}]) distance_to {10,15} < 0.1;
}
test "minus" {
assert geometry(nil) - {10,10} = nil;
assert geometry({10,10}) - geometry(nil) = {10,10};
assert (square(10) - {10,10}).area = 100.0;
assert length((line([{0,10},{20,10}]) - line([{10,0},{10,25}])).geometries) = 2 ;
assert ((square(10) at_location {0,0}) - (square(10) at_location {5,0})) = polygon ([{-5,5},{0,5},{0,-5},{-5,-5}]);
}
test "union" {
assert geometry(nil) union {10,10} = {10,10} ;
assert {10,10} union geometry(nil) = {10,10} ;
assert union([line([{0,10},{20,10}]) , line([{20,10},{30,10}])]).perimeter = 30.0 ;
}
test "masked_by" {
}
test "split_at" {
assert (line([{0,0},{100,0}]) split_at {50,0}) = [line([{0,0},{50,0}]), line([{50,0},{100,0}])];
}
}
experiment OperatorsTest type: test {
test "add_point" {
assert (geometry(nil) add_point {20,20}) = nil;
assert ({10,10} add_point point(nil)) = {10,10};
assert ({10,10} add_point {20,20}) = line([{10,10},{20,20}]);
assert (line([{10,10},{20,20}]) add_point {30,30}) = line([{10,10},{20,20},{30,30}]);
assert (line([{10,10},{20,20},{30,30}]) add_point {0,0}) = line([{0,0},{10,10},{20,20},{30,30}]);
assert (line([{10,10},{20,20},{30,30}]) add_point {25,22}) = line([{10,10},{20,20},{25,22},{30,30}]);
assert ((square(10) at_location {50,50}) add_point {50,35}) = polygon([{45,55}, {55,55}, {55,45}, {50,35},{45,45}]);
assert ((square(10) at_location {50,50}) add_point {50,50}) = polygon([{45,55}, {50,50}, {55,55},{55,45},{45,45}]);
}
test "inter" {
assert geometry(nil) inter {10,10} = nil;
assert {10,10} inter geometry(nil) = nil;
assert {10,10} inter {20,10} = nil;
assert {10,10} inter {10,10} = {10,10};
assert line([{10,10},{20,20}]) inter {10,10} = {10,10};
assert line([{10,10},{20,20}]) inter {20,10} = nil;
assert line([{10,10},{20,20}]) inter line([{5,5},{15,15}]) = line([{10,10},{15,15}]);
assert line([{10,5},{10,20}]) inter line([{5,15},{30,15}]) distance_to {10,15} < 0.1;
}
test "minus" {
assert geometry(nil) - {10,10} = nil;
assert geometry({10,10}) - geometry(nil) = {10,10};
assert (square(10) - {10,10}).area = 100.0;
assert length((line([{0,10},{20,10}]) - line([{10,0},{10,25}])).geometries) = 2 ;
assert ((square(10) at_location {0,0}) - (square(10) at_location {5,0})) = polygon ([{-5,5},{0,5},{0,-5},{-5,-5}]);
}
test "union" {
assert geometry(nil) union {10,10} = {10,10} ;
assert {10,10} union geometry(nil) = {10,10} ;
assert union([line([{0,10},{20,10}]) , line([{20,10},{30,10}])]).perimeter = 30.0 ;
}
test "masked_by" {
}
test "split_at" {
assert (line([{0,0},{100,0}]) split_at {50,0}) = [line([{0,0},{50,0}]), line([{50,0},{100,0}])];
}
}

16 changes: 4 additions & 12 deletions msi.gama.parent/pom.xml
Expand Up @@ -297,7 +297,7 @@
<org.eclipse.emf.common.version>2.11.0-v20150123-0347</org.eclipse.emf.common.version>
<org.eclipse.core.runtime.version>3.11.0.v20150405-1723</org.eclipse.core.runtime.version>
<com.ibm.icu.version>54.1.1</com.ibm.icu.version>
<javax.annotation.version>1.2</javax.annotation.version>
<javax.annotation.version>1.3.2</javax.annotation.version>
<javax.inject.version>1</javax.inject.version>
<xml-apis.version>1.3.04</xml-apis.version>
<antlr-runtime.version>3.2</antlr-runtime.version>
Expand Down Expand Up @@ -371,7 +371,7 @@
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>2.1.0</version>
<version>${tycho.version}</version>
<configuration>
<debug>false</debug>
<source>11</source>
Expand Down Expand Up @@ -587,14 +587,7 @@
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -623,7 +616,6 @@
</dependencies>
</plugin>

</plugins>
</pluginManagement>
</plugins>
</build>
</project>
38 changes: 20 additions & 18 deletions msi.gama.processor/src/msi/gama/precompiler/GamaProcessor.java
@@ -1,9 +1,7 @@
/*********************************************************************************************
*
* 'GamaProcessor.java, in plugin msi.gama.processor, is part of the source code of the GAMA modeling and simulation
* platform. (v. 1.8.1)
*
* (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners
* platform. (c) 2007-2016 UMI 209 UMMISCO IRD/UPMC & Partners
*
* Visit https://github.com/gama-platform/gama for license information and developers contact.
*
Expand All @@ -13,7 +11,6 @@

import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;
import java.util.Set;

import javax.annotation.processing.AbstractProcessor;
Expand All @@ -27,17 +24,24 @@
import javax.tools.Diagnostic.Kind;
import javax.tools.FileObject;

import msi.gama.precompiler.GamlAnnotations.doc;
import msi.gama.precompiler.GamlAnnotations.tests;
import msi.gama.precompiler.doc.DocProcessor;
import msi.gama.precompiler.tests.ExamplesToTests;
import msi.gama.precompiler.tests.TestProcessor;


@SuppressWarnings ({ "unchecked", "rawtypes" })
@SupportedAnnotationTypes ({ "*" })
@SupportedSourceVersion (SourceVersion.RELEASE_8)
@SupportedSourceVersion (SourceVersion.RELEASE_11)
public class GamaProcessor extends AbstractProcessor implements Constants {

// public final static String[] IMPORTS = new String[] { "java.util", "java.lang", "gama.util.map", "gama.util.list",
// "gama.util.file", "gama.util.matrix", "gama.util.path", "gama.util.graph", "gama.util.random",
// "gama.util.tree", "gama.util", "gama.metamodel.agent", "gama.metamodel.population", "gama.metamodel.shape",
// "gaml.types", "gaml.skills", "gama.common.interfaces.batch", "gama.common.interfaces.experiment",
// "gama.common.interfaces.gui", "gama.common.interfaces.outputs", "gama.common.interfaces",
// "gama.runtime.scope", "gaml.operators.noisegeneration", "gaml.operators", "gama.kernel.batch",
// "gama.kernel.experiment", "gama.kernel.root", "gama.kernel.model", "gama.kernel.simulation", "gaml.species",
// "gaml.expressions" };

public final static String[] IMPORTS = new String[] { "msi.gaml.extensions.multi_criteria",
"msi.gama.outputs.layers.charts", "msi.gama.outputs.layers", "msi.gama.outputs", "msi.gama.kernel.batch",
"msi.gama.kernel.root", "msi.gaml.architecture.weighted_tasks", "msi.gaml.architecture.user",
Expand All @@ -62,7 +66,6 @@ public class GamaProcessor extends AbstractProcessor implements Constants {
final StringBuilder sb = new StringBuilder();
writeImmutableHeader(sb);
JAVA_HEADER = sb.toString();
Arrays.sort(IMPORTS, (a, b) -> b.compareTo(a));
}

@Override
Expand Down Expand Up @@ -113,11 +116,8 @@ public void generateTests() {
}
}
// We pass the current document of the documentation processor to avoir re-reading it
final DocProcessor dp = (DocProcessor) processors.get(doc.class);
// context.emit(Kind.NOTE,
// " GAML Tests: lone tests serialization took " + (System.currentTimeMillis() - begin) + "ms",
// (Element) null);
ExamplesToTests.createTests(context, dp.document);
// final DocProcessor dp = (DocProcessor) processors.get(doc.class);
// ExamplesToTests.createTests(context, dp.document);
}

public void generateJavaSource(final FileObject file) {
Expand All @@ -134,7 +134,6 @@ public void generateJavaSource(final FileObject file) {
}

protected static void writeImmutableHeader(final StringBuilder sb) {
sb.append("package ").append(PACKAGE_NAME).append(';');
for (final String element : IMPORTS) {
sb.append(ln).append("import ").append(element).append(".*;");
}
Expand All @@ -144,8 +143,9 @@ protected static void writeImmutableHeader(final StringBuilder sb) {
sb.append(ln).append("import static msi.gaml.operators.Cast.*;");
sb.append(ln).append("import static msi.gaml.operators.Spatial.*;");
sb.append(ln).append("import static msi.gama.common.interfaces.IKeyword.*;");
sb.append(ln).append(" @SuppressWarnings({ \"rawtypes\", \"unchecked\", \"unused\" })");
sb.append(ln).append(ln).append("public class GamlAdditions extends AbstractGamlAdditions").append(" {");
sb.append(ln).append("@SuppressWarnings({ \"rawtypes\", \"unchecked\", \"unused\" })");
sb.append(ln).append(ln).append("public class GamlAdditions extends msi.gaml.compilation.AbstractGamlAdditions")
.append(" {");
sb.append(ln).append(tab);
sb.append("public void initialize() throws SecurityException, NoSuchMethodException {");
}
Expand All @@ -164,7 +164,9 @@ protected void writeMutableHeader(final StringBuilder sb) {
}

public StringBuilder writeJavaBody() {
final StringBuilder sb = new StringBuilder(JAVA_HEADER);
final StringBuilder sb = new StringBuilder();
sb.append("package ").append(PACKAGE_NAME).append(".").append(context.shortcut).append(';');
sb.append(ln).append(JAVA_HEADER);
writeMutableHeader(sb);
processors.values().forEach(p -> {
if (p.outputToJava() && p.hasElements()) {
Expand Down

0 comments on commit e717e34

Please sign in to comment.