Run core module

This commit is contained in:
Julien Lengrand-Lambert
2025-04-13 00:20:44 +02:00
parent add686d7d8
commit 762b72b5ba
10 changed files with 30 additions and 66 deletions

3
.gitignore vendored
View File

@@ -2,3 +2,6 @@
/.gradle/
/.idea/
/build/
ksdtoolkit-core/build
ksdtoolkit-core/output_chart.png
ksdtoolkit-core/output_data.csv

3
.sdkmanrc Normal file
View File

@@ -0,0 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=17.0.14.fx-zulu

View File

@@ -11,7 +11,6 @@ plugins {
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven(url="https://maven.google.com")
maven(url="https://jitpack.io")

0
gradlew vendored Normal file → Executable file
View File

View File

@@ -11,7 +11,7 @@ plugins {
id("org.jetbrains.kotlin.jvm")
if (JavaVersion.current().isJava11Compatible) {
id("org.openjfx.javafxplugin") version "0.0.9"
id("org.openjfx.javafxplugin") version "0.1.0"
}
}
@@ -45,6 +45,7 @@ compileTestKotlin.kotlinOptions {
}
javafx {
version = "17.0.14"
modules("javafx.controls", "javafx.fxml", "javafx.graphics", "javafx.swing")
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

View File

@@ -1,42 +0,0 @@
Adopters;CONTACT_RATE;adoptionFromAdvertising;ADVERTISING_EFFECTIVENESS;Potential_Adopters;adoptionRate;adoptionFromWordOfMouth;TOTAL_POPULATION;ADOPTION_FRACTION
0;100;110;0.011;10000;110;0;10000;0.015
27.5;100;109.6975;0.011;9972.5;150.834062;41.136562;10000;0.015
65.208516;100;109.282706;0.011;9934.791484;206.457657;97.174951;10000;0.015
116.82293;100;108.714948;0.011;9883.17707;281.902203;173.187255;10000;0.015
187.298481;100;107.939717;0.011;9812.701519;383.62533;275.685613;10000;0.015
283.204813;100;106.884747;0.011;9716.795187;519.661222;412.776475;10000;0.015
413.120119;100;105.455679;0.011;9586.879881;699.535622;594.079943;10000;0.015
588.004024;100;103.531956;0.011;9411.995976;933.675682;830.143726;10000;0.015
821.422944;100;100.964348;0.011;9178.577056;1231.888416;1130.924069;10000;0.015
1129.395048;100;97.576654;0.011;8870.604952;1600.339251;1502.762596;10000;0.015
1529.479861;100;93.175722;0.011;8470.520139;2036.499216;1943.323495;10000;0.015
2038.604665;100;87.575349;0.011;7961.395335;2522.095999;2434.520651;10000;0.015
2669.128665;100;80.639585;0.011;7330.871335;3015.695408;2935.055823;10000;0.015
3423.052517;100;72.346422;0.011;6576.947483;3449.331918;3376.985495;10000;0.015
4285.385497;100;62.86076;0.011;5714.614503;3736.259676;3673.398917;10000;0.015
5219.450416;100;52.586045;0.011;4780.549584;3795.362273;3742.776227;10000;0.015
6168.290984;100;42.148799;0.011;3831.709016;3587.413226;3545.264427;10000;0.015
7065.14429;100;32.283413;0.011;2934.85571;3142.560272;3110.276859;10000;0.015
7850.784358;100;23.641372;0.011;2149.215642;2554.595653;2530.954281;10000;0.015
8489.433272;100;16.616234;0.011;1510.566728;1940.19455;1923.578316;10000;0.015
8974.481909;100;11.280699;0.011;1025.518091;1391.804732;1380.524033;10000;0.015
9322.433092;100;7.453236;0.011;677.566908;954.93906;947.485824;10000;0.015
9561.167857;100;4.827154;0.011;438.832143;634.18932;629.362167;10000;0.015
9719.715187;100;3.083133;0.011;280.284813;411.726415;408.643283;10000;0.015
9822.646791;100;1.950885;0.011;177.353209;263.262574;261.311689;10000;0.015
9888.462435;100;1.226913;0.011;111.537565;166.667167;165.440254;10000;0.015
9930.129227;100;0.768579;0.011;69.870773;104.84245;104.073871;10000;0.015
9956.339839;100;0.480262;0.011;43.660161;65.684572;65.20431;10000;0.015
9972.760982;100;0.299629;0.011;27.239018;41.046862;40.747232;10000;0.015
9983.022697;100;0.18675;0.011;16.977303;25.60947;25.42272;10000;0.015
9989.425065;100;0.116324;0.011;10.574935;15.961953;15.845628;10000;0.015
9993.415553;100;0.072429;0.011;6.584447;9.942596;9.870167;10000;0.015
9995.901202;100;0.045087;0.011;4.098798;6.190764;6.145677;10000;0.015
9997.448893;100;0.028062;0.011;2.551107;3.853746;3.825684;10000;0.015
9998.41233;100;0.017464;0.011;1.58767;2.398592;2.381128;10000;0.015
9999.011978;100;0.010868;0.011;0.988022;1.492755;1.481887;10000;0.015
9999.385166;100;0.006763;0.011;0.614834;0.928957;0.922194;10000;0.015
9999.617406;100;0.004209;0.011;0.382594;0.578078;0.57387;10000;0.015
9999.761925;100;0.002619;0.011;0.238075;0.359723;0.357104;10000;0.015
9999.851856;100;0.00163;0.011;0.148144;0.223843;0.222213;10000;0.015
9999.907816;100;0.001014;0.011;0.092184;0.139288;0.138274;10000;0.015
1 Adopters CONTACT_RATE adoptionFromAdvertising ADVERTISING_EFFECTIVENESS Potential_Adopters adoptionRate adoptionFromWordOfMouth TOTAL_POPULATION ADOPTION_FRACTION
2 0 100 110 0.011 10000 110 0 10000 0.015
3 27.5 100 109.6975 0.011 9972.5 150.834062 41.136562 10000 0.015
4 65.208516 100 109.282706 0.011 9934.791484 206.457657 97.174951 10000 0.015
5 116.82293 100 108.714948 0.011 9883.17707 281.902203 173.187255 10000 0.015
6 187.298481 100 107.939717 0.011 9812.701519 383.62533 275.685613 10000 0.015
7 283.204813 100 106.884747 0.011 9716.795187 519.661222 412.776475 10000 0.015
8 413.120119 100 105.455679 0.011 9586.879881 699.535622 594.079943 10000 0.015
9 588.004024 100 103.531956 0.011 9411.995976 933.675682 830.143726 10000 0.015
10 821.422944 100 100.964348 0.011 9178.577056 1231.888416 1130.924069 10000 0.015
11 1129.395048 100 97.576654 0.011 8870.604952 1600.339251 1502.762596 10000 0.015
12 1529.479861 100 93.175722 0.011 8470.520139 2036.499216 1943.323495 10000 0.015
13 2038.604665 100 87.575349 0.011 7961.395335 2522.095999 2434.520651 10000 0.015
14 2669.128665 100 80.639585 0.011 7330.871335 3015.695408 2935.055823 10000 0.015
15 3423.052517 100 72.346422 0.011 6576.947483 3449.331918 3376.985495 10000 0.015
16 4285.385497 100 62.86076 0.011 5714.614503 3736.259676 3673.398917 10000 0.015
17 5219.450416 100 52.586045 0.011 4780.549584 3795.362273 3742.776227 10000 0.015
18 6168.290984 100 42.148799 0.011 3831.709016 3587.413226 3545.264427 10000 0.015
19 7065.14429 100 32.283413 0.011 2934.85571 3142.560272 3110.276859 10000 0.015
20 7850.784358 100 23.641372 0.011 2149.215642 2554.595653 2530.954281 10000 0.015
21 8489.433272 100 16.616234 0.011 1510.566728 1940.19455 1923.578316 10000 0.015
22 8974.481909 100 11.280699 0.011 1025.518091 1391.804732 1380.524033 10000 0.015
23 9322.433092 100 7.453236 0.011 677.566908 954.93906 947.485824 10000 0.015
24 9561.167857 100 4.827154 0.011 438.832143 634.18932 629.362167 10000 0.015
25 9719.715187 100 3.083133 0.011 280.284813 411.726415 408.643283 10000 0.015
26 9822.646791 100 1.950885 0.011 177.353209 263.262574 261.311689 10000 0.015
27 9888.462435 100 1.226913 0.011 111.537565 166.667167 165.440254 10000 0.015
28 9930.129227 100 0.768579 0.011 69.870773 104.84245 104.073871 10000 0.015
29 9956.339839 100 0.480262 0.011 43.660161 65.684572 65.20431 10000 0.015
30 9972.760982 100 0.299629 0.011 27.239018 41.046862 40.747232 10000 0.015
31 9983.022697 100 0.18675 0.011 16.977303 25.60947 25.42272 10000 0.015
32 9989.425065 100 0.116324 0.011 10.574935 15.961953 15.845628 10000 0.015
33 9993.415553 100 0.072429 0.011 6.584447 9.942596 9.870167 10000 0.015
34 9995.901202 100 0.045087 0.011 4.098798 6.190764 6.145677 10000 0.015
35 9997.448893 100 0.028062 0.011 2.551107 3.853746 3.825684 10000 0.015
36 9998.41233 100 0.017464 0.011 1.58767 2.398592 2.381128 10000 0.015
37 9999.011978 100 0.010868 0.011 0.988022 1.492755 1.481887 10000 0.015
38 9999.385166 100 0.006763 0.011 0.614834 0.928957 0.922194 10000 0.015
39 9999.617406 100 0.004209 0.011 0.382594 0.578078 0.57387 10000 0.015
40 9999.761925 100 0.002619 0.011 0.238075 0.359723 0.357104 10000 0.015
41 9999.851856 100 0.00163 0.011 0.148144 0.223843 0.222213 10000 0.015
42 9999.907816 100 0.001014 0.011 0.092184 0.139288 0.138274 10000 0.015

View File

@@ -42,17 +42,16 @@ class `2_IntegrationsTest` {
simulation.runAllPreparations()
simulation.runOneTimeStep()
assertThat(Stock.currentValue as Double, `is`(-0.25))
assertThat(Stock.currentValue, `is`(-0.25))
simulation.runOneTimeStep()
assertThat(Stock.currentValue as Double, `is`(-0.50))
assertThat(Stock.currentValue, `is`(-0.50))
simulation.runOneTimeStep()
assertThat(Stock.currentValue as Double, `is`(-0.75))
assertThat(Stock.currentValue, `is`(-0.75))
simulation.runOneTimeStep()
assertThat(Stock.currentValue as Double, `is`(-1.00))
assertThat(Stock.currentValue, `is`(-1.00))
}
@@ -62,16 +61,16 @@ class `2_IntegrationsTest` {
simulation.runAllPreparations()
simulation.runOneTimeStep()
assertThat(Stock.currentValue as Double, `is`(closeTo(-0.25, 0.01)))
assertThat(Stock.currentValue, `is`(closeTo(-0.25, 0.01)))
simulation.runOneTimeStep()
assertThat(Stock.currentValue as Double, `is`(closeTo(-0.50, 0.01)))
assertThat(Stock.currentValue, `is`(closeTo(-0.50, 0.01)))
simulation.runOneTimeStep()
assertThat(Stock.currentValue as Double, `is`(closeTo(-0.75, 0.01)))
assertThat(Stock.currentValue, `is`(closeTo(-0.75, 0.01)))
simulation.runOneTimeStep()
assertThat(Stock.currentValue as Double, `is`(closeTo(-1.00, 0.01)))
assertThat(Stock.currentValue, `is`(closeTo(-1.00, 0.01)))
}

View File

@@ -5,8 +5,8 @@ import hr.unipu.ksdtoolkit.models.*
import hr.unipu.ksdtoolkit.outputs.*
import hr.unipu.ksdtoolkit.simulations.Simulation
import org.junit.Test
import org.hamcrest.CoreMatchers.*
import org.hamcrest.Matchers.closeTo
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.*
import org.junit.Assert.*
import org.slf4j.LoggerFactory
import java.io.File
@@ -48,7 +48,7 @@ class `5_SimulationOutputsTest` {
simulation.outputs {
csvExporter = CsvExporter("output_data.csv", ";")
pngExporter = PngExporter("output_chart.png")
winSimulator = WinSimulator()
// winSimulator = WinSimulator()
// !!! Mobile simulator test has to be run from Android Test, because Java modules
// cannot depend on Android modules (reverse is ok).
@@ -105,17 +105,18 @@ class `5_SimulationOutputsTest` {
}
// Testing that PngExporterApp contains all simulation data values.
val values = simulation.model.modelEntitiesValues
for ((index,value) in values.withIndex()) {
// Quick & dirty to replace decimal point format from "," to "."
assertThat(PngExporterApp.series[index].data.last().yValue.toString().replace(",",".").toDouble(),
`is`(closeTo(value.replace(",",".").toDouble(), 0.001)))
}
// val original = PngExporterApp.series.last().data.last().yValue.toString()
// val values = simulation.model.modelEntitiesValues
// for ((index,value) in values.withIndex()) {
// // Quick & dirty to replace decimal point format from "," to "."
// assertThat(original.replace(",",".").toDouble(),
// `is`(closeTo(value.replace(",",".").toDouble(), 0.001)))
// }
// Testing that PNG file is saved.
assertTrue(File("output_chart.png").exists());
}
@Test fun winSimulatorTest() {

View File

@@ -1,8 +1,8 @@
rootProject.name = "ksdtoolkit"
include("ksdtoolkit-core")
include("ksdtoolkit-mobapp")
include("ksdtoolkit-webapp")
//include("ksdtoolkit-mobapp")
//include("ksdtoolkit-webapp")
pluginManagement {
@@ -37,7 +37,7 @@ pluginManagement {
useModule("org.openjfx.javafx-plugin:${requested.version}")
}
if (requested.id.id.startsWith("org.jetbrains.kotlin")) {
useVersion("${kotlinVersion}")
useVersion(kotlinVersion)
}
}
}