From 48871e1be75169e4e3768a7c0c47791e02c7e634 Mon Sep 17 00:00:00 2001 From: ArenBabikian Date: Sun, 17 May 2020 01:58:13 -0400 Subject: update measurements setup. make archives. --- .../src/queries/NewOCLFileX.ocl | 45 --- .../src/queries/case_study_A.vql | 356 -------------------- .../src/queries/case_study_short.vql | 51 --- .../src/run/ConfigGenerator.java | 13 - .../src/run/GenerateFromConfig.xtend | 196 ----------- .../src/run/GeneratePledgeModels.xtend | 360 --------------------- .../src/run/RunGeneratorConfig.xtend | 61 ++-- 7 files changed, 33 insertions(+), 1049 deletions(-) delete mode 100644 Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/NewOCLFileX.ocl delete mode 100644 Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A.vql delete mode 100644 Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_short.vql delete mode 100644 Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/ConfigGenerator.java delete mode 100644 Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend delete mode 100644 Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GeneratePledgeModels.xtend (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.run/src') diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/NewOCLFileX.ocl b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/NewOCLFileX.ocl deleted file mode 100644 index 66ae728e..00000000 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/NewOCLFileX.ocl +++ /dev/null @@ -1,45 +0,0 @@ -import 'file:/Users/Aren Babikian/git/VIATRA-Attributes/case.study.a.model/model/Taxation.ecore' - -package Taxation - ---context Income inv inv8: ---if(not self.income_type.oclIsTypeOf(Employment_Income)) then ---self.details->forAll(d| d.distance = 0) ---else ---self.details->forAll(d| d.distance >= 0.0 and d.distance <= 100) ---endif --- ---context Legal_Union_Record inv inv490: ---self.individual_A.oclIsKindOf(Tax_Payer) --- ---context Legal_Union_Record inv inv491: ---self.individual_B->forAll(i | i.oclIsKindOf(Physical_Person) ) --- ---context Legal_Union_Record inv inv492: ---self.individual_B->forAll(i | not i.oclIsTypeOf(Dependent) ) --- ---context Legal_Union_Record inv inv493: ---self.individual_A <> self.individual_B --- ---context Tax_Payer inv inv13: --- self.addresses->exists( hab_add:Address | hab_add.oclIsTypeOf(Habitual_Address) = true and hab_add.country=Country::ZZ) ---implies --- self.oclIsTypeOf(Resident_Tax_Payer) - - context Income inv inv7: -let val:Real =self.details->asOrderedSet()->first().distance in -self.details->forAll(d: Income_Detail|d.distance = val) - ---context External_Allowance inv inv15: ---let child:Dependent = self.person in ---let h:Household = Household.allInstances()->select(children->includes(child))->asOrderedSet()->first() in ---let t1:Set(Physical_Person) = Set{h.parents.individual_A}->union(h.parents.individual_B)->select(oclIsKindOf(Tax_Payer)) in ---if(t1->size()=1) then ---self.reciver = t1->asOrderedSet()->first() ---else ---self.reciver = t1->asOrderedSet()->at(2) or self.reciver = t1->asOrderedSet()->at(1) ---endif - - - -endpackage \ No newline at end of file diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A.vql b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A.vql deleted file mode 100644 index 03e6847d..00000000 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A.vql +++ /dev/null @@ -1,356 +0,0 @@ -package queries - -import "http:///TaxCard.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); -//} - -@Constraint(message = "inv15", severity = "error", key = {ea}) -pattern inv15(ea : External_Allowance) { - External_Allowance.person(ea, child); - Household.children(h, child);//only one due to multiplicity - External_Allowance.reciver(ea, i); - Tax_Payer(i); - neg find x_inv15(h, i); -} or { - External_Allowance.reciver(ea, i); - Dependent(i); -} - -pattern x_inv15(h : Household, i : Tax_Payer) { - Household.parents.individual_A(h, i); -} or { - Household.parents.individual_B(h, i); -} - -//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/queries/case_study_short.vql b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_short.vql deleted file mode 100644 index f11ef7b7..00000000 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_short.vql +++ /dev/null @@ -1,51 +0,0 @@ -package queries - -import "http:///TaxCard.ecore" - -//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); -//} -// -////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); -//} - -////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); -} \ No newline at end of file diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/ConfigGenerator.java b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/ConfigGenerator.java deleted file mode 100644 index 044d2651..00000000 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/ConfigGenerator.java +++ /dev/null @@ -1,13 +0,0 @@ -package run; - -import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor; - -public class ConfigGenerator { - public static void main(String[] args) { - String errorMessages = StandaloneScriptExecutor.executeScript("config/taxation.vsconfig"); - if(errorMessages!=null) { - System.out.println(errorMessages); - } - } - -} 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 deleted file mode 100644 index ccb0d7b3..00000000 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend +++ /dev/null @@ -1,196 +0,0 @@ -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 hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic -import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace -import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor -import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput -import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type -import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem -import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult -import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult -import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore -import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor -import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation -import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml -import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner -import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration -import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser -import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace -import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace -import java.io.PrintWriter -import java.math.BigDecimal -import java.text.SimpleDateFormat -import java.util.ArrayList -import java.util.Date -import java.util.HashMap -import java.util.List -import java.util.Map -import org.eclipse.core.runtime.NullProgressMonitor -import org.eclipse.emf.ecore.EAttribute -import org.eclipse.emf.ecore.EClass -import org.eclipse.emf.ecore.EEnum -import org.eclipse.emf.ecore.EEnumLiteral -import org.eclipse.emf.ecore.EObject -import org.eclipse.emf.ecore.EPackage -import org.eclipse.emf.ecore.EReference -import org.eclipse.emf.ecore.resource.Resource -import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl -import org.eclipse.viatra.query.runtime.api.IQueryGroup - -class GenerateFromConfig { - static val SIZE_LB = 200 - static val SIZE_UB = 200 - static val SIZE_MUL = 1 - static val SIZE_INC = 5 - - static var REPS = 3 - static val RUNTIME = 600 - - static val DOMAIN = "FamilyTree" // "FamilyTree", "Taxation", "Satellite" - static val QUERIES = true - static val INITIAL = true - static val INDIV_WRT = false - static val GLOBAL_WRT = false - static val q2t = if(QUERIES) "Y" else "N" - - def static void main(String[] args) { - Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi", new XMIResourceFactoryImpl) - - // Workspace setup - val Date date = new Date(System.currentTimeMillis) - val SimpleDateFormat format = new SimpleDateFormat("dd-HHmm"); - val formattedDate = DOMAIN + "/" + format.format(date) - - val workspace = new FileSystemWorkspace('''output/''' + formattedDate + '''/''', "") - workspace.initAndClear - - println("Input and output workspaces are created") - - val executor = new ScriptExecutor - val path = "config//generic" + DOMAIN + ".vsconfig" - var ConfigurationScript config = StandaloneScriptExecutor.loadScript(path) - - println("Config File loaded") - - // ///////////////////////// - // BEGIN RUN - var PrintWriter global_writer = null - val header = "domain, queries?,size,model?,timeout,measuredTime,TransformatonTime,SolverTime\n" - if (GLOBAL_WRT) { - global_writer = new PrintWriter( - workspace.workspaceURI + "//_" + DOMAIN + SIZE_LB + "to" + SIZE_UB + "x" + REPS + "q" + q2t + "-" + - formattedDate + ".csv") - global_writer.append(header) - } - - var NEXT_INC = SIZE_INC - for (var size = SIZE_LB; size <= SIZE_UB; size += NEXT_INC) { - NEXT_INC *= SIZE_MUL - - var PrintWriter indiv_writer = null - if (INDIV_WRT) { - indiv_writer = new PrintWriter( // TODO - workspace.workspaceURI + "//__" + DOMAIN + "Sz" + size + "x" + REPS + "q" + q2t + "-" + formattedDate + - ".csv") - indiv_writer.append(header) - } - - println() - 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 + "/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 - - println("<" + measuredTime / 1000.0 + "s >>\n") - -// val toAddtoCSV = DOMAIN + "," + QUERIES + "," + size + "," + -// (solution.class == ModelResultImpl).toString + "," + RUNTIME + "," + measuredTime / 1000.0 + "," + -// solution.statistics.transformationTime / 1000.0 + "," + solution.statistics.solverTime / 1000.0 + -// "\n" -// -// 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) -// } - if(INDIV_WRT) indiv_writer.close - } - if(GLOBAL_WRT) global_writer.close - } - - def static writeStats(LogicResult solution, long time, ViatraReasonerConfiguration config) { - val stats = solution.statistics - println(" Statistics:") -// for (e : stats.entries.filter[name.substring(0, 9) == "_Solution"]) { -// println(" " + e.name + ": " + (e as IntStatisticEntry).value + " ms") -// } - println( - " #new nodes : [" + config.typeScopes.minNewElements + ".." + - (if(config.typeScopes.maxNewElements == 2147483647) "*" else config.typeScopes.maxNewElements) + "]") - println(" \"solve\" time: " + time as double / 1000 + " s") - -// println("<>") - } -} diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GeneratePledgeModels.xtend b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GeneratePledgeModels.xtend deleted file mode 100644 index 23a34bf1..00000000 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GeneratePledgeModels.xtend +++ /dev/null @@ -1,360 +0,0 @@ -package run - -import Taxation.TaxationPackage -import familytree.FamilytreePackage -import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic -import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration -import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace -import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor -import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel -import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput -import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type -import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem -import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult -import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult -import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.impl.ModelResultImpl -import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore -import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic -import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration -import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor -import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic -import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation -import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml -import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner -import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration -import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser -import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace -import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace -import java.io.PrintWriter -import java.math.BigDecimal -import java.text.SimpleDateFormat -import java.util.Date -import java.util.HashMap -import java.util.List -import java.util.Map -import java.util.TreeSet -import org.eclipse.emf.common.util.EList -import org.eclipse.emf.ecore.EAttribute -import org.eclipse.emf.ecore.EClass -import org.eclipse.emf.ecore.EEnum -import org.eclipse.emf.ecore.EEnumLiteral -import org.eclipse.emf.ecore.EObject -import org.eclipse.emf.ecore.EPackage -import org.eclipse.emf.ecore.EReference -import org.eclipse.emf.ecore.resource.Resource -import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl -import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup -import org.eclipse.viatra.query.runtime.api.IQueryGroup -import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine -import queries.Case_study_A -import queries.FamilyTreeConstraints - -class GeneratePledgeModels { -static val SIZE_LB = 20 -static val SIZE_UB = 20 -static val SIZE_MUL = 1 -static val SIZE_INC = 5 - -static var REPS = 1 -static val RUNTIME = 600 - -static val DOMAIN = "FamilyTree" // "FamilyTree", "Taxation" -static val QUERIES = false -static val INDIV_WRT = true -static val GLOBAL_WRT = true -static val q2t = if(QUERIES) "Y" else "N" - -def static void main(String[] args) { - (new EMFPatternLanguageStandaloneSetup).createInjectorAndDoEMFRegistration - Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi", new XMIResourceFactoryImpl) - Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("logicproblem", new XMIResourceFactoryImpl) - Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("partialmodel", new XMIResourceFactoryImpl) - ReteEngine.getClass - val Ecore2Logic ecore2Logic = new Ecore2Logic - val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic) - val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) - val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic - - // Workspace setup - val Date date = new Date(System.currentTimeMillis) - val SimpleDateFormat format = new SimpleDateFormat("dd-HHmm"); - val formattedDate = format.format(date) - - val inputs = new FileSystemWorkspace('''inputs/''', "") - val dataws = new FileSystemWorkspace('''output/''', "") - val modelsws = new FileSystemWorkspace('''output/''' + formattedDate + '''/models/''', "") - val workspace = new FileSystemWorkspace('''output/''' + formattedDate + '''/''', "") - val debug = new FileSystemWorkspace('''output/''' + DOMAIN + "-" + formattedDate + '''/debug/''', "") - workspace.initAndClear - modelsws.initAndClear - - println("Input and output workspaces are created") - - // ////////////////////////// - // DOMAIN - var EcoreMetamodelDescriptor metamodel = null - var EList partialModel = null - var ViatraQuerySetDescriptor queries = null - switch DOMAIN { - case "Taxation": { - metamodel = loadMetamodel(TaxationPackage.eINSTANCE) - partialModel = loadPartialModel(inputs, "Household.xmi") -// queries = loadQueries(metamodel, Case_study_A.instance) - } - case "FamilyTree": { - metamodel = loadMetamodel(FamilytreePackage.eINSTANCE) - partialModel = loadPartialModel(inputs, "FamilyTree.xmi") -// queries = loadQueries(metamodel, FamilyTreeConstraints.instance) - } - default: { - System.err.println("Unsupported Domain") - throw new Exception - } - } - println("DSL loaded") - - // ///////////////////////// - // Prepare Problem - val modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel, new Ecore2LogicConfiguration()) - var problem = modelGenerationProblem.output - val modelExtensionProblem = instanceModel2Logic.transform(modelGenerationProblem, partialModel) - problem = modelExtensionProblem.output - if (QUERIES) { - val validModelExtensionProblem = viatra2Logic.transformQueries(queries, modelExtensionProblem, - new Viatra2LogicConfiguration) - problem = validModelExtensionProblem.output - } - // debug.writeModel(problem, "problem.logicproblem") - println("Problem created") - // ///////////////////////// - // BEGIN RUN - var PrintWriter global_writer = null - val header = "domain, queries?,size,model?,timeout,measuredTime,TransformatonTime,SolverTime\n" - if (GLOBAL_WRT) { - global_writer = new PrintWriter( - workspace.workspaceURI + "//_" + DOMAIN + SIZE_LB + "to" + SIZE_UB + "x" + REPS + "q" + q2t + "-" + - formattedDate + ".csv") - global_writer.append(header) - } - - var NEXT_INC = SIZE_INC - for (var size = SIZE_LB; size <= SIZE_UB; size += NEXT_INC) { - NEXT_INC *= SIZE_MUL - - var PrintWriter indiv_writer = null - if (INDIV_WRT) { - indiv_writer = new PrintWriter( // TODO - workspace.workspaceURI + "//__" + DOMAIN + "Sz" + size + "x" + REPS + "q" + q2t + "-" + formattedDate + - ".csv") - indiv_writer.append(header) - } - - println() - println("DOMAIN: " + DOMAIN + ", SIZE=" + size) - - for (var i = 0; i < REPS; i++) { - - print("<> : ") - - var ViatraReasoner reasoner = new ViatraReasoner - - // ///////////////////////////////////////////////////// - // Define Config File - val knownIntegers = new TreeSet - knownIntegers.addAll(0, 10, 20, 30, 40, 50) - - val knownReals = new TreeSet - knownReals.addAll(new BigDecimal("0.0")) - - val knownStrings = new TreeSet - knownStrings.addAll("r0", "r1", "r2", "r3", "r4", "r5", "r6") - - val curSize = size - val solverConfig = new ViatraReasonerConfiguration => [ - it.documentationLevel = DocumentationLevel::NONE -// it.debugCongiguration = new DebugConfiguration => [logging = true] - it.runtimeLimit = RUNTIME - // it.typeScopes.maxNewElements = SIZE - it.typeScopes.minNewElements = curSize - -// if(!knownIntegers.isEmpty) it.typeScopes.knownIntegers = knownIntegers - if(!knownReals.isEmpty) it.typeScopes.knownReals = knownReals - // if(!knownStrings.isEmpty) it.typeScopes.knownStrings = knownStrings - ] - - val startTime = System.currentTimeMillis - var solution = reasoner.solve(problem, solverConfig, debug) - val measuredTime = System.currentTimeMillis - startTime - - print("<" + measuredTime / 1000.0 + "s") - -// solution.writeStats(totalTime, solverConfig) - try { - if (solution instanceof ModelResult) { - solution.writeInterpretation(logic2Ecore, modelsws, size + "_" + i, reasoner, modelGenerationProblem) - println(" (XMI Success)") - } - } catch (Exception e) { - System.err.println(" (XMI Error)" + e.message) - } - - try { - if (solution instanceof ModelResult) { - solution.writeRepresentation(modelsws, size + "_" + i) - println(" (VIZ Success) >>") - } - } catch (Exception e) { - System.err.println(" (VIZ Error)" + e.message + ">>") - } - - println() - // 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 - } - - def - -static Map getTypeMap(Map classMap, EcoreMetamodelDescriptor metamodel, - Ecore2Logic e2l, Ecore2Logic_Trace trace) { - val typeMap = new HashMap - val listMap = metamodel.classes.toMap[s|s.name] - - for (Class elem : classMap.keySet) { - typeMap.put(e2l.TypeofEClass( - trace, - listMap.get(elem.simpleName) - ), classMap.get(elem)) - } - return typeMap - } - - def - -static loadMetamodel(EPackage pckg) { - val List classes = pckg.getEClassifiers.filter(EClass).toList - val List enums = pckg.getEClassifiers.filter(EEnum).toList - val List literals = enums.map[getELiterals].flatten.toList - val List references = classes.map[getEReferences].flatten.toList - val List attributes = classes.map[getEAttributes].flatten.toList - return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes) - } - - def - -static loadPartialModel(ReasonerWorkspace inputs, String path) { - Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()) - inputs.readModel(EObject, path).eResource.contents -// inputs.readModel(EObject,"FamInstance.xmi").eResource.allContents.toList - } - - def - -static loadQueries(EcoreMetamodelDescriptor metamodel, IQueryGroup i) { - val patterns = i.specifications.toList - val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet - val derivedFeatures = emptyMap - // NO DERIVED FEATURES -// val derivedFeatures = new LinkedHashMap -// derivedFeatures.put(i.type,metamodel.attributes.filter[it.name == "type"].head) -// derivedFeatures.put(i.model,metamodel.references.filter[it.name == "model"].head) - val res = new ViatraQuerySetDescriptor( - patterns, - wfPatterns, - derivedFeatures - ) - return res - } - - def - -static writeInterpretation(LogicResult solution, Logic2Ecore logic2Ecore, ReasonerWorkspace workspace, - String id, ViatraReasoner reasoner, TracedOutput mgProb) { - val interpretations = reasoner.getInterpretations(solution as ModelResult) - for (interpIndex : 0 ..< interpretations.size) { -// val extension b = new LogicStructureBuilder -// val extension a = new LogicProblemBuilder - val interpretation = interpretations.get(interpIndex) - val model = logic2Ecore.transformInterpretation(interpretation, mgProb.trace) -// println(model) - workspace.writeModel(model, '''sol-«id»_«interpIndex».xmi''') - } - } - - def - -static writeRepresentation(LogicResult solution, ReasonerWorkspace workspace, String id) { - val representations = solution.representation - for (representationIndex : 0 ..< representations.size) { - val representation = representations.get(representationIndex) - if (representation instanceof PartialInterpretation) { - val gml = (new PartialInterpretation2Gml).transform(representation) - workspace.writeText('''sol-«id»_«representationIndex».gml''', gml) - - val png = (new GraphvizVisualiser).visualiseConcretization(representation) -// println(png) - png.writeToFile(workspace, '''sol-«id»_«representationIndex».png''') - -// workspace.writeModel(representation, '''solution«representationIndex».partialintrpretation''') - } else { - workspace.writeText('''sol-«representationIndex».txt''', representation.toString) - } - } - } - - def - -static writeStats(LogicResult solution, long time, ViatraReasonerConfiguration config) { - val stats = solution.statistics - println(" Statistics:") -// for (e : stats.entries.filter[name.substring(0, 9) == "_Solution"]) { -// println(" " + e.name + ": " + (e as IntStatisticEntry).value + " ms") -// } - println( - " #new nodes : [" + config.typeScopes.minNewElements + ".." + - (if(config.typeScopes.maxNewElements == 2147483647) "*" else config.typeScopes.maxNewElements) + "]") - println(" \"solve\" time: " + time as double / 1000 + " s") - -// println("<>") - } -} 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 index 98bf7c83..c84f55d3 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/RunGeneratorConfig.xtend +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/RunGeneratorConfig.xtend @@ -12,6 +12,7 @@ import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.RuntimeEn 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 hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace import java.text.SimpleDateFormat import java.util.Date import org.apache.commons.cli.BasicParser @@ -22,6 +23,8 @@ 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.eclipse.emf.ecore.resource.Resource +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl class RunGeneratorConfig { static var SIZE_LB = 20 @@ -29,9 +32,10 @@ class RunGeneratorConfig { static var HOUSEHOLD = 0 static var RUNS = 10 - static var RUNTIME = 900 + static var MODELS = 10 + static var RUNTIME = 1500 - static var DOMAIN = "FamilyTree" // "FamilyTree", "Taxation", "Satellite" + static var DOMAIN = "FamilyTree" // "FamilyTree", "Satellite", "Taxation" static val QUERIES = true static val INITIAL = true @@ -39,7 +43,7 @@ class RunGeneratorConfig { // Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi", new XMIResourceFactoryImpl) // val workspace = new FileSystemWorkspace('''x/''', "") // workspace.initAndClear - + val options = new Options() val lb = new Option("lb", "lowerBound", true, "generated model Lower bound") @@ -48,8 +52,11 @@ class RunGeneratorConfig { val ub = new Option("ub", "upperBound", true, "generated model Upper bound") options.addOption(ub) - val n = new Option("n", "numRuns", true, "number of runs") - options.addOption(n) + val nr = new Option("nr", "numRuns", true, "number of runs") + options.addOption(nr) + + val nm = new Option("nm", "numModels", true, "number of models") + options.addOption(nm) val rt = new Option("rt", "runtime", true, "runtime limit") options.addOption(rt) @@ -76,8 +83,10 @@ class RunGeneratorConfig { if(lbIn !== null) SIZE_LB = Integer.parseInt(lbIn) val ubIn = cmd.getOptionValue("upperBound") if(ubIn !== null) SIZE_UB = Integer.parseInt(ubIn) - val nIn = cmd.getOptionValue("numRuns") - if(nIn !== null) RUNS = Integer.parseInt(nIn) + val nrIn = cmd.getOptionValue("numRuns") + if(nrIn !== null) RUNS = Integer.parseInt(nrIn) + val nmIn = cmd.getOptionValue("numModels") + if(nmIn !== null) MODELS = Integer.parseInt(nmIn) val rtIn = cmd.getOptionValue("runtime") if(rtIn !== null) RUNTIME = Integer.parseInt(rtIn) val dIn = cmd.getOptionValue("domain") @@ -85,6 +94,7 @@ class RunGeneratorConfig { val hhIn = cmd.getOptionValue("household") if(hhIn !== null) HOUSEHOLD = Integer.parseInt(hhIn) + val isTaxation = DOMAIN == "Taxation" // Workspace setup val Date date = new Date(System.currentTimeMillis) val SimpleDateFormat format = new SimpleDateFormat("dd-HHmm") @@ -97,27 +107,23 @@ class RunGeneratorConfig { // ///////////////////////// // BEGIN RUN println( - "<>") - if (DOMAIN == "TaxationWithRoot") { - println("<>") - } - - - - val naming = DOMAIN + "/size" + toStr(SIZE_LB) + "to" + toStr(SIZE_UB) + "x" + RUNS - + "<>") + if (isTaxation) println("<>") + + var naming = DOMAIN + "/size" + toStr(SIZE_LB) + "to" + toStr(SIZE_UB) + "r" + RUNS + "n" + MODELS + "rt" + RUNTIME + if (isTaxation) naming = naming + "hh" + HOUSEHOLD val outputPath = "measurements/" + "models/" + naming + "_" + formattedDate val debugPath = "measurements/" + "debug/" + naming + "_" + formattedDate val logPath = debugPath + "/log.txt" - val statsPath = "measurements/" + "stats/" + naming + - "stats_" + formattedDate + ".csv" + val statsPath = "measurements/" + "stats/" + naming + "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 + genTask.number = MODELS // Size val scopeSpec = genTask.scope as ScopeSpecification @@ -130,20 +136,19 @@ class RunGeneratorConfig { interval.maxUnlimited = false interval.maxNumber = SIZE_UB } -// workspace.writeModel(config, '''x.xmi''') - - - if (DOMAIN == "TaxationWithRoot") { + if (isTaxation) { if (HOUSEHOLD > 0) { val pms = genTask.partialModel as PartialModelSpecification val me = pms.entry.get(0) as ModelEntry val fs = me.path as FileSpecification fs.path = "inputs/Resource" + HOUSEHOLD + "hh.xmi" println("<>") - } + } else { + scopeSpec.scopes.remove(1) + } } - +// workspace.writeModel(config, '''x.xmi''') // Runtime val configScope = genTask.config as ConfigSpecification val runtimeEntry = configScope.entries.get(0) as RuntimeEntry @@ -165,11 +170,11 @@ class RunGeneratorConfig { println() } - + static def String toStr(int i) { var toAdd = "" - if(i<100 && i != -1) toAdd = "0" - return toAdd+i + if(i < 100 && i != -1) toAdd = "0" + return toAdd + i } } -- cgit v1.2.3-70-g09d2