Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 1 | /** |
| 2 | ******************************************************************************** |
| 3 | * Copyright (c) 2016-2019 Vector Informatik GmbH and others. |
| 4 | * |
| 5 | * This program and the accompanying materials are made |
| 6 | * available under the terms of the Eclipse Public License 2.0 |
| 7 | * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| 8 | * |
| 9 | * SPDX-License-Identifier: EPL-2.0 |
| 10 | * |
| 11 | * Contributors: |
| 12 | * Vector Informatik GmbH - initial API and implementation |
| 13 | * ******************************************************************************* |
| 14 | */ |
| 15 | |
Harald Mackamul | 9193257 | 2019-09-27 17:49:13 +0200 | [diff] [blame] | 16 | package org.eclipse.app4mc.amalthea.validations.tests |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 17 | |
| 18 | import java.util.List |
| 19 | import org.eclipse.app4mc.amalthea.model.Amalthea |
| 20 | import org.eclipse.app4mc.amalthea.model.AmaltheaFactory |
Raphael Weber | e403795 | 2019-07-26 10:43:09 +0200 | [diff] [blame] | 21 | import org.eclipse.app4mc.amalthea.model.ContinuousValueBetaDistribution |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 22 | import org.eclipse.app4mc.amalthea.model.ContinuousValueGaussDistribution |
| 23 | import org.eclipse.app4mc.amalthea.model.ContinuousValueStatistics |
| 24 | import org.eclipse.app4mc.amalthea.model.ContinuousValueUniformDistribution |
| 25 | import org.eclipse.app4mc.amalthea.model.ContinuousValueWeibullEstimatorsDistribution |
| 26 | import org.eclipse.app4mc.amalthea.model.DiscreteValueBetaDistribution |
| 27 | import org.eclipse.app4mc.amalthea.model.DiscreteValueGaussDistribution |
| 28 | import org.eclipse.app4mc.amalthea.model.DiscreteValueStatistics |
| 29 | import org.eclipse.app4mc.amalthea.model.DiscreteValueUniformDistribution |
| 30 | import org.eclipse.app4mc.amalthea.model.DiscreteValueWeibullEstimatorsDistribution |
| 31 | import org.eclipse.app4mc.amalthea.model.Time |
| 32 | import org.eclipse.app4mc.amalthea.model.TimeBetaDistribution |
| 33 | import org.eclipse.app4mc.amalthea.model.TimeGaussDistribution |
| 34 | import org.eclipse.app4mc.amalthea.model.TimeStatistics |
| 35 | import org.eclipse.app4mc.amalthea.model.TimeUniformDistribution |
| 36 | import org.eclipse.app4mc.amalthea.model.TimeWeibullEstimatorsDistribution |
| 37 | import org.eclipse.app4mc.amalthea.model.builder.AmaltheaBuilder |
| 38 | import org.eclipse.app4mc.amalthea.model.builder.SoftwareBuilder |
| 39 | import org.eclipse.app4mc.amalthea.model.builder.StimuliBuilder |
| 40 | import org.eclipse.app4mc.amalthea.validations.EMFProfile |
| 41 | import org.eclipse.app4mc.validation.core.Severity |
| 42 | import org.eclipse.app4mc.validation.core.ValidationDiagnostic |
| 43 | import org.eclipse.app4mc.validation.util.ValidationExecutor |
| 44 | import org.junit.Test |
| 45 | |
| 46 | import static org.eclipse.app4mc.amalthea.model.util.FactoryUtil.* |
| 47 | import static org.junit.Assert.assertFalse |
| 48 | import static org.junit.Assert.assertTrue |
| 49 | |
Harald Mackamul | 665c001 | 2019-07-23 16:10:07 +0200 | [diff] [blame] | 50 | class BasicDistributionTests { |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 51 | extension AmaltheaBuilder b1 = new AmaltheaBuilder |
| 52 | extension StimuliBuilder b2 = new StimuliBuilder |
| 53 | extension SoftwareBuilder b3 = new SoftwareBuilder |
Harald Mackamul | dd92f73 | 2019-07-19 17:21:30 +0200 | [diff] [blame] | 54 | |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 55 | val executor = new ValidationExecutor(EMFProfile) |
Raphael Weber | e403795 | 2019-07-26 10:43:09 +0200 | [diff] [blame] | 56 | |
| 57 | def ContinuousValueBetaDistribution createCVBetaD(double alpha, double beta, double lower, double upper) { |
| 58 | val ret = AmaltheaFactory.eINSTANCE.createContinuousValueBetaDistribution |
| 59 | ret.alpha = alpha |
| 60 | ret.beta = beta |
| 61 | ret.lowerBound = lower |
| 62 | ret.upperBound = upper |
| 63 | ret |
| 64 | } |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 65 | |
| 66 | def ContinuousValueGaussDistribution createCVGaussD(double mean, double sd, double lower, double upper) { |
| 67 | val ret = AmaltheaFactory.eINSTANCE.createContinuousValueGaussDistribution |
| 68 | ret.mean = mean |
| 69 | ret.sd = sd |
| 70 | ret.lowerBound = lower |
| 71 | ret.upperBound = upper |
| 72 | ret |
| 73 | } |
| 74 | |
| 75 | def ContinuousValueUniformDistribution createCVUniformD(double lower, double upper) { |
| 76 | val ret = AmaltheaFactory.eINSTANCE.createContinuousValueUniformDistribution |
| 77 | ret.lowerBound = lower |
| 78 | ret.upperBound = upper |
| 79 | ret |
| 80 | } |
| 81 | |
| 82 | def ContinuousValueStatistics createCVStatistics(double avg, double lower, double upper) { |
| 83 | val ret = AmaltheaFactory.eINSTANCE.createContinuousValueStatistics |
| 84 | ret.average = avg |
| 85 | ret.lowerBound = lower |
| 86 | ret.upperBound = upper |
| 87 | ret |
| 88 | } |
| 89 | |
| 90 | def ContinuousValueWeibullEstimatorsDistribution createCVWeibullED(double avg, double prp, double lower, |
| 91 | double upper) { |
| 92 | val ret = AmaltheaFactory.eINSTANCE.createContinuousValueWeibullEstimatorsDistribution |
| 93 | ret.average = avg |
| 94 | ret.PRemainPromille = prp |
| 95 | ret.lowerBound = lower |
| 96 | ret.upperBound = upper |
| 97 | ret |
| 98 | } |
| 99 | |
| 100 | def DiscreteValueBetaDistribution createDVBetaD(double alpha, double beta, long lower, long upper) { |
| 101 | val ret = AmaltheaFactory.eINSTANCE.createDiscreteValueBetaDistribution |
| 102 | ret.alpha = alpha |
| 103 | ret.beta = beta |
| 104 | ret.lowerBound = lower |
| 105 | ret.upperBound = upper |
| 106 | ret |
| 107 | } |
| 108 | |
| 109 | def DiscreteValueGaussDistribution createDVGaussD(double mean, double sd, long lower, long upper) { |
| 110 | val ret = AmaltheaFactory.eINSTANCE.createDiscreteValueGaussDistribution |
| 111 | ret.mean = mean |
| 112 | ret.sd = sd |
| 113 | ret.lowerBound = lower |
| 114 | ret.upperBound = upper |
| 115 | ret |
| 116 | } |
| 117 | |
| 118 | def DiscreteValueUniformDistribution createDVUniformD(long lower, long upper) { |
| 119 | val ret = AmaltheaFactory.eINSTANCE.createDiscreteValueUniformDistribution |
| 120 | ret.lowerBound = lower |
| 121 | ret.upperBound = upper |
| 122 | ret |
| 123 | } |
| 124 | |
| 125 | def DiscreteValueStatistics createDVStatistics(double avg, long lower, long upper) { |
| 126 | val ret = AmaltheaFactory.eINSTANCE.createDiscreteValueStatistics |
| 127 | ret.average = avg |
| 128 | ret.lowerBound = lower |
| 129 | ret.upperBound = upper |
| 130 | ret |
| 131 | } |
| 132 | |
| 133 | def DiscreteValueWeibullEstimatorsDistribution createDVWeibullED(double avg, double prp, long lower, long upper) { |
| 134 | val ret = AmaltheaFactory.eINSTANCE.createDiscreteValueWeibullEstimatorsDistribution |
| 135 | ret.average = avg |
| 136 | ret.PRemainPromille = prp |
| 137 | ret.lowerBound = lower |
| 138 | ret.upperBound = upper |
| 139 | ret |
| 140 | } |
| 141 | |
| 142 | def TimeBetaDistribution createTBetaD(double alpha, double beta, Time lower, Time upper) { |
| 143 | val ret = AmaltheaFactory.eINSTANCE.createTimeBetaDistribution |
| 144 | ret.alpha = alpha |
| 145 | ret.beta = beta |
| 146 | ret.lowerBound = lower |
| 147 | ret.upperBound = upper |
| 148 | ret |
| 149 | } |
| 150 | |
| 151 | def TimeGaussDistribution createTGaussD(Time mean, Time sd, Time lower, Time upper) { |
| 152 | val ret = AmaltheaFactory.eINSTANCE.createTimeGaussDistribution |
| 153 | ret.mean = mean |
| 154 | ret.sd = sd |
| 155 | ret.lowerBound = lower |
| 156 | ret.upperBound = upper |
| 157 | ret |
| 158 | } |
| 159 | |
| 160 | def TimeUniformDistribution createTUniformD(Time lower, Time upper) { |
| 161 | val ret = AmaltheaFactory.eINSTANCE.createTimeUniformDistribution |
| 162 | ret.lowerBound = lower |
| 163 | ret.upperBound = upper |
| 164 | ret |
| 165 | } |
| 166 | |
| 167 | def TimeStatistics createTStatistics(Time avg, Time lower, Time upper) { |
| 168 | val ret = AmaltheaFactory.eINSTANCE.createTimeStatistics |
| 169 | ret.average = avg |
| 170 | ret.lowerBound = lower |
| 171 | ret.upperBound = upper |
| 172 | ret |
| 173 | } |
| 174 | |
| 175 | def TimeWeibullEstimatorsDistribution createTWeibullED(Time avg, double prp, Time lower, Time upper) { |
| 176 | val ret = AmaltheaFactory.eINSTANCE.createTimeWeibullEstimatorsDistribution |
| 177 | ret.average = avg |
| 178 | ret.PRemainPromille = prp |
| 179 | ret.lowerBound = lower |
| 180 | ret.upperBound = upper |
| 181 | ret |
| 182 | } |
| 183 | |
| 184 | def boolean containsAll(String str, String... args) { |
| 185 | for (String arg : args) { |
| 186 | if(!str.contains(arg)) return false |
| 187 | } |
| 188 | return true |
| 189 | } |
| 190 | |
| 191 | def List<ValidationDiagnostic> validate(Amalthea model) { |
| 192 | executor.validate(model) |
| 193 | executor.results |
| 194 | } |
Raphael Weber | e403795 | 2019-07-26 10:43:09 +0200 | [diff] [blame] | 195 | |
| 196 | @Test |
| 197 | def void test_BasicContinuousValueBetaDistribution() { |
| 198 | val model = amalthea [ |
| 199 | stimuliModel[ |
| 200 | variableRateStimulus[ |
| 201 | name = "vrs_ok" |
| 202 | occurrencesPerStep = createCVBetaD(0.5d, 0.5d, 20d, 40d) |
| 203 | ] |
| 204 | variableRateStimulus[ |
| 205 | name = "vrs_alphaZero" |
| 206 | occurrencesPerStep = createCVBetaD(0d, 0.5d, 20d, 40d) |
| 207 | ] |
| 208 | variableRateStimulus[ |
| 209 | name = "vrs_betaZero" |
| 210 | occurrencesPerStep = createCVBetaD(0.5d, 0d, 20d, 40d) |
| 211 | ] |
| 212 | variableRateStimulus[ |
| 213 | name = "vrs_alphabetaZero" |
| 214 | occurrencesPerStep = createCVBetaD(0d, 0d, 20d, 40d) |
| 215 | ] |
| 216 | ] |
| 217 | ] |
| 218 | val validationResult = validate(model) |
| 219 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 220 | |
| 221 | assertTrue(result.contains("The feature 'alpha' of 'ContinuousValueBetaDistribution' contains a bad value ( in Variable Rate Stimulus \"vrs_alphaZero\" ) => The value '0.0' must be greater than '0.0'")) |
| 222 | assertTrue(result.contains("The feature 'alpha' of 'ContinuousValueBetaDistribution' contains a bad value ( in Variable Rate Stimulus \"vrs_alphabetaZero\" ) => The value '0.0' must be greater than '0.0'")) |
| 223 | assertFalse(result.contains("The feature 'alpha' of 'ContinuousValueBetaDistribution' contains a bad value ( in Variable Rate Stimulus \"vrs_ok\" ) => The value '0.5' must be greater than '0.0'")) |
| 224 | assertTrue(result.contains("The feature 'beta' of 'ContinuousValueBetaDistribution' contains a bad value ( in Variable Rate Stimulus \"vrs_betaZero\" ) => The value '0.0' must be greater than '0.0'")) |
| 225 | assertTrue(result.contains("The feature 'beta' of 'ContinuousValueBetaDistribution' contains a bad value ( in Variable Rate Stimulus \"vrs_alphabetaZero\" ) => The value '0.0' must be greater than '0.0'")) |
| 226 | assertFalse(result.contains("The feature 'beta' of 'ContinuousValueBetaDistribution' contains a bad value ( in Variable Rate Stimulus \"vrs_ok\" ) => The value '0.5' must be greater than '0.0'")) |
| 227 | } |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 228 | |
| 229 | @Test |
| 230 | def void test_BasicContinuousValueInterval() { |
| 231 | val model = amalthea [ |
| 232 | stimuliModel[ |
| 233 | variableRateStimulus[ |
| 234 | name = "vrs_ok" |
| 235 | occurrencesPerStep = createCVUniformD(20d, 40d) |
| 236 | ] |
| 237 | variableRateStimulus[ |
| 238 | name = "vrs_more" |
| 239 | occurrencesPerStep = createCVUniformD(20d, 10d) |
| 240 | ] |
| 241 | ] |
| 242 | ] |
| 243 | val validationResult = validate(model) |
| 244 | |
| 245 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 246 | assertTrue(result.contains("ContinuousValueUniformDistribution: lower bound > upper bound ( in Variable Rate Stimulus \"vrs_more\" )")) |
| 247 | assertFalse(result.contains("ContinuousValueUniformDistribution: lower bound > upper bound ( in Variable Rate Stimulus \"vrs_ok\" )")) |
| 248 | } |
| 249 | |
| 250 | @Test |
| 251 | def void test_BasicContinuousValueStatistics() { |
| 252 | val model = amalthea [ |
| 253 | stimuliModel[ |
| 254 | variableRateStimulus[ |
| 255 | name = "vrs_ok" |
| 256 | occurrencesPerStep = createCVStatistics(30d, 20d, 40d) |
| 257 | ] |
| 258 | variableRateStimulus[ |
| 259 | name = "vrs_avgLess" |
| 260 | occurrencesPerStep = createCVStatistics(10d, 20d, 40d) |
| 261 | ] |
| 262 | variableRateStimulus[ |
| 263 | name = "vrs_avgMore" |
| 264 | occurrencesPerStep = createCVStatistics(50d, 20d, 40d) |
| 265 | ] |
| 266 | ] |
| 267 | ] |
| 268 | val validationResult = validate(model) |
| 269 | |
| 270 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 271 | assertTrue(result.contains("ContinuousValueStatistics: lower bound > average ( in Variable Rate Stimulus \"vrs_avgLess\" )")) |
| 272 | assertTrue(result.contains("ContinuousValueStatistics: average > upper bound ( in Variable Rate Stimulus \"vrs_avgMore\" )")) |
| 273 | assertFalse(result.contains("ContinuousValueStatistics: lower bound > average ( in Variable Rate Stimulus \"vrs_ok\")")) |
| 274 | assertFalse(result.contains("ContinuousValueStatistics: average > upper bound ( in Variable Rate Stimulus \"vrs_ok\")")) |
| 275 | } |
| 276 | |
| 277 | @Test |
| 278 | def void test_BasicContinuousValueWeibullEstimatorsDistribution() { |
| 279 | val model = amalthea [ |
| 280 | stimuliModel[ |
| 281 | variableRateStimulus[ |
| 282 | name = "vrs_ok" |
| 283 | occurrencesPerStep = createCVWeibullED(30d, 1d, 20d, 40d) |
| 284 | ] |
| 285 | variableRateStimulus[ |
| 286 | name = "vrs_avgLess" |
| 287 | occurrencesPerStep = createCVWeibullED(10d, 1d, 20d, 40d) |
| 288 | ] |
| 289 | variableRateStimulus[ |
| 290 | name = "vrs_avgMore" |
| 291 | occurrencesPerStep = createCVWeibullED(50d, 1d, 20d, 40d) |
| 292 | ] |
| 293 | ] |
| 294 | ] |
| 295 | val validationResult = validate(model) |
| 296 | |
| 297 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 298 | assertTrue(result.contains("ContinuousValueWeibullEstimatorsDistribution: lower bound > average ( in Variable Rate Stimulus \"vrs_avgLess\" )")) |
| 299 | assertTrue(result.contains("ContinuousValueWeibullEstimatorsDistribution: average > upper bound ( in Variable Rate Stimulus \"vrs_avgMore\" )")) |
| 300 | assertFalse(result.contains("ContinuousValueWeibullEstimatorsDistribution: lower bound > average ( in Variable Rate Stimulus \"vrs_ok\" )")) |
| 301 | assertFalse(result.contains("ContinuousValueWeibullEstimatorsDistribution: average > upper bound ( in Variable Rate Stimulus \"vrs_ok\" )")) |
| 302 | } |
| 303 | |
| 304 | @Test |
| 305 | def void test_BasicTruncatedContinuousValueDistribution() { |
| 306 | val model = amalthea [ |
| 307 | stimuliModel[ |
| 308 | variableRateStimulus[ |
| 309 | name = "vrs_ok" |
| 310 | occurrencesPerStep = createCVGaussD(30d, 10d, 20d, 40d) |
| 311 | ] |
| 312 | variableRateStimulus[ |
| 313 | name = "vrs_more" |
| 314 | occurrencesPerStep = createCVGaussD(30d, 10d, 20d, 10d) |
| 315 | ] |
| 316 | ] |
| 317 | ] |
| 318 | val validationResult = validate(model) |
| 319 | |
| 320 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 321 | assertTrue(result.contains("ContinuousValueGaussDistribution: lower bound > upper bound ( in Variable Rate Stimulus \"vrs_more\" )")) |
| 322 | assertFalse(result.contains("ContinuousValueGaussDistribution: lower bound > upper bound ( in Variable Rate Stimulus \"vrs_ok\" )")) |
| 323 | } |
| 324 | |
| 325 | @Test |
| 326 | def void test_BasicDiscreteValueBetaDistribution() { |
| 327 | val model = amalthea [ |
| 328 | softwareModel [ |
| 329 | runnable [ |
| 330 | name = "r_ok" |
Harald Mackamul | 1c230e2 | 2019-12-23 22:01:52 +0100 | [diff] [blame^] | 331 | activityGraph [ticks [^default = createDVBetaD(0.5d, 0.5d, 20l, 40l)]] |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 332 | ] |
| 333 | runnable [ |
| 334 | name = "r_alphaZero" |
Harald Mackamul | 1c230e2 | 2019-12-23 22:01:52 +0100 | [diff] [blame^] | 335 | activityGraph [ticks [^default = createDVBetaD(0d, 0.5d, 20l, 40l)]] |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 336 | ] |
| 337 | runnable [ |
| 338 | name = "r_betaZero" |
Harald Mackamul | 1c230e2 | 2019-12-23 22:01:52 +0100 | [diff] [blame^] | 339 | activityGraph [ticks [^default = createDVBetaD(0.5d, 0d, 20l, 40l)]] |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 340 | ] |
| 341 | runnable [ |
| 342 | name = "r_alphabetaZero" |
Harald Mackamul | 1c230e2 | 2019-12-23 22:01:52 +0100 | [diff] [blame^] | 343 | activityGraph [ticks [^default = createDVBetaD(0d, 0d, 20l, 40l)]] |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 344 | ] |
| 345 | ] |
| 346 | ] |
| 347 | val validationResult = validate(model) |
| 348 | |
| 349 | val alpha = "feature 'alpha' of 'DiscreteValueBetaDistribution'" |
| 350 | val beta = "feature 'beta' of 'DiscreteValueBetaDistribution'" |
| 351 | val message = "value '0.0' must be greater than '0.0'" |
| 352 | |
| 353 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 354 | assertTrue(result.exists[it.containsAll(alpha, message, "in Runnable \"r_alphaZero\"")]) |
| 355 | assertTrue(result.exists[it.containsAll(alpha, message, "in Runnable \"r_alphabetaZero\"")]) |
| 356 | assertFalse(result.exists[it.containsAll(alpha, message, "in Runnable \"r_ok\"")]) |
| 357 | assertTrue(result.exists[it.containsAll(beta, message, "in Runnable \"r_betaZero\"")]) |
| 358 | assertTrue(result.exists[it.containsAll(beta, message, "in Runnable \"r_alphabetaZero\"")]) |
| 359 | assertFalse(result.exists[it.containsAll(beta, message, "in Runnable \"r_ok\"")]) |
| 360 | } |
| 361 | |
| 362 | @Test |
| 363 | def void test_BasicDiscreteValueInterval() { |
| 364 | val model = amalthea [ |
| 365 | softwareModel[ |
| 366 | runnable[ |
| 367 | name = "r_ok" |
Harald Mackamul | 1c230e2 | 2019-12-23 22:01:52 +0100 | [diff] [blame^] | 368 | activityGraph [ticks [^default = createDVUniformD(20, 40)]] |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 369 | ] |
| 370 | runnable[ |
| 371 | name = "r_more" |
Harald Mackamul | 1c230e2 | 2019-12-23 22:01:52 +0100 | [diff] [blame^] | 372 | activityGraph [ticks [^default = createDVUniformD(20, 10)]] |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 373 | ] |
| 374 | ] |
| 375 | ] |
| 376 | val validationResult = validate(model) |
| 377 | |
| 378 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 379 | assertTrue(result.contains("DiscreteValueUniformDistribution: lower bound > upper bound ( in Runnable \"r_more\" )")) |
| 380 | assertFalse(result.contains("DiscreteValueUniformDistribution: lower bound > upper bound ( in Runnable \"r_ok\" )")) |
| 381 | } |
| 382 | |
| 383 | @Test |
| 384 | def void test_BasicDiscreteValueStatistics() { |
| 385 | val model = amalthea [ |
| 386 | softwareModel[ |
| 387 | runnable[ |
| 388 | name = "r_ok" |
Harald Mackamul | 1c230e2 | 2019-12-23 22:01:52 +0100 | [diff] [blame^] | 389 | activityGraph [ticks [^default = createDVStatistics(30d, 20, 40)]] |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 390 | ] |
| 391 | runnable[ |
| 392 | name = "r_avgLess" |
Harald Mackamul | 1c230e2 | 2019-12-23 22:01:52 +0100 | [diff] [blame^] | 393 | activityGraph [ticks [^default = createDVStatistics(10d, 20, 40)]] |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 394 | ] |
| 395 | runnable[ |
| 396 | name = "r_avgMore" |
Harald Mackamul | 1c230e2 | 2019-12-23 22:01:52 +0100 | [diff] [blame^] | 397 | activityGraph [ticks [^default = createDVStatistics(50d, 20, 40)]] |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 398 | ] |
| 399 | ] |
| 400 | ] |
| 401 | val validationResult = validate(model) |
| 402 | |
| 403 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 404 | assertTrue(result.contains("DiscreteValueStatistics: lower bound > average ( in Runnable \"r_avgLess\" )")) |
| 405 | assertTrue(result.contains("DiscreteValueStatistics: average > upper bound ( in Runnable \"r_avgMore\" )")) |
| 406 | assertFalse(result.contains("DiscreteValueStatistics: lower bound > average ( in Runnable \"r_ok\" )")) |
| 407 | assertFalse(result.contains("DiscreteValueStatistics: average > upper bound ( in Runnable \"r_ok\" )")) |
| 408 | } |
| 409 | |
| 410 | @Test |
| 411 | def void test_BasicDiscreteValueWeibullEstimatorsDistribution() { |
| 412 | val model = amalthea [ |
| 413 | softwareModel[ |
| 414 | runnable[ |
| 415 | name = "r_ok" |
Harald Mackamul | 1c230e2 | 2019-12-23 22:01:52 +0100 | [diff] [blame^] | 416 | activityGraph [ticks [^default = createDVWeibullED(30d, 1d, 20, 40)]] |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 417 | ] |
| 418 | runnable[ |
| 419 | name = "r_avgLess" |
Harald Mackamul | 1c230e2 | 2019-12-23 22:01:52 +0100 | [diff] [blame^] | 420 | activityGraph [ticks [^default = createDVWeibullED(10d, 1d, 20, 40)]] |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 421 | ] |
| 422 | runnable[ |
| 423 | name = "r_avgMore" |
Harald Mackamul | 1c230e2 | 2019-12-23 22:01:52 +0100 | [diff] [blame^] | 424 | activityGraph [ticks [^default = createDVWeibullED(50d, 1d, 20, 40)]] |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 425 | ] |
| 426 | ] |
| 427 | ] |
| 428 | val validationResult = validate(model) |
| 429 | |
| 430 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 431 | assertTrue(result.contains("DiscreteValueWeibullEstimatorsDistribution: lower bound > average ( in Runnable \"r_avgLess\" )")) |
| 432 | assertTrue(result.contains("DiscreteValueWeibullEstimatorsDistribution: average > upper bound ( in Runnable \"r_avgMore\" )")) |
| 433 | assertFalse(result.contains("DiscreteValueWeibullEstimatorsDistribution: lower bound > average ( in Runnable \"r_ok\" )")) |
| 434 | assertFalse(result.contains("DiscreteValueWeibullEstimatorsDistribution: average > upper bound ( in Runnable \"r_ok\" )")) |
| 435 | } |
| 436 | |
| 437 | @Test |
| 438 | def void test_BasicTruncatedDiscreteValueDistribution() { |
| 439 | val model = amalthea [ |
| 440 | softwareModel[ |
| 441 | runnable[ |
| 442 | name = "r_ok" |
Harald Mackamul | 1c230e2 | 2019-12-23 22:01:52 +0100 | [diff] [blame^] | 443 | activityGraph [ticks [^default = createDVGaussD(30d, 10d, 20, 40)]] |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 444 | ] |
| 445 | runnable[ |
| 446 | name = "r_more" |
Harald Mackamul | 1c230e2 | 2019-12-23 22:01:52 +0100 | [diff] [blame^] | 447 | activityGraph [ticks [^default = createDVGaussD(30d, 10d, 20, 10)]] |
Harald Mackamul | fb6b09f | 2019-07-19 14:04:22 +0200 | [diff] [blame] | 448 | ] |
| 449 | ] |
| 450 | ] |
| 451 | val validationResult = validate(model) |
| 452 | |
| 453 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 454 | assertTrue(result.contains("DiscreteValueGaussDistribution: lower bound > upper bound ( in Runnable \"r_more\" )")) |
| 455 | assertFalse(result.contains("DiscreteValueGaussDistribution: lower bound > upper bound ( in Runnable \"r_ok\" )")) |
| 456 | } |
| 457 | |
| 458 | @Test |
| 459 | def void test_BasicTimeBetaDistribution() { |
| 460 | val model = amalthea [ |
| 461 | stimuliModel[ |
| 462 | periodicStimulus[ |
| 463 | name = "ps_ok" |
| 464 | jitter = createTBetaD(0.5d, 0.5d, createTime(), createTime()) |
| 465 | ] |
| 466 | periodicStimulus[ |
| 467 | name = "ps_alphaZero" |
| 468 | jitter = createTBetaD(0d, 0.5d, createTime(), createTime()) |
| 469 | ] |
| 470 | periodicStimulus[ |
| 471 | name = "ps_betaZero" |
| 472 | jitter = createTBetaD(0.5d, 0d, createTime(), createTime()) |
| 473 | ] |
| 474 | periodicStimulus[ |
| 475 | name = "ps_alphabetaZero" |
| 476 | jitter = createTBetaD(0d, 0d, createTime(), createTime()) |
| 477 | ] |
| 478 | ] |
| 479 | ] |
| 480 | val validationResult = validate(model) |
| 481 | |
| 482 | val alpha = "feature 'alpha' of 'TimeBetaDistribution'" |
| 483 | val beta = "feature 'beta' of 'TimeBetaDistribution'" |
| 484 | val message = "value '0.0' must be greater than '0.0'" |
| 485 | |
| 486 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 487 | assertTrue(result.exists[it.containsAll(alpha, message, "in Periodic Stimulus \"ps_alphaZero\"")]) |
| 488 | assertTrue(result.exists[it.containsAll(alpha, message, "in Periodic Stimulus \"ps_alphabetaZero\"")]) |
| 489 | assertFalse(result.exists[it.containsAll(alpha, message, "in Periodic Stimulus \"ps_ok\"")]) |
| 490 | assertTrue(result.exists[it.containsAll(beta, message, "in Periodic Stimulus \"ps_betaZero\"")]) |
| 491 | assertTrue(result.exists[it.containsAll(beta, message, "in Periodic Stimulus \"ps_alphabetaZero\"")]) |
| 492 | assertFalse(result.exists[it.containsAll(beta, message, "in Periodic Stimulus \"ps_ok\"")]) |
| 493 | } |
| 494 | |
| 495 | @Test |
| 496 | def void test_BasicTimeInterval() { |
| 497 | val model = amalthea [ |
| 498 | stimuliModel[ |
| 499 | periodicStimulus[ |
| 500 | name = "ps_ok" |
| 501 | jitter = createTUniformD(createTime(20, "ms"), createTime(40, "ms")) |
| 502 | ] |
| 503 | periodicStimulus[ |
| 504 | name = "ps_more" |
| 505 | jitter = createTUniformD(createTime(20, "ms"), createTime(10, "ms")) |
| 506 | ] |
| 507 | ] |
| 508 | ] |
| 509 | val validationResult = validate(model) |
| 510 | |
| 511 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 512 | assertTrue(result.contains("TimeUniformDistribution: lower bound > upper bound ( in Periodic Stimulus \"ps_more\" )")) |
| 513 | assertFalse(result.contains("TimeUniformDistribution: lower bound > upper bound ( in Periodic Stimulus \"ps_ok\" )")) |
| 514 | } |
| 515 | |
| 516 | @Test |
| 517 | def void test_BasicTimeStatistics() { |
| 518 | val model = amalthea [ |
| 519 | stimuliModel[ |
| 520 | periodicStimulus[ |
| 521 | name = "ps_ok" |
| 522 | jitter = createTStatistics(createTime(30, "ms"), createTime(20, "ms"), createTime(40, "ms")) |
| 523 | ] |
| 524 | periodicStimulus[ |
| 525 | name = "ps_avgLess" |
| 526 | jitter = createTStatistics(createTime(10, "ms"), createTime(20, "ms"), createTime(40, "ms")) |
| 527 | ] |
| 528 | periodicStimulus[ |
| 529 | name = "ps_avgMore" |
| 530 | jitter = createTStatistics(createTime(50, "ms"), createTime(20, "ms"), createTime(40, "ms")) |
| 531 | ] |
| 532 | ] |
| 533 | ] |
| 534 | val validationResult = validate(model) |
| 535 | |
| 536 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 537 | assertTrue(result.contains("TimeStatistics: lower bound > average ( in Periodic Stimulus \"ps_avgLess\" )")) |
| 538 | assertTrue(result.contains("TimeStatistics: average > upper bound ( in Periodic Stimulus \"ps_avgMore\" )")) |
| 539 | assertFalse(result.contains("TimeStatistics: lower bound > average ( in Periodic Stimulus \"ps_ok\" )")) |
| 540 | assertFalse(result.contains("TimeStatistics: average > upper bound ( in Periodic Stimulus \"ps_ok\" )")) |
| 541 | } |
| 542 | |
| 543 | @Test |
| 544 | def void test_BasicTimeWeibullEstimatorsDistribution() { |
| 545 | val model = amalthea [ |
| 546 | stimuliModel[ |
| 547 | periodicStimulus[ |
| 548 | name = "ps_ok" |
| 549 | jitter = createTWeibullED(createTime(30, "ms"), 1d, createTime(20, "ms"), createTime(40, "ms")) |
| 550 | ] |
| 551 | periodicStimulus[ |
| 552 | name = "ps_avgLess" |
| 553 | jitter = createTWeibullED(createTime(10, "ms"), 1d, createTime(20, "ms"), createTime(40, "ms")) |
| 554 | ] |
| 555 | periodicStimulus[ |
| 556 | name = "ps_avgMore" |
| 557 | jitter = createTWeibullED(createTime(50, "ms"), 1d, createTime(20, "ms"), createTime(40, "ms")) |
| 558 | ] |
| 559 | ] |
| 560 | ] |
| 561 | val validationResult = validate(model) |
| 562 | |
| 563 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 564 | assertTrue(result.contains("TimeWeibullEstimatorsDistribution: lower bound > average ( in Periodic Stimulus \"ps_avgLess\" )")) |
| 565 | assertTrue(result.contains("TimeWeibullEstimatorsDistribution: average > upper bound ( in Periodic Stimulus \"ps_avgMore\" )")) |
| 566 | assertFalse(result.contains("TimeWeibullEstimatorsDistribution: lower bound > average ( in Periodic Stimulus \"ps_ok\" )")) |
| 567 | assertFalse(result.contains("TimeWeibullEstimatorsDistribution: average > upper bound ( in Periodic Stimulus \"ps_ok\" )")) |
| 568 | } |
| 569 | |
| 570 | @Test |
| 571 | def void test_BasicTruncatedTimeDistribution() { |
| 572 | val model = amalthea [ |
| 573 | stimuliModel[ |
| 574 | periodicStimulus[ |
| 575 | name = "ps_ok" |
| 576 | jitter = createTGaussD(createTime(30, "ms"), createTime(10, "ms"), createTime(20, "ms"), |
| 577 | createTime(40, "ms")) |
| 578 | ] |
| 579 | periodicStimulus[ |
| 580 | name = "ps_more" |
| 581 | jitter = createTGaussD(createTime(30, "ms"), createTime(10, "ms"), createTime(20, "ms"), |
| 582 | createTime(10, "ms")) |
| 583 | ] |
| 584 | ] |
| 585 | ] |
| 586 | val validationResult = validate(model) |
| 587 | |
| 588 | val result = validationResult.filter[it.severityLevel == Severity.ERROR].map[it.message].toList |
| 589 | assertTrue(result.contains("TimeGaussDistribution: lower bound > upper bound ( in Periodic Stimulus \"ps_more\" )")) |
| 590 | assertFalse(result.contains("TimeGaussDistribution: lower bound > upper bound ( in Periodic Stimulus \"ps_ok\" )")) |
| 591 | } |
| 592 | } |