diff options
author | 2019-05-25 15:00:10 -0400 | |
---|---|---|
committer | 2019-05-25 15:00:10 -0400 | |
commit | 89fe6051866933495237f0c733147700275b9549 (patch) | |
tree | fee5157ef3a68af17aac1a8bdfbf7cfa50240e23 /Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.java | |
parent | MDEOptimiser implementation of CPS benchmark (diff) | |
download | VIATRA-Generator-89fe6051866933495237f0c733147700275b9549.tar.gz VIATRA-Generator-89fe6051866933495237f0c733147700275b9549.tar.zst VIATRA-Generator-89fe6051866933495237f0c733147700275b9549.zip |
MDEOptimiser tuning for CPS
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.java')
-rw-r--r-- | Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.java | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.java index 00a4887b..a6ff0d0e 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.java | |||
@@ -13,7 +13,8 @@ import java.io.FileWriter; | |||
13 | import java.util.List; | 13 | import java.util.List; |
14 | import java.util.Map; | 14 | import java.util.Map; |
15 | import java.util.concurrent.TimeUnit; | 15 | import java.util.concurrent.TimeUnit; |
16 | import java.util.function.Consumer; | 16 | import java.util.regex.Matcher; |
17 | import java.util.regex.Pattern; | ||
17 | import org.eclipse.emf.ecore.EPackage; | 18 | import org.eclipse.emf.ecore.EPackage; |
18 | import org.eclipse.emf.ecore.resource.Resource; | 19 | import org.eclipse.emf.ecore.resource.Resource; |
19 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; | 20 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; |
@@ -30,6 +31,8 @@ public class CbcCpsMain { | |||
30 | 31 | ||
31 | private static final String SOLUTION_FILE = "solution.txt"; | 32 | private static final String SOLUTION_FILE = "solution.txt"; |
32 | 33 | ||
34 | private static final Pattern VALUE_REGEX = Pattern.compile("Optimal - objective value\\s*([0-9]+(\\.[0-9]+)?)"); | ||
35 | |||
33 | private CbcCpsMain() { | 36 | private CbcCpsMain() { |
34 | new IllegalStateException("This is a static utility class and should not be instantiated directly."); | 37 | new IllegalStateException("This is a static utility class and should not be instantiated directly."); |
35 | } | 38 | } |
@@ -40,7 +43,7 @@ public class CbcCpsMain { | |||
40 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | 43 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); |
41 | _extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, _xMIResourceFactoryImpl); | 44 | _extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, _xMIResourceFactoryImpl); |
42 | EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, CpsPackage.eINSTANCE); | 45 | EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, CpsPackage.eINSTANCE); |
43 | final CpsGenerator generator = new CpsGenerator(1, 4, 2); | 46 | final CpsGenerator generator = new CpsGenerator(1, 4, 1); |
44 | final CyberPhysicalSystem problem = generator.generateCpsProblem(); | 47 | final CyberPhysicalSystem problem = generator.generateCpsProblem(); |
45 | final CpsToLpTranslator toLp = new CpsToLpTranslator(problem, 10, true); | 48 | final CpsToLpTranslator toLp = new CpsToLpTranslator(problem, 10, true); |
46 | final CharSequence lp = toLp.getLpProblem(); | 49 | final CharSequence lp = toLp.getLpProblem(); |
@@ -69,27 +72,36 @@ public class CbcCpsMain { | |||
69 | } | 72 | } |
70 | FileReader _fileReader = new FileReader(CbcCpsMain.SOLUTION_FILE); | 73 | FileReader _fileReader = new FileReader(CbcCpsMain.SOLUTION_FILE); |
71 | final BufferedReader reader = new BufferedReader(_fileReader); | 74 | final BufferedReader reader = new BufferedReader(_fileReader); |
75 | double value = Double.NaN; | ||
72 | try { | 76 | try { |
73 | final Consumer<String> _function = (String it) -> { | 77 | String line = null; |
74 | InputOutput.<String>println(it); | 78 | while (((line = reader.readLine()) != null)) { |
75 | }; | 79 | { |
76 | reader.lines().forEach(_function); | 80 | InputOutput.<String>println(line); |
81 | final Matcher matcher = CbcCpsMain.VALUE_REGEX.matcher(line); | ||
82 | boolean _matches = matcher.matches(); | ||
83 | if (_matches) { | ||
84 | value = Double.parseDouble(matcher.group(1)); | ||
85 | } | ||
86 | } | ||
87 | } | ||
77 | } finally { | 88 | } finally { |
78 | reader.close(); | 89 | reader.close(); |
79 | } | 90 | } |
80 | final Function1<Request, List<Integer>> _function_1 = (Request it) -> { | 91 | final Function1<Request, List<Integer>> _function = (Request it) -> { |
81 | final Function1<Requirement, Integer> _function_2 = (Requirement it_1) -> { | 92 | final Function1<Requirement, Integer> _function_1 = (Requirement it_1) -> { |
82 | return Integer.valueOf(it_1.getCount()); | 93 | return Integer.valueOf(it_1.getCount()); |
83 | }; | 94 | }; |
84 | return ListExtensions.<Requirement, Integer>map(it.getRequirements(), _function_2); | 95 | return ListExtensions.<Requirement, Integer>map(it.getRequirements(), _function_1); |
85 | }; | 96 | }; |
86 | final Function2<Integer, Integer, Integer> _function_2 = (Integer p1, Integer p2) -> { | 97 | final Function2<Integer, Integer, Integer> _function_1 = (Integer p1, Integer p2) -> { |
87 | return Integer.valueOf(((p1).intValue() + (p2).intValue())); | 98 | return Integer.valueOf(((p1).intValue() + (p2).intValue())); |
88 | }; | 99 | }; |
89 | Integer _reduce = IterableExtensions.<Integer>reduce(IterableExtensions.<Request, Integer>flatMap(problem.getRequests(), _function_1), _function_2); | 100 | Integer _reduce = IterableExtensions.<Integer>reduce(IterableExtensions.<Request, Integer>flatMap(problem.getRequests(), _function), _function_1); |
90 | int _multiply = ((_reduce).intValue() * 5); | 101 | final int applicationCost = ((_reduce).intValue() * 5); |
91 | String _plus_1 = ("Additional cost: " + Integer.valueOf(_multiply)); | 102 | final double cost = (applicationCost + value); |
92 | InputOutput.<String>println(_plus_1); | 103 | InputOutput.println(); |
104 | InputOutput.<String>println(("Cost: " + Double.valueOf(cost))); | ||
93 | } catch (Throwable _e) { | 105 | } catch (Throwable _e) { |
94 | throw Exceptions.sneakyThrow(_e); | 106 | throw Exceptions.sneakyThrow(_e); |
95 | } | 107 | } |