From 4d914f3a77f64dc326933921b03735d4aabd9214 Mon Sep 17 00:00:00 2001 From: ArenBabikian Date: Wed, 13 May 2020 00:34:43 -0400 Subject: Adjust measurement setup. TaxationWithRoot support. JAR creation --- .../src/queries/case_study_A_withRoot.vql | 338 +++++++++++++++++++++ .../src/run/GenerateFromConfig.xtend | 125 ++++---- .../src/run/RunGeneratorConfig.xtend | 123 ++++++++ 3 files changed, 523 insertions(+), 63 deletions(-) create mode 100644 Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A_withRoot.vql create mode 100644 Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/RunGeneratorConfig.xtend (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.run/src') diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A_withRoot.vql b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A_withRoot.vql new file mode 100644 index 00000000..cd876200 --- /dev/null +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A_withRoot.vql @@ -0,0 +1,338 @@ +package queries + +import "http:///TaxCardWithRoot.ecore" + +//AttributeRemoved -> DF + +//inv1-External_Allowance.amount is a derived feature (TODOcheck) +//inv2-Tax_Card.income.taxPayer.taxesDue is a derived feature (TODOcheck) + +//inv3-multiplicity adjusted +@Constraint(message = "inv03", severity = "error", key = {dep}) +pattern inv03(dep : Dependent) { + find x_inv03_eligAll(dep); + neg find x_inv03_hasAll(dep); +} or { + Dependent.birth_year(dep, by); + check(2018-by > 21); + Dependent.continued_studies(dep, false); + Dependent.allowances(dep, _); +} +pattern x_inv03_eligAll(dep : Dependent) { + Dependent.birth_year(dep, by); + check(2018-by <= 21); +} or { + Dependent.continued_studies(dep, true); +} +pattern x_inv03_hasAll(dep : Dependent) { + Dependent.allowances(dep, _); +} + +//inv5 - oclIsTypeOf - handled here +@Constraint(message = "inv05", severity = "error", key = {inc}) +pattern inv05(inc : Income) { + //income_type: None + neg find x_inv08_noType(inc); + Income.details.worked_days(inc, wd); + check(wd != 0); +} or { + //income_type: Not Employment_Income + Income.income_type(inc, type); + neg find x_inv08_notEI(type); + Income.details.worked_days(inc, wd); + check(wd != 0); +} or { + //income_type: Employment Income + Income.income_type(inc, type); + Employment_Income(type); + find x_inv05_inRange(inc); +} +pattern x_inv05_inRange(inc : Income) { + Income.details.worked_days(inc, wd); + check(wd < 1); +} or { + Income.details.worked_days(inc, wd); + check(wd > 25); +} + +//inv6-Does not make sens, but directly from OCL +//first part of or from definition of getAge() +@Constraint(message = "inv06", severity = "error", key = {tp}) +pattern inv06(tp : Tax_Payer) { + Tax_Payer.dependents(tp, _); + Tax_Payer.birth_year(tp, TPBy); + check(2018 - TPBy > 2018-16); +} or { + Tax_Payer.birth_year(tp, TPBy); + Tax_Payer.dependents(tp, dep); + Dependent.birth_year(dep, DepBy); + check(2018-DepBy <= 2018-TPBy-16); +} + +//inv7-OrderedSet +@Constraint(message = "inv07", severity = "error", key = {inc}) +pattern inv07(inc : Income) { + Income.details.distance(inc, d1); + Income.details.distance(inc, d2); + check(d1 != d2);//compare values +} + +//user_complete_details-AttributeRemoved + +//inv8 - oclIsTypeOf - handled here +@Constraint(message = "inv08", severity = "error", key = {inc}) +pattern inv08(inc : Income) { + //income_type: None + neg find x_inv08_noType(inc); + Income.details.distance(inc, dist); + check(dist != 0); +} or { + //income_type: Not Employment_Income + Income.income_type(inc, type); + neg find x_inv08_notEI(type); + Income.details.distance(inc, dist); + check(dist != 0); +} or { + //income_type: Employment Income + Income.income_type(inc, type); + Employment_Income(type); + find x_inv08_inRange(inc); +} +pattern x_inv08_notEI(type : Employment_Income) { + Employment_Income(type); +} +pattern x_inv08_noType(inc : Income) { + Income.income_type(inc, _); +} +pattern x_inv08_inRange(inc : Income) { + Income.details.distance(inc, dist); + check(dist < 0); +} or { + Income.details.distance(inc, dist); + check(dist > 100); +} +//inv9-DerivedFeature + +//inv10-Ordered Sets +@Constraint(message = "inv10", severity = "error", key = {inc}) +pattern inv10(inc : Income) { + Income.details.amount(inc, a1); + Income.details.amount(inc, a2); + check(a1 != a2);//compare values +} + +//inv11-attributes-handled by multiplicity +@Constraint(message = "inv11", severity = "error", key = {exp}) +pattern inv11(exp : Expense) { + find x_inv11_incOver100(exp); + find x_inv11_incNotOver100(exp); +} +pattern x_inv11_incOver100(exp : Expense) { + Expense.income.income_amount(exp, incVal); + check(incVal / 2 > 50); + +} or { + Expense.declared_amount(exp, decl); + check(decl != 50); +} +pattern x_inv11_incNotOver100(exp : Expense) { + Expense.income.income_amount(exp, incVal); + check(incVal / 2 <= 50); +} or { + Expense.declared_amount(exp, decl); + check(decl < 50); +} or { + Expense.income.income_amount(exp, incVal); + Expense.declared_amount(exp, decl); + check(decl > incVal/2); +} + +//inv12 +//exists - handled logically +@Constraint(message = "inv12", severity = "error", key = {tp}) +pattern inv12(tp : Tax_Payer) { + Tax_Payer.addresses(tp, hab_add); + Habitual_Address(hab_add); + neg find x_inv12_notZZ(hab_add); + Tax_Payer.incomes(tp, inc); + Local_Income(inc); + neg find x_inv12_notNonRes(tp); +} +pattern x_inv12_notNonRes(tp : Non_Resident_Tax_Payer) { + Non_Resident_Tax_Payer(tp); +} +pattern x_inv12_notZZ(hab_add : Habitual_Address) { + Address.country(hab_add, ::ZZ); +} + +//inv13 - Added new containment rel Phys_Pers->Address +//exists - handled logically +@Constraint(message = "inv13", severity = "error", key = {tp}) +pattern inv13(tp : Tax_Payer) { + Tax_Payer.addresses(tp, hab_add); + Habitual_Address(hab_add); + Address.country(hab_add, ::ZZ); + neg find x_inv13(tp); +} +pattern x_inv13(tp : Resident_Tax_Payer) { + Resident_Tax_Payer(tp); +} + +//inv14-MultiplicityChanged + +//inv15-Ordered Sets in assignment if block +//ERROR if no household object +@Constraint(message = "inv15", severity = "error", key = {ea}) +pattern inv15(ea : External_Allowance) { + neg find x_inv15(ea); +} +pattern x_inv15(ea : External_Allowance) { + External_Allowance.person(ea, child); + Household.children(h, child);//only one due to multiplicity + Household.parents.individual_A(h, iA); + Tax_Payer(iA); + External_Allowance.reciver(ea, iA); +} or { + External_Allowance.person(ea, child); + Household.children(h, child);//only one due to multiplicity + Household.parents.individual_B(h, iB); + Tax_Payer(iB); + External_Allowance.reciver(ea, iB); +} + +//inv16-Tax_Card.tax_card_type is a derived feature + +//inv17-attribute-handled by multiplicity +@Constraint(message = "inv17", severity = "error", key = {lur}) +pattern inv17(lur : Legal_Union_Record) { + Legal_Union_Record.start_year(lur, sy); + check(sy < 1950); +} or { + Legal_Union_Record.start_year(lur, sy); + check(sy > 2018); +} + +//inv18-MultiplicityChecked +//inv19-MultiplicityChecked + +//inv20-Useless constraint since both edges are containment (TODOCheck) +//OclIsUndefined-Handled by multiplicity +@Constraint(message = "inv20", severity = "error", key = {lur}) +pattern inv20(lur : Legal_Union_Record) { + Legal_Union_Record.individual_A(lur, iA); + Legal_Union_Record.individual_B(lur, iB); + iA == iB; +} +//inv21-MultiplicityChecked +//inv22-MultiplicityChecked +//inv23-MultiplicityChecked +//inv24-MultiplicityChecked +//inv25-MultiplicityChecked +//inv26-MultiplicityChanged +//inv27-dupOfInv24 +//inv28-dubOfInv23 +//inv29-MultiplicityChanged +//inv30-AttributeRemoved +//inv31-AttributeRemoved +//inv32-AttributeRemoved + +//inv33-attribute-handled by multiplicity +@Constraint(message = "inv33", severity = "error", key = {p}) +pattern inv33(p : Physical_Person) { + Physical_Person.birth_year(p, by); + check(2018-by < 0); +} or { + Physical_Person.birth_year(p, by); + check(2018-by > 100); +} + +//inv34-attribute-handled by multiplicity +@Constraint(message = "inv34", severity = "error", key = {p}) +pattern inv34(p : Physical_Person) { + Physical_Person.birth_month(p, birthMonth); + check(birthMonth < 1); +} or { + Physical_Person.birth_month(p, birthMonth); + check(birthMonth > 12); +} + +//inv35-attribute-handled by multiplicity +@Constraint(message = "inv35", severity = "error", key = {p}) +pattern inv35(p : Physical_Person) { + Physical_Person.birth_day(p, birthDay); + check(birthDay < 1); +} or { + Physical_Person.birth_day(p, birthDay); + check(birthDay > 28); +} + +//inv36-AttributeRemoved +//inv37-AttributeRemoved +//inv38-AttributeRemoved +//inv39-AttributeRemoved +//inv40-AttributeRemoved +//inv41-AttributeRemoved +//inv42-AttributeRemoved +//inv43-AttributeRemoved +//inv44-AttributeRemoved +//inv45-AttributeRemoved +//inv46-AttributeRemoved + +//inv47-attributes-handled by multiplicity +@Constraint(message = "inv47", severity = "error", key = {lur}) +pattern inv47(lur : Legal_Union_Record) { + Legal_Union_Record.end_year(lur, endY); + Legal_Union_Record.start_year(lur, startY); + neg find x_inv47(lur); + check(startY >= endY); +} or { + Legal_Union_Record.end_year(lur, endY); + Legal_Union_Record.start_year(lur, startY); + check(endY!= -1); + check(startY >= endY); +} +pattern x_inv47(lur : Legal_Union_Record) { + Legal_Union_Record.separation_cause(lur, ::NONE); +} + +//inv48-attributes-handled by multiplicity +@Constraint(message = "inv48", severity = "error", key = {p}) +pattern inv48(p : Physical_Person) { + Physical_Person.disability_percentage(p, disPer); + check(disPer > 1.0); +} or { + Physical_Person.disability_percentage(p, disPer); + check(disPer < 0.0); +} or { + Physical_Person.disability_type(p, ::NONE); + Physical_Person.disability_percentage(p, disPer); + check(disPer != 0.0); +} or { + neg find x_inv48(p); + Physical_Person.disability_percentage(p, disPer); + check(disPer == 0.0); +} +pattern x_inv48(p : Physical_Person) { + Physical_Person.disability_type(p, ::NONE); +} + +//inv49-OclKindOf-handled by multiplicity +@Constraint(message = "inv49", severity = "error", key = {lur}) +pattern inv49_A(lur : Legal_Union_Record) { + Legal_Union_Record.individual_A(lur, i); + Legal_Union_Record.individual_B(lur, i); +} +//inv49-OclKindOf-handled by multiplicity +@Constraint(message = "inv49", severity = "error", key = {lur}) +pattern inv49_B(lur : Legal_Union_Record) { + Legal_Union_Record.individual_A(lur, i); + Dependent(i); +} or { + Legal_Union_Record.individual_B(lur, i); + Dependent(i); +} + +//inv50-MultiplicityChecked +//inv51-MultiplicityChecked +//inv52-MultiplicityChecked +//inv53-MultiplicityChecked \ No newline at end of file diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend index 5cda1e16..ccb0d7b3 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend @@ -48,15 +48,15 @@ import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl import org.eclipse.viatra.query.runtime.api.IQueryGroup class GenerateFromConfig { - static val SIZE_LB = 20 - static val SIZE_UB = 20 + static val SIZE_LB = 200 + static val SIZE_UB = 200 static val SIZE_MUL = 1 static val SIZE_INC = 5 - static var REPS = 5 - static val RUNTIME = 2100 + static var REPS = 3 + static val RUNTIME = 600 - static val DOMAIN = "Satellite" // "FamilyTree", "Taxation", "Satellite" + static val DOMAIN = "FamilyTree" // "FamilyTree", "Taxation", "Satellite" static val QUERIES = true static val INITIAL = true static val INDIV_WRT = false @@ -69,7 +69,7 @@ class GenerateFromConfig { // Workspace setup val Date date = new Date(System.currentTimeMillis) val SimpleDateFormat format = new SimpleDateFormat("dd-HHmm"); - val formattedDate = DOMAIN + "-" + format.format(date) + val formattedDate = DOMAIN + "/" + format.format(date) val workspace = new FileSystemWorkspace('''output/''' + formattedDate + '''/''', "") workspace.initAndClear @@ -106,60 +106,59 @@ class GenerateFromConfig { } println() - println("DOMAIN: " + DOMAIN + ", SIZE=" + size) + println("<>") - for (var i = 0; i < REPS; i++) { - - print("<> : ") - - - // ///////////////////////////////////////////////////// - // Define Config File - val knownIntegers = new ArrayList - knownIntegers.addAll(0, 10, 20, 30, 40, 50) - - val knownReals = new ArrayList - knownReals.addAll(new BigDecimal("0.0")) - - val knownStrings = new ArrayList - knownStrings.addAll("r0", "r1", "r2", "r3", "r4", "r5", "r6") - - val outputPath = "output/" + formattedDate + "/size" + size + "/run" + i + "/models/" - val debugPath = "output/" + formattedDate + "/size" + size + "/run" + i + "/debug/" - val logPath = debugPath + "log.txt" - val statsPath = debugPath + "statistics.csv" - - // Adjust configuration - val genTask = config.commands.get(0) as GenerationTask - if(!QUERIES) genTask.patterns = null - if(!INITIAL) genTask.partialModel = null - - val scopeSpec = genTask.scope as ScopeSpecification - val objScope = scopeSpec.scopes.get(0) as ObjectTypeScope - val interval = objScope.number as IntervallNumber - interval.min = size - interval.maxUnlimited = true - - val configScope = genTask.config as ConfigSpecification - val runtimeEntry = configScope.entries.get(0) as RuntimeEntry - runtimeEntry.millisecLimit = RUNTIME - - // TODO add known ints, reals, string... - val debug = genTask.debugFolder as FileSpecification - debug.path = debugPath - val output = genTask.tagetFolder as FileSpecification - output.path = outputPath - val log = genTask.targetLogFile as FileSpecification - log.path = logPath - val stats = genTask.targetStatisticsFile as FileSpecification - stats.path = statsPath +// for (var i = 0; i < REPS; i++) { +// +// print("<> : ") + // ///////////////////////////////////////////////////// + // Define Config File +// val knownIntegers = new ArrayList +// knownIntegers.addAll(0, 10, 20, 30, 40, 50) +// +// val knownReals = new ArrayList +// knownReals.addAll(new BigDecimal("0.0")) +// +// val knownStrings = new ArrayList +// knownStrings.addAll("r0", "r1", "r2", "r3", "r4", "r5", "r6") + + val outputPath = "output/" + formattedDate + "/size" + size + "/models/" + val debugPath = "output/" + formattedDate + "/size" + size + "/debug/" + val logPath = debugPath + "log.txt" + val statsPath = debugPath + "statistics.csv" + + // Adjust configuration + val genTask = config.commands.get(0) as GenerationTask + if(!QUERIES) genTask.patterns = null + if(!INITIAL) genTask.partialModel = null + genTask.runs = REPS + + val scopeSpec = genTask.scope as ScopeSpecification + val objScope = scopeSpec.scopes.get(0) as ObjectTypeScope + val interval = objScope.number as IntervallNumber + interval.min = size + interval.maxUnlimited = true + + val configScope = genTask.config as ConfigSpecification + val runtimeEntry = configScope.entries.get(0) as RuntimeEntry + runtimeEntry.millisecLimit = RUNTIME + + // TODO add known ints, reals, string... + val debug = genTask.debugFolder as FileSpecification + debug.path = debugPath + val output = genTask.tagetFolder as FileSpecification + output.path = outputPath + val log = genTask.targetLogFile as FileSpecification + log.path = logPath + val stats = genTask.targetStatisticsFile as FileSpecification + stats.path = statsPath // workspace.writeModel(config, '''x.xmi''') - val startTime = System.currentTimeMillis - executor.executeScript(config, new NullProgressMonitor) - val measuredTime = System.currentTimeMillis - startTime + val startTime = System.currentTimeMillis + executor.executeScript(config, new NullProgressMonitor) + val measuredTime = System.currentTimeMillis - startTime - println("<" + measuredTime / 1000.0 + "s >>\n") + println("<" + measuredTime / 1000.0 + "s >>\n") // val toAddtoCSV = DOMAIN + "," + QUERIES + "," + size + "," + // (solution.class == ModelResultImpl).toString + "," + RUNTIME + "," + measuredTime / 1000.0 + "," + @@ -169,13 +168,13 @@ class GenerateFromConfig { // if(GLOBAL_WRT) global_writer.append(toAddtoCSV) // if(INDIV_WRT) indiv_writer.append(toAddtoCSV) // solution.writeStats(totalTime, solverConfig) - // Run Garbage Collector - val Runtime r = Runtime.getRuntime(); - r.gc(); - r.gc(); - r.gc(); - Thread.sleep(3000) - } + // Run Garbage Collector +// val Runtime r = Runtime.getRuntime(); +// r.gc(); +// r.gc(); +// r.gc(); +// Thread.sleep(3000) +// } if(INDIV_WRT) indiv_writer.close } if(GLOBAL_WRT) global_writer.close diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/RunGeneratorConfig.xtend b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/RunGeneratorConfig.xtend new file mode 100644 index 00000000..c2ad68f5 --- /dev/null +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/RunGeneratorConfig.xtend @@ -0,0 +1,123 @@ +package run + +import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigSpecification +import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigurationScript +import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.FileSpecification +import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.GenerationTask +import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.IntervallNumber +import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ObjectTypeScope +import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.RuntimeEntry +import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ScopeSpecification +import hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor +import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor +import java.text.SimpleDateFormat +import java.util.Date +import org.apache.commons.cli.CommandLine +import org.apache.commons.cli.CommandLineParser +import org.apache.commons.cli.HelpFormatter +import org.apache.commons.cli.Option +import org.apache.commons.cli.Options +import org.apache.commons.cli.ParseException +import org.eclipse.core.runtime.NullProgressMonitor +import org.apache.commons.cli.BasicParser + +class RunGeneratorConfig { + static var SIZE = 20 + + static var RUNS = 10 + static var RUNTIME = 600 + + static var DOMAIN = "FamilyTree" // "FamilyTree", "Taxation", "Satellite" + static val QUERIES = true + static val INITIAL = true + + def static void main(String[] args) { + + val options = new Options() + + val s = new Option("s", "size", true, "generated model Lower bound") + options.addOption(s) + + val n = new Option("n", "numRuns", true, "number of runs") + options.addOption(n) + + val rt = new Option("rt", "runtime", true, "runtime limit") + options.addOption(rt) + + val d = new Option("d", "domain", true, "domain") + options.addOption(d) + + val CommandLineParser parser = new BasicParser + val formatter = new HelpFormatter() + var CommandLine cmd + + try { + cmd = parser.parse(options, args) + } catch (ParseException e) { + System.out.println(e.getMessage()) + formatter.printHelp("utility-name", options) + System.exit(1) + } + + val sIn = cmd.getOptionValue("size") + if(sIn !== null) SIZE = Integer.parseInt(sIn) + val nIn = cmd.getOptionValue("numRuns") + if(nIn !== null) RUNS = Integer.parseInt(nIn) + val rtIn = cmd.getOptionValue("runtime") + if(rtIn !== null) RUNTIME = Integer.parseInt(rtIn) + val dIn = cmd.getOptionValue("domain") + if(dIn !== null) DOMAIN = dIn + + // Workspace setup + val Date date = new Date(System.currentTimeMillis) + val SimpleDateFormat format = new SimpleDateFormat("dd-HHmm") + val formattedDate = format.format(date) + + val executor = new ScriptExecutor + val path = "config//generic" + DOMAIN + ".vsconfig" + var ConfigurationScript config = StandaloneScriptExecutor.loadScript(path) + + // ///////////////////////// + // BEGIN RUN + println("<>\n") + + val outputPath = "measurements/" + "models/"+ DOMAIN + "/size" + SIZE + "_" + formattedDate + val debugPath = "measurements/" + "debug/" + DOMAIN + "/size" + SIZE + "_" + formattedDate + val logPath = debugPath + "/log.txt" + val statsPath = "measurements/" + "stats/" + DOMAIN + "/size" + SIZE + "x" + RUNS + "stats_" + formattedDate + ".csv" + + // Basic Adjustments + val genTask = config.commands.get(1) as GenerationTask + if(!QUERIES) genTask.patterns = null + if(!INITIAL) genTask.partialModel = null + genTask.runs = RUNS + + // Size + val scopeSpec = genTask.scope as ScopeSpecification + val objScope = scopeSpec.scopes.get(0) as ObjectTypeScope + val interval = objScope.number as IntervallNumber + interval.min = SIZE + interval.maxUnlimited = true + + // Runtime + val configScope = genTask.config as ConfigSpecification + val runtimeEntry = configScope.entries.get(0) as RuntimeEntry + runtimeEntry.millisecLimit = RUNTIME + + // Output locations + val debug = genTask.debugFolder as FileSpecification + debug.path = debugPath + val output = genTask.tagetFolder as FileSpecification + output.path = outputPath + val log = genTask.targetLogFile as FileSpecification + log.path = logPath + val stats = genTask.targetStatisticsFile as FileSpecification + stats.path = statsPath + + // Run Generator + executor.executeScript(config, new NullProgressMonitor) + + println() + } + +} -- cgit v1.2.3-54-g00ecf