diff options
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner')
36 files changed, 0 insertions, 1836 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.CbcCpsMain.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.CbcCpsMain.xtendbin deleted file mode 100644 index 14b2c080..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.CbcCpsMain.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.CpsToLpTranslator.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.CpsToLpTranslator.xtendbin deleted file mode 100644 index 9acd8621..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.CpsToLpTranslator.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.gitignore deleted file mode 100644 index 011600b4..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.gitignore +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | /.CpsToLpTranslator.java._trace | ||
2 | /.CbcCpsMain.java._trace | ||
3 | /.CbcCpsMain.xtendbin | ||
4 | /.CpsToLpTranslator.xtendbin | ||
5 | /CbcCpsMain.java | ||
6 | /CpsToLpTranslator.java | ||
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 deleted file mode 100644 index a6ff0d0e..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.java +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.cplex; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.Request; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.cplex.CpsToLpTranslator; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.generator.CpsGenerator; | ||
9 | import java.io.BufferedReader; | ||
10 | import java.io.BufferedWriter; | ||
11 | import java.io.FileReader; | ||
12 | import java.io.FileWriter; | ||
13 | import java.util.List; | ||
14 | import java.util.Map; | ||
15 | import java.util.concurrent.TimeUnit; | ||
16 | import java.util.regex.Matcher; | ||
17 | import java.util.regex.Pattern; | ||
18 | import org.eclipse.emf.ecore.EPackage; | ||
19 | import org.eclipse.emf.ecore.resource.Resource; | ||
20 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; | ||
21 | import org.eclipse.xtext.xbase.lib.Exceptions; | ||
22 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
23 | import org.eclipse.xtext.xbase.lib.Functions.Function2; | ||
24 | import org.eclipse.xtext.xbase.lib.InputOutput; | ||
25 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
26 | import org.eclipse.xtext.xbase.lib.ListExtensions; | ||
27 | |||
28 | @SuppressWarnings("all") | ||
29 | public class CbcCpsMain { | ||
30 | private static final String PROBLEM_FILE = "problem.lp"; | ||
31 | |||
32 | private static final String SOLUTION_FILE = "solution.txt"; | ||
33 | |||
34 | private static final Pattern VALUE_REGEX = Pattern.compile("Optimal - objective value\\s*([0-9]+(\\.[0-9]+)?)"); | ||
35 | |||
36 | private CbcCpsMain() { | ||
37 | new IllegalStateException("This is a static utility class and should not be instantiated directly."); | ||
38 | } | ||
39 | |||
40 | public static void main(final String[] args) { | ||
41 | try { | ||
42 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | ||
43 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | ||
44 | _extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, _xMIResourceFactoryImpl); | ||
45 | EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, CpsPackage.eINSTANCE); | ||
46 | final CpsGenerator generator = new CpsGenerator(1, 4, 1); | ||
47 | final CyberPhysicalSystem problem = generator.generateCpsProblem(); | ||
48 | final CpsToLpTranslator toLp = new CpsToLpTranslator(problem, 10, true); | ||
49 | final CharSequence lp = toLp.getLpProblem(); | ||
50 | FileWriter _fileWriter = new FileWriter(CbcCpsMain.PROBLEM_FILE); | ||
51 | final BufferedWriter writer = new BufferedWriter(_fileWriter); | ||
52 | try { | ||
53 | writer.append(lp); | ||
54 | } finally { | ||
55 | writer.close(); | ||
56 | } | ||
57 | final Process process = new ProcessBuilder().inheritIO().command("cbc", CbcCpsMain.PROBLEM_FILE, "solve", "solu", CbcCpsMain.SOLUTION_FILE).start(); | ||
58 | boolean _waitFor = process.waitFor(120, TimeUnit.SECONDS); | ||
59 | boolean _not = (!_waitFor); | ||
60 | if (_not) { | ||
61 | System.err.println("Timeout reached"); | ||
62 | process.destroyForcibly(); | ||
63 | System.exit((-1)); | ||
64 | } | ||
65 | int _exitValue = process.exitValue(); | ||
66 | boolean _notEquals = (_exitValue != 0); | ||
67 | if (_notEquals) { | ||
68 | int _exitValue_1 = process.exitValue(); | ||
69 | String _plus = ("Unexpected exit value " + Integer.valueOf(_exitValue_1)); | ||
70 | System.err.println(_plus); | ||
71 | System.exit((-1)); | ||
72 | } | ||
73 | FileReader _fileReader = new FileReader(CbcCpsMain.SOLUTION_FILE); | ||
74 | final BufferedReader reader = new BufferedReader(_fileReader); | ||
75 | double value = Double.NaN; | ||
76 | try { | ||
77 | String line = null; | ||
78 | while (((line = reader.readLine()) != null)) { | ||
79 | { | ||
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 | } | ||
88 | } finally { | ||
89 | reader.close(); | ||
90 | } | ||
91 | final Function1<Request, List<Integer>> _function = (Request it) -> { | ||
92 | final Function1<Requirement, Integer> _function_1 = (Requirement it_1) -> { | ||
93 | return Integer.valueOf(it_1.getCount()); | ||
94 | }; | ||
95 | return ListExtensions.<Requirement, Integer>map(it.getRequirements(), _function_1); | ||
96 | }; | ||
97 | final Function2<Integer, Integer, Integer> _function_1 = (Integer p1, Integer p2) -> { | ||
98 | return Integer.valueOf(((p1).intValue() + (p2).intValue())); | ||
99 | }; | ||
100 | Integer _reduce = IterableExtensions.<Integer>reduce(IterableExtensions.<Request, Integer>flatMap(problem.getRequests(), _function), _function_1); | ||
101 | final int applicationCost = ((_reduce).intValue() * 5); | ||
102 | final double cost = (applicationCost + value); | ||
103 | InputOutput.println(); | ||
104 | InputOutput.<String>println(("Cost: " + Double.valueOf(cost))); | ||
105 | } catch (Throwable _e) { | ||
106 | throw Exceptions.sneakyThrow(_e); | ||
107 | } | ||
108 | } | ||
109 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CpsToLpTranslator.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CpsToLpTranslator.java deleted file mode 100644 index 20afeee6..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CpsToLpTranslator.java +++ /dev/null | |||
@@ -1,505 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.cplex; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import com.google.common.collect.ImmutableList; | ||
5 | import com.google.common.collect.ImmutableMap; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.cps.Request; | ||
10 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; | ||
11 | import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; | ||
12 | import java.util.Collection; | ||
13 | import java.util.List; | ||
14 | import java.util.Map; | ||
15 | import org.eclipse.emf.common.util.EList; | ||
16 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
17 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
18 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; | ||
19 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
20 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
21 | import org.eclipse.xtext.xbase.lib.ListExtensions; | ||
22 | import org.eclipse.xtext.xbase.lib.Pair; | ||
23 | |||
24 | @SuppressWarnings("all") | ||
25 | public class CpsToLpTranslator { | ||
26 | private static final double MINIMUM_MEMORY_USAGE = 0.25; | ||
27 | |||
28 | private static final double MINIMUM_HDD_USAGE = 0.25; | ||
29 | |||
30 | private final CyberPhysicalSystem cps; | ||
31 | |||
32 | private final Map<Requirement, ? extends List<String>> appInstances; | ||
33 | |||
34 | private final Map<HostType, ? extends List<String>> hostInstances; | ||
35 | |||
36 | private final boolean breakSymmetry; | ||
37 | |||
38 | public CpsToLpTranslator(final CyberPhysicalSystem cps, final int hostInstanceCount, final boolean breakSymmetry) { | ||
39 | this.cps = cps; | ||
40 | this.appInstances = this.createAppInstances(); | ||
41 | this.hostInstances = this.createHostInstances(hostInstanceCount); | ||
42 | this.breakSymmetry = breakSymmetry; | ||
43 | } | ||
44 | |||
45 | private ImmutableMap<Requirement, ImmutableList<String>> createAppInstances() { | ||
46 | ImmutableMap<Requirement, ImmutableList<String>> _xblockexpression = null; | ||
47 | { | ||
48 | final ImmutableMap.Builder<Requirement, ImmutableList<String>> builder = ImmutableMap.<Requirement, ImmutableList<String>>builder(); | ||
49 | int i = 0; | ||
50 | Iterable<Requirement> _requirements = this.getRequirements(); | ||
51 | for (final Requirement req : _requirements) { | ||
52 | { | ||
53 | final ImmutableList.Builder<String> listBuilder = ImmutableList.<String>builder(); | ||
54 | for (int j = 0; (j < req.getCount()); j++) { | ||
55 | StringConcatenation _builder = new StringConcatenation(); | ||
56 | _builder.append("r"); | ||
57 | _builder.append(i); | ||
58 | _builder.append("a"); | ||
59 | _builder.append(j); | ||
60 | listBuilder.add(_builder.toString()); | ||
61 | } | ||
62 | builder.put(req, listBuilder.build()); | ||
63 | i++; | ||
64 | } | ||
65 | } | ||
66 | _xblockexpression = builder.build(); | ||
67 | } | ||
68 | return _xblockexpression; | ||
69 | } | ||
70 | |||
71 | private ImmutableMap<HostType, ImmutableList<String>> createHostInstances(final int hostInstanceCount) { | ||
72 | ImmutableMap<HostType, ImmutableList<String>> _xblockexpression = null; | ||
73 | { | ||
74 | final ImmutableMap.Builder<HostType, ImmutableList<String>> builder = ImmutableMap.<HostType, ImmutableList<String>>builder(); | ||
75 | int i = 0; | ||
76 | EList<HostType> _hostTypes = this.cps.getHostTypes(); | ||
77 | for (final HostType hostType : _hostTypes) { | ||
78 | { | ||
79 | final ImmutableList.Builder<String> listBuilder = ImmutableList.<String>builder(); | ||
80 | for (int j = 0; (j < hostInstanceCount); j++) { | ||
81 | StringConcatenation _builder = new StringConcatenation(); | ||
82 | _builder.append("h"); | ||
83 | _builder.append(i); | ||
84 | _builder.append("i"); | ||
85 | _builder.append(j); | ||
86 | listBuilder.add(_builder.toString()); | ||
87 | } | ||
88 | builder.put(hostType, listBuilder.build()); | ||
89 | i++; | ||
90 | } | ||
91 | } | ||
92 | _xblockexpression = builder.build(); | ||
93 | } | ||
94 | return _xblockexpression; | ||
95 | } | ||
96 | |||
97 | public CharSequence getLpProblem() { | ||
98 | StringConcatenation _builder = new StringConcatenation(); | ||
99 | _builder.append("Minimize"); | ||
100 | _builder.newLine(); | ||
101 | _builder.append("\t"); | ||
102 | _builder.append("total_cost: "); | ||
103 | CharSequence _objective = this.getObjective(); | ||
104 | _builder.append(_objective, "\t"); | ||
105 | _builder.newLineIfNotEmpty(); | ||
106 | _builder.append("Subject To"); | ||
107 | _builder.newLine(); | ||
108 | _builder.append("\t"); | ||
109 | CharSequence _constraints = this.getConstraints(); | ||
110 | _builder.append(_constraints, "\t"); | ||
111 | _builder.newLineIfNotEmpty(); | ||
112 | _builder.append("Bounds"); | ||
113 | _builder.newLine(); | ||
114 | _builder.append("\t"); | ||
115 | CharSequence _bounds = this.getBounds(); | ||
116 | _builder.append(_bounds, "\t"); | ||
117 | _builder.newLineIfNotEmpty(); | ||
118 | _builder.append("Binary"); | ||
119 | _builder.newLine(); | ||
120 | _builder.append("\t"); | ||
121 | CharSequence _binaryVariables = this.getBinaryVariables(); | ||
122 | _builder.append(_binaryVariables, "\t"); | ||
123 | _builder.newLineIfNotEmpty(); | ||
124 | _builder.append("End"); | ||
125 | _builder.newLine(); | ||
126 | return _builder; | ||
127 | } | ||
128 | |||
129 | private CharSequence getObjective() { | ||
130 | StringConcatenation _builder = new StringConcatenation(); | ||
131 | { | ||
132 | Iterable<Pair<HostType, String>> _hostInstancesWithType = this.getHostInstancesWithType(); | ||
133 | boolean _hasElements = false; | ||
134 | for(final Pair<HostType, String> pair : _hostInstancesWithType) { | ||
135 | if (!_hasElements) { | ||
136 | _hasElements = true; | ||
137 | } else { | ||
138 | _builder.appendImmediate(" + ", ""); | ||
139 | } | ||
140 | int _cost = pair.getKey().getCost(); | ||
141 | _builder.append(_cost); | ||
142 | _builder.append(" "); | ||
143 | CharSequence _existsVariable = this.getExistsVariable(pair.getValue()); | ||
144 | _builder.append(_existsVariable); | ||
145 | } | ||
146 | } | ||
147 | return _builder; | ||
148 | } | ||
149 | |||
150 | private CharSequence getConstraints() { | ||
151 | StringConcatenation _builder = new StringConcatenation(); | ||
152 | { | ||
153 | Iterable<Pair<ApplicationType, String>> _appInstancesWithType = this.getAppInstancesWithType(); | ||
154 | for(final Pair<ApplicationType, String> appPair : _appInstancesWithType) { | ||
155 | String _value = appPair.getValue(); | ||
156 | _builder.append(_value); | ||
157 | _builder.append("_allocated: "); | ||
158 | { | ||
159 | Iterable<String> _possibleHostInstances = this.getPossibleHostInstances(appPair.getKey()); | ||
160 | boolean _hasElements = false; | ||
161 | for(final String host : _possibleHostInstances) { | ||
162 | if (!_hasElements) { | ||
163 | _hasElements = true; | ||
164 | } else { | ||
165 | _builder.appendImmediate(" + ", ""); | ||
166 | } | ||
167 | CharSequence _allocatedToVariable = this.getAllocatedToVariable(appPair.getValue(), host); | ||
168 | _builder.append(_allocatedToVariable); | ||
169 | } | ||
170 | } | ||
171 | _builder.append(" = 1"); | ||
172 | _builder.newLineIfNotEmpty(); | ||
173 | { | ||
174 | Iterable<String> _possibleHostInstances_1 = this.getPossibleHostInstances(appPair.getKey()); | ||
175 | for(final String host_1 : _possibleHostInstances_1) { | ||
176 | String _value_1 = appPair.getValue(); | ||
177 | _builder.append(_value_1); | ||
178 | _builder.append("_to_"); | ||
179 | _builder.append(host_1); | ||
180 | _builder.append("_exists: "); | ||
181 | CharSequence _existsVariable = this.getExistsVariable(host_1); | ||
182 | _builder.append(_existsVariable); | ||
183 | _builder.append(" - "); | ||
184 | CharSequence _allocatedToVariable_1 = this.getAllocatedToVariable(appPair.getValue(), host_1); | ||
185 | _builder.append(_allocatedToVariable_1); | ||
186 | _builder.append(" >= 0"); | ||
187 | _builder.newLineIfNotEmpty(); | ||
188 | } | ||
189 | } | ||
190 | } | ||
191 | } | ||
192 | { | ||
193 | Iterable<Pair<HostType, String>> _hostInstancesWithType = this.getHostInstancesWithType(); | ||
194 | for(final Pair<HostType, String> hostPair : _hostInstancesWithType) { | ||
195 | String _value_2 = hostPair.getValue(); | ||
196 | _builder.append(_value_2); | ||
197 | _builder.append("_mem_use: "); | ||
198 | { | ||
199 | Iterable<Pair<ResourceRequirement, String>> _possibleAppInstancesWithRequirements = this.getPossibleAppInstancesWithRequirements(hostPair.getKey()); | ||
200 | boolean _hasElements_1 = false; | ||
201 | for(final Pair<ResourceRequirement, String> appPair_1 : _possibleAppInstancesWithRequirements) { | ||
202 | if (!_hasElements_1) { | ||
203 | _hasElements_1 = true; | ||
204 | } else { | ||
205 | _builder.appendImmediate(" + ", ""); | ||
206 | } | ||
207 | int _requiredMemory = appPair_1.getKey().getRequiredMemory(); | ||
208 | _builder.append(_requiredMemory); | ||
209 | _builder.append(" "); | ||
210 | CharSequence _allocatedToVariable_2 = this.getAllocatedToVariable(appPair_1.getValue(), hostPair.getValue()); | ||
211 | _builder.append(_allocatedToVariable_2); | ||
212 | } | ||
213 | } | ||
214 | _builder.append(" - "); | ||
215 | int _defaultMemory = hostPair.getKey().getDefaultMemory(); | ||
216 | _builder.append(_defaultMemory); | ||
217 | _builder.append(" "); | ||
218 | CharSequence _memoryUsageVariable = this.getMemoryUsageVariable(hostPair.getValue()); | ||
219 | _builder.append(_memoryUsageVariable); | ||
220 | _builder.append(" = 0"); | ||
221 | _builder.newLineIfNotEmpty(); | ||
222 | String _value_3 = hostPair.getValue(); | ||
223 | _builder.append(_value_3); | ||
224 | _builder.append("_hdd_use: "); | ||
225 | { | ||
226 | Iterable<Pair<ResourceRequirement, String>> _possibleAppInstancesWithRequirements_1 = this.getPossibleAppInstancesWithRequirements(hostPair.getKey()); | ||
227 | boolean _hasElements_2 = false; | ||
228 | for(final Pair<ResourceRequirement, String> appPair_2 : _possibleAppInstancesWithRequirements_1) { | ||
229 | if (!_hasElements_2) { | ||
230 | _hasElements_2 = true; | ||
231 | } else { | ||
232 | _builder.appendImmediate(" + ", ""); | ||
233 | } | ||
234 | int _requiredHdd = appPair_2.getKey().getRequiredHdd(); | ||
235 | _builder.append(_requiredHdd); | ||
236 | _builder.append(" "); | ||
237 | CharSequence _allocatedToVariable_3 = this.getAllocatedToVariable(appPair_2.getValue(), hostPair.getValue()); | ||
238 | _builder.append(_allocatedToVariable_3); | ||
239 | } | ||
240 | } | ||
241 | _builder.append(" - "); | ||
242 | int _defaultHdd = hostPair.getKey().getDefaultHdd(); | ||
243 | _builder.append(_defaultHdd); | ||
244 | _builder.append(" "); | ||
245 | CharSequence _hddUsageVariable = this.getHddUsageVariable(hostPair.getValue()); | ||
246 | _builder.append(_hddUsageVariable); | ||
247 | _builder.append(" = 0"); | ||
248 | _builder.newLineIfNotEmpty(); | ||
249 | } | ||
250 | } | ||
251 | _builder.append("average_mem: "); | ||
252 | { | ||
253 | Iterable<String> _allHostInstances = this.getAllHostInstances(); | ||
254 | boolean _hasElements_3 = false; | ||
255 | for(final String host_2 : _allHostInstances) { | ||
256 | if (!_hasElements_3) { | ||
257 | _hasElements_3 = true; | ||
258 | } else { | ||
259 | _builder.appendImmediate(" + ", ""); | ||
260 | } | ||
261 | CharSequence _memoryUsageVariable_1 = this.getMemoryUsageVariable(host_2); | ||
262 | _builder.append(_memoryUsageVariable_1); | ||
263 | _builder.append(" - "); | ||
264 | _builder.append(CpsToLpTranslator.MINIMUM_MEMORY_USAGE); | ||
265 | _builder.append(" "); | ||
266 | CharSequence _existsVariable_1 = this.getExistsVariable(host_2); | ||
267 | _builder.append(_existsVariable_1); | ||
268 | } | ||
269 | } | ||
270 | _builder.append(" >= 0"); | ||
271 | _builder.newLineIfNotEmpty(); | ||
272 | _builder.append("average_hdd: "); | ||
273 | { | ||
274 | Iterable<String> _allHostInstances_1 = this.getAllHostInstances(); | ||
275 | boolean _hasElements_4 = false; | ||
276 | for(final String host_3 : _allHostInstances_1) { | ||
277 | if (!_hasElements_4) { | ||
278 | _hasElements_4 = true; | ||
279 | } else { | ||
280 | _builder.appendImmediate(" + ", ""); | ||
281 | } | ||
282 | CharSequence _memoryUsageVariable_2 = this.getMemoryUsageVariable(host_3); | ||
283 | _builder.append(_memoryUsageVariable_2); | ||
284 | _builder.append(" - "); | ||
285 | _builder.append(CpsToLpTranslator.MINIMUM_HDD_USAGE); | ||
286 | _builder.append(" "); | ||
287 | CharSequence _existsVariable_2 = this.getExistsVariable(host_3); | ||
288 | _builder.append(_existsVariable_2); | ||
289 | } | ||
290 | } | ||
291 | _builder.append(" >= 0"); | ||
292 | _builder.newLineIfNotEmpty(); | ||
293 | { | ||
294 | final Function1<Requirement, Boolean> _function = (Requirement it) -> { | ||
295 | int _count = it.getCount(); | ||
296 | return Boolean.valueOf((_count > 1)); | ||
297 | }; | ||
298 | Iterable<Pair<Integer, Requirement>> _indexed = IterableExtensions.<Requirement>indexed(IterableExtensions.<Requirement>filter(this.getRequirements(), _function)); | ||
299 | for(final Pair<Integer, Requirement> reqPair : _indexed) { | ||
300 | { | ||
301 | final Function1<ResourceRequirement, List<String>> _function_1 = (ResourceRequirement it) -> { | ||
302 | return this.hostInstances.get(it.getHostType()); | ||
303 | }; | ||
304 | Iterable<String> _flatMap = IterableExtensions.<ResourceRequirement, String>flatMap(reqPair.getValue().getType().getRequirements(), _function_1); | ||
305 | for(final String host_4 : _flatMap) { | ||
306 | _builder.append("r"); | ||
307 | Integer _key = reqPair.getKey(); | ||
308 | _builder.append(_key); | ||
309 | _builder.append("_"); | ||
310 | _builder.append(host_4); | ||
311 | _builder.append("_redundant: "); | ||
312 | { | ||
313 | List<String> _get = this.appInstances.get(reqPair.getValue()); | ||
314 | boolean _hasElements_5 = false; | ||
315 | for(final String app : _get) { | ||
316 | if (!_hasElements_5) { | ||
317 | _hasElements_5 = true; | ||
318 | } else { | ||
319 | _builder.appendImmediate(" + ", ""); | ||
320 | } | ||
321 | CharSequence _allocatedToVariable_4 = this.getAllocatedToVariable(app, host_4); | ||
322 | _builder.append(_allocatedToVariable_4); | ||
323 | } | ||
324 | } | ||
325 | _builder.append(" <= 1"); | ||
326 | _builder.newLineIfNotEmpty(); | ||
327 | } | ||
328 | } | ||
329 | } | ||
330 | } | ||
331 | { | ||
332 | if (this.breakSymmetry) { | ||
333 | { | ||
334 | Collection<? extends List<String>> _values = this.hostInstances.values(); | ||
335 | for(final List<String> hosts : _values) { | ||
336 | { | ||
337 | int _size = hosts.size(); | ||
338 | int _minus = (_size - 1); | ||
339 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _minus, true); | ||
340 | for(final Integer i : _doubleDotLessThan) { | ||
341 | String _get_1 = hosts.get(((i).intValue() + 1)); | ||
342 | _builder.append(_get_1); | ||
343 | _builder.append("_after_"); | ||
344 | String _get_2 = hosts.get((i).intValue()); | ||
345 | _builder.append(_get_2); | ||
346 | _builder.append(": "); | ||
347 | CharSequence _existsVariable_3 = this.getExistsVariable(hosts.get((i).intValue())); | ||
348 | _builder.append(_existsVariable_3); | ||
349 | _builder.append(" - "); | ||
350 | CharSequence _existsVariable_4 = this.getExistsVariable(hosts.get(((i).intValue() + 1))); | ||
351 | _builder.append(_existsVariable_4); | ||
352 | _builder.append(" >= 0"); | ||
353 | _builder.newLineIfNotEmpty(); | ||
354 | } | ||
355 | } | ||
356 | } | ||
357 | } | ||
358 | } | ||
359 | } | ||
360 | return _builder; | ||
361 | } | ||
362 | |||
363 | private CharSequence getBounds() { | ||
364 | StringConcatenation _builder = new StringConcatenation(); | ||
365 | { | ||
366 | Iterable<String> _allHostInstances = this.getAllHostInstances(); | ||
367 | for(final String host : _allHostInstances) { | ||
368 | _builder.append("0 <= "); | ||
369 | CharSequence _memoryUsageVariable = this.getMemoryUsageVariable(host); | ||
370 | _builder.append(_memoryUsageVariable); | ||
371 | _builder.append(" <= 1"); | ||
372 | _builder.newLineIfNotEmpty(); | ||
373 | _builder.append("0 <= "); | ||
374 | CharSequence _hddUsageVariable = this.getHddUsageVariable(host); | ||
375 | _builder.append(_hddUsageVariable); | ||
376 | _builder.append(" <= 1"); | ||
377 | _builder.newLineIfNotEmpty(); | ||
378 | } | ||
379 | } | ||
380 | return _builder; | ||
381 | } | ||
382 | |||
383 | private CharSequence getBinaryVariables() { | ||
384 | StringConcatenation _builder = new StringConcatenation(); | ||
385 | { | ||
386 | Iterable<String> _allHostInstances = this.getAllHostInstances(); | ||
387 | for(final String host : _allHostInstances) { | ||
388 | CharSequence _existsVariable = this.getExistsVariable(host); | ||
389 | _builder.append(_existsVariable); | ||
390 | _builder.newLineIfNotEmpty(); | ||
391 | } | ||
392 | } | ||
393 | { | ||
394 | Iterable<Pair<ApplicationType, String>> _appInstancesWithType = this.getAppInstancesWithType(); | ||
395 | for(final Pair<ApplicationType, String> appPair : _appInstancesWithType) { | ||
396 | { | ||
397 | Iterable<String> _possibleHostInstances = this.getPossibleHostInstances(appPair.getKey()); | ||
398 | for(final String host_1 : _possibleHostInstances) { | ||
399 | CharSequence _allocatedToVariable = this.getAllocatedToVariable(appPair.getValue(), host_1); | ||
400 | _builder.append(_allocatedToVariable); | ||
401 | _builder.newLineIfNotEmpty(); | ||
402 | } | ||
403 | } | ||
404 | } | ||
405 | } | ||
406 | return _builder; | ||
407 | } | ||
408 | |||
409 | private Iterable<Requirement> getRequirements() { | ||
410 | final Function1<Request, EList<Requirement>> _function = (Request it) -> { | ||
411 | return it.getRequirements(); | ||
412 | }; | ||
413 | return IterableExtensions.<Request, Requirement>flatMap(this.cps.getRequests(), _function); | ||
414 | } | ||
415 | |||
416 | private Iterable<String> getAllHostInstances() { | ||
417 | final Function1<List<String>, List<String>> _function = (List<String> it) -> { | ||
418 | return it; | ||
419 | }; | ||
420 | return IterableExtensions.flatMap(this.hostInstances.values(), _function); | ||
421 | } | ||
422 | |||
423 | private Iterable<Pair<HostType, String>> getHostInstancesWithType() { | ||
424 | final Function1<Map.Entry<HostType, ? extends List<String>>, List<Pair<HostType, String>>> _function = (Map.Entry<HostType, ? extends List<String>> pair) -> { | ||
425 | final Function1<String, Pair<HostType, String>> _function_1 = (String it) -> { | ||
426 | HostType _key = pair.getKey(); | ||
427 | return Pair.<HostType, String>of(_key, it); | ||
428 | }; | ||
429 | return ListExtensions.<String, Pair<HostType, String>>map(pair.getValue(), _function_1); | ||
430 | }; | ||
431 | return IterableExtensions.flatMap(this.hostInstances.entrySet(), _function); | ||
432 | } | ||
433 | |||
434 | private Iterable<Pair<ApplicationType, String>> getAppInstancesWithType() { | ||
435 | final Function1<Map.Entry<Requirement, ? extends List<String>>, List<Pair<ApplicationType, String>>> _function = (Map.Entry<Requirement, ? extends List<String>> pair) -> { | ||
436 | final Function1<String, Pair<ApplicationType, String>> _function_1 = (String it) -> { | ||
437 | ApplicationType _type = pair.getKey().getType(); | ||
438 | return Pair.<ApplicationType, String>of(_type, it); | ||
439 | }; | ||
440 | return ListExtensions.<String, Pair<ApplicationType, String>>map(pair.getValue(), _function_1); | ||
441 | }; | ||
442 | return IterableExtensions.flatMap(this.appInstances.entrySet(), _function); | ||
443 | } | ||
444 | |||
445 | private Iterable<String> getPossibleHostInstances(final ApplicationType appType) { | ||
446 | final Function1<ResourceRequirement, List<String>> _function = (ResourceRequirement req) -> { | ||
447 | return this.hostInstances.get(req.getHostType()); | ||
448 | }; | ||
449 | return IterableExtensions.<ResourceRequirement, String>flatMap(appType.getRequirements(), _function); | ||
450 | } | ||
451 | |||
452 | private Iterable<Pair<ResourceRequirement, String>> getPossibleAppInstancesWithRequirements(final HostType hostType) { | ||
453 | final Function1<Map.Entry<Requirement, ? extends List<String>>, List<Pair<ResourceRequirement, String>>> _function = (Map.Entry<Requirement, ? extends List<String>> pair) -> { | ||
454 | List<Pair<ResourceRequirement, String>> _xblockexpression = null; | ||
455 | { | ||
456 | final Function1<ResourceRequirement, Boolean> _function_1 = (ResourceRequirement it) -> { | ||
457 | HostType _hostType = it.getHostType(); | ||
458 | return Boolean.valueOf(Objects.equal(_hostType, hostType)); | ||
459 | }; | ||
460 | final ResourceRequirement resourceReq = IterableExtensions.<ResourceRequirement>findFirst(pair.getKey().getType().getRequirements(), _function_1); | ||
461 | List<Pair<ResourceRequirement, String>> _xifexpression = null; | ||
462 | if ((resourceReq == null)) { | ||
463 | _xifexpression = CollectionLiterals.<Pair<ResourceRequirement, String>>emptyList(); | ||
464 | } else { | ||
465 | final Function1<String, Pair<ResourceRequirement, String>> _function_2 = (String it) -> { | ||
466 | return Pair.<ResourceRequirement, String>of(resourceReq, it); | ||
467 | }; | ||
468 | _xifexpression = ListExtensions.<String, Pair<ResourceRequirement, String>>map(pair.getValue(), _function_2); | ||
469 | } | ||
470 | _xblockexpression = _xifexpression; | ||
471 | } | ||
472 | return _xblockexpression; | ||
473 | }; | ||
474 | return IterableExtensions.flatMap(this.appInstances.entrySet(), _function); | ||
475 | } | ||
476 | |||
477 | private CharSequence getExistsVariable(final String hostInstance) { | ||
478 | StringConcatenation _builder = new StringConcatenation(); | ||
479 | _builder.append(hostInstance); | ||
480 | _builder.append("_exists"); | ||
481 | return _builder; | ||
482 | } | ||
483 | |||
484 | private CharSequence getMemoryUsageVariable(final String hostInstance) { | ||
485 | StringConcatenation _builder = new StringConcatenation(); | ||
486 | _builder.append(hostInstance); | ||
487 | _builder.append("_mem"); | ||
488 | return _builder; | ||
489 | } | ||
490 | |||
491 | private CharSequence getHddUsageVariable(final String hostInstance) { | ||
492 | StringConcatenation _builder = new StringConcatenation(); | ||
493 | _builder.append(hostInstance); | ||
494 | _builder.append("_hdd"); | ||
495 | return _builder; | ||
496 | } | ||
497 | |||
498 | private CharSequence getAllocatedToVariable(final String appInstance, final String hostInstance) { | ||
499 | StringConcatenation _builder = new StringConcatenation(); | ||
500 | _builder.append(appInstance); | ||
501 | _builder.append("_to_"); | ||
502 | _builder.append(hostInstance); | ||
503 | return _builder; | ||
504 | } | ||
505 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.CpsStateCoder.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.CpsStateCoder.xtendbin deleted file mode 100644 index ee672cb1..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.CpsStateCoder.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.RuleBasedCpsMain.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.RuleBasedCpsMain.xtendbin deleted file mode 100644 index e58e8b6f..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.RuleBasedCpsMain.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.RuleBasedCpsSolver.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.RuleBasedCpsSolver.xtendbin deleted file mode 100644 index e29f2d71..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.RuleBasedCpsSolver.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.gitignore deleted file mode 100644 index 2338336b..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.gitignore +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | /.RuleBasedCpsSolver.java._trace | ||
2 | /.RuleBasedCpsMain.java._trace | ||
3 | /.CpsStateCoder.java._trace | ||
4 | /.CpsStateCoder.xtendbin | ||
5 | /.RuleBasedCpsMain.xtendbin | ||
6 | /.RuleBasedCpsSolver.xtendbin | ||
7 | /CpsStateCoder.java | ||
8 | /RuleBasedCpsMain.java | ||
9 | /RuleBasedCpsSolver.java | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.java deleted file mode 100644 index 3ae8e828..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.java +++ /dev/null | |||
@@ -1,316 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.dse; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.Request; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; | ||
10 | import java.util.Arrays; | ||
11 | import org.eclipse.emf.common.notify.Notifier; | ||
12 | import org.eclipse.emf.common.util.EList; | ||
13 | import org.eclipse.emf.ecore.EObject; | ||
14 | import org.eclipse.emf.ecore.resource.Resource; | ||
15 | import org.eclipse.emf.ecore.resource.ResourceSet; | ||
16 | import org.eclipse.viatra.dse.statecode.IStateCoder; | ||
17 | import org.eclipse.viatra.dse.statecode.IStateCoderFactory; | ||
18 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
19 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
20 | import org.eclipse.xtend2.lib.StringConcatenationClient; | ||
21 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
22 | |||
23 | @SuppressWarnings("all") | ||
24 | public class CpsStateCoder implements IStateCoder { | ||
25 | public static class Factory implements IStateCoderFactory { | ||
26 | @Override | ||
27 | public IStateCoder createStateCoder() { | ||
28 | return new CpsStateCoder(); | ||
29 | } | ||
30 | } | ||
31 | |||
32 | private CyberPhysicalSystem cps; | ||
33 | |||
34 | protected CpsStateCoder() { | ||
35 | } | ||
36 | |||
37 | @Override | ||
38 | public void init(final Notifier notifier) { | ||
39 | CyberPhysicalSystem _switchResult = null; | ||
40 | boolean _matched = false; | ||
41 | if (notifier instanceof ResourceSet) { | ||
42 | _matched=true; | ||
43 | _switchResult = this.getCpsFromResourceSet(((ResourceSet)notifier)); | ||
44 | } | ||
45 | if (!_matched) { | ||
46 | if (notifier instanceof Resource) { | ||
47 | _matched=true; | ||
48 | _switchResult = this.getCpsFromResource(((Resource)notifier)); | ||
49 | } | ||
50 | } | ||
51 | if (!_matched) { | ||
52 | if (notifier instanceof CyberPhysicalSystem) { | ||
53 | _matched=true; | ||
54 | _switchResult = ((CyberPhysicalSystem)notifier); | ||
55 | } | ||
56 | } | ||
57 | if (!_matched) { | ||
58 | throw new IllegalArgumentException("notifier is not a CyberPhysicalSystem"); | ||
59 | } | ||
60 | this.cps = _switchResult; | ||
61 | } | ||
62 | |||
63 | private CyberPhysicalSystem getCpsFromResourceSet(final ResourceSet resourceSet) { | ||
64 | CyberPhysicalSystem _xblockexpression = null; | ||
65 | { | ||
66 | boolean _isEmpty = resourceSet.getResources().isEmpty(); | ||
67 | if (_isEmpty) { | ||
68 | throw new IllegalArgumentException("No Resource in ResourceSet"); | ||
69 | } | ||
70 | final Resource resource = IterableExtensions.<Resource>head(resourceSet.getResources()); | ||
71 | _xblockexpression = this.getCpsFromResource(resource); | ||
72 | } | ||
73 | return _xblockexpression; | ||
74 | } | ||
75 | |||
76 | private CyberPhysicalSystem getCpsFromResource(final Resource resource) { | ||
77 | CyberPhysicalSystem _xblockexpression = null; | ||
78 | { | ||
79 | boolean _isEmpty = resource.getContents().isEmpty(); | ||
80 | if (_isEmpty) { | ||
81 | throw new IllegalArgumentException("No EObject in Resource"); | ||
82 | } | ||
83 | final EObject cps = IterableExtensions.<EObject>head(resource.getContents()); | ||
84 | CyberPhysicalSystem _xifexpression = null; | ||
85 | if ((cps instanceof CyberPhysicalSystem)) { | ||
86 | _xifexpression = ((CyberPhysicalSystem)cps); | ||
87 | } else { | ||
88 | throw new IllegalArgumentException("EObject in Resource is not a CyberPhysicalSystem"); | ||
89 | } | ||
90 | _xblockexpression = _xifexpression; | ||
91 | } | ||
92 | return _xblockexpression; | ||
93 | } | ||
94 | |||
95 | @Override | ||
96 | public String createStateCode() { | ||
97 | StringConcatenation _builder = new StringConcatenation(); | ||
98 | StringConcatenationClient _createRequestsCode = this.createRequestsCode(); | ||
99 | _builder.append(_createRequestsCode); | ||
100 | CharSequence _createHostTypesCode = this.createHostTypesCode(); | ||
101 | _builder.append(_createHostTypesCode); | ||
102 | return _builder.toString(); | ||
103 | } | ||
104 | |||
105 | private StringConcatenationClient createRequestsCode() { | ||
106 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
107 | @Override | ||
108 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
109 | { | ||
110 | EList<Request> _requests = CpsStateCoder.this.cps.getRequests(); | ||
111 | for(final Request request : _requests) { | ||
112 | StringConcatenationClient _createRequestCode = CpsStateCoder.this.createRequestCode(request); | ||
113 | _builder.append(_createRequestCode); | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | }; | ||
118 | return _client; | ||
119 | } | ||
120 | |||
121 | private StringConcatenationClient createRequestCode(final Request request) { | ||
122 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
123 | @Override | ||
124 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
125 | _builder.append("["); | ||
126 | { | ||
127 | EList<Requirement> _requirements = request.getRequirements(); | ||
128 | for(final Requirement requirement : _requirements) { | ||
129 | StringConcatenationClient _createRequirementCode = CpsStateCoder.this.createRequirementCode(requirement); | ||
130 | _builder.append(_createRequirementCode); | ||
131 | } | ||
132 | } | ||
133 | _builder.append("]"); | ||
134 | } | ||
135 | }; | ||
136 | return _client; | ||
137 | } | ||
138 | |||
139 | private StringConcatenationClient createRequirementCode(final Requirement requirement) { | ||
140 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
141 | @Override | ||
142 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
143 | _builder.append("["); | ||
144 | { | ||
145 | EList<ApplicationInstance> _instances = requirement.getInstances(); | ||
146 | boolean _hasElements = false; | ||
147 | for(final ApplicationInstance app : _instances) { | ||
148 | if (!_hasElements) { | ||
149 | _hasElements = true; | ||
150 | } else { | ||
151 | _builder.appendImmediate(",", ""); | ||
152 | } | ||
153 | String _createAppCode = CpsStateCoder.this.createAppCode(app); | ||
154 | _builder.append(_createAppCode); | ||
155 | } | ||
156 | } | ||
157 | _builder.append("]"); | ||
158 | } | ||
159 | }; | ||
160 | return _client; | ||
161 | } | ||
162 | |||
163 | private String createAppCode(final ApplicationInstance app) { | ||
164 | String _xifexpression = null; | ||
165 | HostInstance _allocatedTo = app.getAllocatedTo(); | ||
166 | boolean _tripleEquals = (_allocatedTo == null); | ||
167 | if (_tripleEquals) { | ||
168 | _xifexpression = "-"; | ||
169 | } else { | ||
170 | _xifexpression = this.createMatchArgumentCode(app.getAllocatedTo()); | ||
171 | } | ||
172 | return _xifexpression; | ||
173 | } | ||
174 | |||
175 | private CharSequence createHostTypesCode() { | ||
176 | StringConcatenation _builder = new StringConcatenation(); | ||
177 | _builder.append("("); | ||
178 | { | ||
179 | EList<HostType> _hostTypes = this.cps.getHostTypes(); | ||
180 | boolean _hasElements = false; | ||
181 | for(final HostType hostType : _hostTypes) { | ||
182 | if (!_hasElements) { | ||
183 | _hasElements = true; | ||
184 | } else { | ||
185 | _builder.appendImmediate(",", ""); | ||
186 | } | ||
187 | int _size = hostType.getInstances().size(); | ||
188 | _builder.append(_size); | ||
189 | } | ||
190 | } | ||
191 | _builder.append(")"); | ||
192 | return _builder; | ||
193 | } | ||
194 | |||
195 | @Override | ||
196 | public String createActivationCode(final IPatternMatch match) { | ||
197 | StringConcatenation _builder = new StringConcatenation(); | ||
198 | String _simpleName = match.specification().getSimpleName(); | ||
199 | _builder.append(_simpleName); | ||
200 | _builder.append("("); | ||
201 | { | ||
202 | Object[] _array = match.toArray(); | ||
203 | boolean _hasElements = false; | ||
204 | for(final Object arg : _array) { | ||
205 | if (!_hasElements) { | ||
206 | _hasElements = true; | ||
207 | } else { | ||
208 | _builder.appendImmediate(",", ""); | ||
209 | } | ||
210 | String _createMatchArgumentCode = this.createMatchArgumentCode(arg); | ||
211 | _builder.append(_createMatchArgumentCode); | ||
212 | } | ||
213 | } | ||
214 | _builder.append(")"); | ||
215 | return _builder.toString(); | ||
216 | } | ||
217 | |||
218 | protected String _createMatchArgumentCode(final Requirement requirement) { | ||
219 | String _xblockexpression = null; | ||
220 | { | ||
221 | final EObject request = requirement.eContainer(); | ||
222 | String _xifexpression = null; | ||
223 | if ((request instanceof Request)) { | ||
224 | String _xblockexpression_1 = null; | ||
225 | { | ||
226 | EObject _eContainer = ((Request)request).eContainer(); | ||
227 | boolean _notEquals = (!Objects.equal(_eContainer, this.cps)); | ||
228 | if (_notEquals) { | ||
229 | throw new IllegalArgumentException("Request is not contained in the CPS"); | ||
230 | } | ||
231 | final int requestIndex = this.cps.getRequests().indexOf(request); | ||
232 | final int requirementIndex = ((Request)request).getRequirements().indexOf(requirement); | ||
233 | String _plus = (Integer.valueOf(requestIndex) + "."); | ||
234 | _xblockexpression_1 = (_plus + Integer.valueOf(requirementIndex)); | ||
235 | } | ||
236 | _xifexpression = _xblockexpression_1; | ||
237 | } else { | ||
238 | throw new IllegalArgumentException("Requirement is not contained in a request"); | ||
239 | } | ||
240 | _xblockexpression = _xifexpression; | ||
241 | } | ||
242 | return _xblockexpression; | ||
243 | } | ||
244 | |||
245 | protected String _createMatchArgumentCode(final ApplicationInstance app) { | ||
246 | String _xblockexpression = null; | ||
247 | { | ||
248 | final Requirement requirement = app.getRequirement(); | ||
249 | if ((requirement == null)) { | ||
250 | throw new IllegalArgumentException("Application instance is not associated with a requirement"); | ||
251 | } | ||
252 | final int instanceIndex = requirement.getInstances().indexOf(app); | ||
253 | String _createMatchArgumentCode = this.createMatchArgumentCode(requirement); | ||
254 | String _plus = (_createMatchArgumentCode + "."); | ||
255 | _xblockexpression = (_plus + Integer.valueOf(instanceIndex)); | ||
256 | } | ||
257 | return _xblockexpression; | ||
258 | } | ||
259 | |||
260 | protected String _createMatchArgumentCode(final HostInstance host) { | ||
261 | String _xblockexpression = null; | ||
262 | { | ||
263 | final EObject hostType = host.eContainer(); | ||
264 | String _xifexpression = null; | ||
265 | if ((hostType instanceof HostType)) { | ||
266 | String _xblockexpression_1 = null; | ||
267 | { | ||
268 | final int hostIndex = ((HostType)hostType).getInstances().indexOf(host); | ||
269 | String _createMatchArgumentCode = this.createMatchArgumentCode(hostType); | ||
270 | String _plus = (_createMatchArgumentCode + "."); | ||
271 | _xblockexpression_1 = (_plus + Integer.valueOf(hostIndex)); | ||
272 | } | ||
273 | _xifexpression = _xblockexpression_1; | ||
274 | } else { | ||
275 | throw new IllegalArgumentException("Host is not contained in a host type"); | ||
276 | } | ||
277 | _xblockexpression = _xifexpression; | ||
278 | } | ||
279 | return _xblockexpression; | ||
280 | } | ||
281 | |||
282 | protected String _createMatchArgumentCode(final HostType hostType) { | ||
283 | String _xblockexpression = null; | ||
284 | { | ||
285 | EObject _eContainer = hostType.eContainer(); | ||
286 | boolean _notEquals = (!Objects.equal(_eContainer, this.cps)); | ||
287 | if (_notEquals) { | ||
288 | throw new IllegalArgumentException("Host type is not contained in the CPS"); | ||
289 | } | ||
290 | final int hostTypeIndex = this.cps.getHostTypes().indexOf(hostType); | ||
291 | _xblockexpression = Integer.valueOf(hostTypeIndex).toString(); | ||
292 | } | ||
293 | return _xblockexpression; | ||
294 | } | ||
295 | |||
296 | protected String _createMatchArgumentCode(final Object object) { | ||
297 | throw new IllegalArgumentException("Unknown match argument: "); | ||
298 | } | ||
299 | |||
300 | protected String createMatchArgumentCode(final Object app) { | ||
301 | if (app instanceof ApplicationInstance) { | ||
302 | return _createMatchArgumentCode((ApplicationInstance)app); | ||
303 | } else if (app instanceof HostInstance) { | ||
304 | return _createMatchArgumentCode((HostInstance)app); | ||
305 | } else if (app instanceof HostType) { | ||
306 | return _createMatchArgumentCode((HostType)app); | ||
307 | } else if (app instanceof Requirement) { | ||
308 | return _createMatchArgumentCode((Requirement)app); | ||
309 | } else if (app != null) { | ||
310 | return _createMatchArgumentCode(app); | ||
311 | } else { | ||
312 | throw new IllegalArgumentException("Unhandled parameter types: " + | ||
313 | Arrays.<Object>asList(app).toString()); | ||
314 | } | ||
315 | } | ||
316 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.java deleted file mode 100644 index 7d81f84b..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.java +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.dse; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.dse.RuleBasedCpsSolver; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.generator.CpsGenerator; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsQueries; | ||
8 | import java.util.Map; | ||
9 | import org.eclipse.emf.ecore.EPackage; | ||
10 | import org.eclipse.emf.ecore.EStructuralFeature; | ||
11 | import org.eclipse.emf.ecore.resource.Resource; | ||
12 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; | ||
13 | import org.eclipse.viatra.addon.querybasedfeatures.runtime.QueryBasedFeatureSettingDelegateFactory; | ||
14 | import org.eclipse.viatra.addon.querybasedfeatures.runtime.handler.QueryBasedFeatures; | ||
15 | import org.eclipse.viatra.dse.api.DesignSpaceExplorer; | ||
16 | import org.eclipse.viatra.query.runtime.extensibility.SingletonQueryGroupProvider; | ||
17 | import org.eclipse.viatra.query.runtime.registry.IQuerySpecificationRegistry; | ||
18 | import org.eclipse.viatra.query.runtime.registry.QuerySpecificationRegistry; | ||
19 | import org.eclipse.viatra.query.runtime.registry.connector.QueryGroupProviderSourceConnector; | ||
20 | |||
21 | @SuppressWarnings("all") | ||
22 | public class RuleBasedCpsMain { | ||
23 | private RuleBasedCpsMain() { | ||
24 | new IllegalStateException("This is a static utility class and should not be instantiated directly."); | ||
25 | } | ||
26 | |||
27 | public static void main(final String[] args) { | ||
28 | DesignSpaceExplorer.turnOnLogging(DesignSpaceExplorer.DseLoggingLevel.VERBOSE_FULL); | ||
29 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | ||
30 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | ||
31 | _extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, _xMIResourceFactoryImpl); | ||
32 | QueryBasedFeatureSettingDelegateFactory _queryBasedFeatureSettingDelegateFactory = new QueryBasedFeatureSettingDelegateFactory(); | ||
33 | EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put(QueryBasedFeatures.ANNOTATION_SOURCE, _queryBasedFeatureSettingDelegateFactory); | ||
34 | EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, CpsPackage.eINSTANCE); | ||
35 | IQuerySpecificationRegistry _instance = QuerySpecificationRegistry.getInstance(); | ||
36 | CpsQueries _instance_1 = CpsQueries.instance(); | ||
37 | SingletonQueryGroupProvider _singletonQueryGroupProvider = new SingletonQueryGroupProvider(_instance_1); | ||
38 | QueryGroupProviderSourceConnector _queryGroupProviderSourceConnector = new QueryGroupProviderSourceConnector("CpsQueries", _singletonQueryGroupProvider, | ||
39 | true); | ||
40 | _instance.addSource(_queryGroupProviderSourceConnector); | ||
41 | final CpsGenerator generator = new CpsGenerator(1, 4, 1); | ||
42 | final CyberPhysicalSystem problem = generator.generateCpsProblem(); | ||
43 | final RuleBasedCpsSolver solver = new RuleBasedCpsSolver(); | ||
44 | solver.solve(problem); | ||
45 | } | ||
46 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.java deleted file mode 100644 index fd348752..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.java +++ /dev/null | |||
@@ -1,93 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.dse; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.dse.CpsStateCoder; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate; | ||
10 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric; | ||
11 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric; | ||
12 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric; | ||
13 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance; | ||
14 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective; | ||
15 | import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied; | ||
16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CompositeDirectionalThresholdObjective; | ||
17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind; | ||
18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold; | ||
19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.QueryBasedObjective; | ||
20 | import java.util.Collection; | ||
21 | import java.util.function.Consumer; | ||
22 | import org.eclipse.emf.common.util.EList; | ||
23 | import org.eclipse.viatra.dse.api.DesignSpaceExplorer; | ||
24 | import org.eclipse.viatra.dse.api.Solution; | ||
25 | import org.eclipse.viatra.dse.evolutionary.EvolutionaryStrategy; | ||
26 | import org.eclipse.viatra.dse.evolutionary.EvolutionaryStrategyBuilder; | ||
27 | import org.eclipse.viatra.dse.objectives.Fitness; | ||
28 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRuleFactory; | ||
29 | import org.eclipse.xtext.xbase.lib.Extension; | ||
30 | import org.eclipse.xtext.xbase.lib.InputOutput; | ||
31 | |||
32 | @SuppressWarnings("all") | ||
33 | public class RuleBasedCpsSolver { | ||
34 | @Extension | ||
35 | private final BatchTransformationRuleFactory _batchTransformationRuleFactory = new BatchTransformationRuleFactory(); | ||
36 | |||
37 | @Extension | ||
38 | private final CpsFactory _cpsFactory = CpsFactory.eINSTANCE; | ||
39 | |||
40 | public void solve(final CyberPhysicalSystem problem) { | ||
41 | final DesignSpaceExplorer dse = new DesignSpaceExplorer(); | ||
42 | dse.addMetaModelPackage(CpsPackage.eINSTANCE); | ||
43 | dse.setInitialModel(problem.eResource().getResourceSet()); | ||
44 | final Consumer<RequirementNotSatisfied.Match> _function = (RequirementNotSatisfied.Match it) -> { | ||
45 | final ApplicationInstance app = this._cpsFactory.createApplicationInstance(); | ||
46 | EList<ApplicationInstance> _instances = it.getReq().getType().getInstances(); | ||
47 | _instances.add(app); | ||
48 | EList<ApplicationInstance> _instances_1 = it.getReq().getInstances(); | ||
49 | _instances_1.add(app); | ||
50 | }; | ||
51 | dse.addTransformationRule(this._batchTransformationRuleFactory.<RequirementNotSatisfied.Match, RequirementNotSatisfied.Matcher>createRule(RequirementNotSatisfied.instance()).action(_function).build()); | ||
52 | final Consumer<Allocate.Match> _function_1 = (Allocate.Match it) -> { | ||
53 | ApplicationInstance _app = it.getApp(); | ||
54 | _app.setAllocatedTo(it.getHost()); | ||
55 | }; | ||
56 | dse.addTransformationRule(this._batchTransformationRuleFactory.<Allocate.Match, Allocate.Matcher>createRule(Allocate.instance()).action(_function_1).build()); | ||
57 | final Consumer<CreateHostInstance.Match> _function_2 = (CreateHostInstance.Match it) -> { | ||
58 | EList<HostInstance> _instances = it.getHostType().getInstances(); | ||
59 | HostInstance _createHostInstance = this._cpsFactory.createHostInstance(); | ||
60 | _instances.add(_createHostInstance); | ||
61 | }; | ||
62 | dse.addTransformationRule(this._batchTransformationRuleFactory.<CreateHostInstance.Match, CreateHostInstance.Matcher>createRule(CreateHostInstance.instance()).action(_function_2).build()); | ||
63 | GuidanceObjective _instance = GuidanceObjective.instance(); | ||
64 | ObjectiveThreshold.Inclusive _inclusive = new ObjectiveThreshold.Inclusive(0); | ||
65 | QueryBasedObjective _queryBasedObjective = new QueryBasedObjective(_instance, ObjectiveKind.LOWER_IS_BETTER, _inclusive, 0); | ||
66 | AverageFreeMemoryMetric _instance_1 = AverageFreeMemoryMetric.instance(); | ||
67 | ObjectiveThreshold.Inclusive _inclusive_1 = new ObjectiveThreshold.Inclusive(0.75); | ||
68 | QueryBasedObjective _queryBasedObjective_1 = new QueryBasedObjective(_instance_1, ObjectiveKind.LOWER_IS_BETTER, _inclusive_1, 0); | ||
69 | AverageFreeHddMetric _instance_2 = AverageFreeHddMetric.instance(); | ||
70 | ObjectiveThreshold.Inclusive _inclusive_2 = new ObjectiveThreshold.Inclusive(0.75); | ||
71 | QueryBasedObjective _queryBasedObjective_2 = new QueryBasedObjective(_instance_2, ObjectiveKind.LOWER_IS_BETTER, _inclusive_2, 0); | ||
72 | CompositeDirectionalThresholdObjective _compositeDirectionalThresholdObjective = new CompositeDirectionalThresholdObjective("Composite", _queryBasedObjective, _queryBasedObjective_1, _queryBasedObjective_2); | ||
73 | dse.addObjective(_compositeDirectionalThresholdObjective); | ||
74 | CostMetric _instance_3 = CostMetric.instance(); | ||
75 | QueryBasedObjective _queryBasedObjective_3 = new QueryBasedObjective(_instance_3, ObjectiveKind.LOWER_IS_BETTER, | ||
76 | ObjectiveThreshold.NO_THRESHOLD, 0); | ||
77 | dse.addObjective(_queryBasedObjective_3); | ||
78 | dse.setMaxNumberOfThreads(1); | ||
79 | CpsStateCoder.Factory _factory = new CpsStateCoder.Factory(); | ||
80 | dse.setStateCoderFactory(_factory); | ||
81 | final EvolutionaryStrategy strategy = EvolutionaryStrategyBuilder.createNsga2Strategy(25); | ||
82 | dse.startExplorationWithTimeout(strategy, ((2 * 60) * 1000)); | ||
83 | Collection<Solution> _solutions = dse.getSolutions(); | ||
84 | for (final Solution solution : _solutions) { | ||
85 | Object _stateCode = solution.getStateCode(); | ||
86 | String _plus = ("Found solution: " + _stateCode); | ||
87 | String _plus_1 = (_plus + " "); | ||
88 | Fitness _fitness = solution.getArbitraryTrajectory().getFitness(); | ||
89 | String _plus_2 = (_plus_1 + _fitness); | ||
90 | InputOutput.<String>println(_plus_2); | ||
91 | } | ||
92 | } | ||
93 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/.CpsGenerator.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/.CpsGenerator.xtendbin deleted file mode 100644 index 42bebd02..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/.CpsGenerator.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/.gitignore deleted file mode 100644 index 716ffd30..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/.gitignore +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | /.CpsGenerator.java._trace | ||
2 | /.CpsGenerator.xtendbin | ||
3 | /CpsGenerator.java | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.java deleted file mode 100644 index ce0cd02d..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.java +++ /dev/null | |||
@@ -1,177 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.generator; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.Request; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; | ||
10 | import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; | ||
11 | import java.util.Collection; | ||
12 | import java.util.Collections; | ||
13 | import java.util.List; | ||
14 | import java.util.Random; | ||
15 | import org.eclipse.emf.common.util.EList; | ||
16 | import org.eclipse.emf.common.util.URI; | ||
17 | import org.eclipse.emf.ecore.EObject; | ||
18 | import org.eclipse.emf.ecore.resource.Resource; | ||
19 | import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; | ||
20 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
21 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; | ||
22 | import org.eclipse.xtext.xbase.lib.Extension; | ||
23 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; | ||
24 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | ||
25 | |||
26 | @SuppressWarnings("all") | ||
27 | public class CpsGenerator { | ||
28 | @Extension | ||
29 | private final CpsFactory _cpsFactory = CpsFactory.eINSTANCE; | ||
30 | |||
31 | private static final int MIN_MEMORY = 1; | ||
32 | |||
33 | private static final int MAX_MEMORY = 6; | ||
34 | |||
35 | private static final int MIN_HDD = 1; | ||
36 | |||
37 | private static final int MAX_HDD = 30; | ||
38 | |||
39 | private static final int HIGH_CPU_FRACTION = 4; | ||
40 | |||
41 | private static final int MIN_REPLICAS = 1; | ||
42 | |||
43 | private static final int MAX_REPLICAS = 4; | ||
44 | |||
45 | private final Random random; | ||
46 | |||
47 | private final int applicationTypeCount; | ||
48 | |||
49 | private final int demandFactor; | ||
50 | |||
51 | private final boolean populateAppInstances; | ||
52 | |||
53 | public CpsGenerator(final long randomSeed, final int applicationTypeCount, final int demandFactor) { | ||
54 | this(randomSeed, applicationTypeCount, demandFactor, false); | ||
55 | } | ||
56 | |||
57 | public CpsGenerator(final long randomSeed, final int applicationTypeCount, final int demandFactor, final boolean populateAppInstances) { | ||
58 | Random _random = new Random(randomSeed); | ||
59 | this.random = _random; | ||
60 | this.applicationTypeCount = applicationTypeCount; | ||
61 | this.demandFactor = demandFactor; | ||
62 | this.populateAppInstances = populateAppInstances; | ||
63 | } | ||
64 | |||
65 | public CyberPhysicalSystem generateCpsProblem() { | ||
66 | CyberPhysicalSystem _xblockexpression = null; | ||
67 | { | ||
68 | final ResourceSetImpl resourceSet = new ResourceSetImpl(); | ||
69 | final Resource resource = resourceSet.createResource(URI.createFileURI("dummy.dummyext")); | ||
70 | CyberPhysicalSystem _createCyberPhysicalSystem = this._cpsFactory.createCyberPhysicalSystem(); | ||
71 | final Procedure1<CyberPhysicalSystem> _function = (CyberPhysicalSystem it) -> { | ||
72 | final CyberPhysicalSystem cps = it; | ||
73 | EList<EObject> _contents = resource.getContents(); | ||
74 | _contents.add(cps); | ||
75 | this.createLowCpuHostTypes(it); | ||
76 | final List<HostType> highCpuHostTypes = this.createHighCpuHostTypes(it); | ||
77 | for (int i = 0; (i < this.applicationTypeCount); i++) { | ||
78 | if (((i % CpsGenerator.HIGH_CPU_FRACTION) == 0)) { | ||
79 | this.createRandomApplicationType(it, highCpuHostTypes); | ||
80 | } else { | ||
81 | this.createRandomApplicationType(it, it.getHostTypes()); | ||
82 | } | ||
83 | } | ||
84 | for (int i = 0; (i < this.demandFactor); i++) { | ||
85 | EList<Request> _requests = it.getRequests(); | ||
86 | Request _createRequest = this._cpsFactory.createRequest(); | ||
87 | final Procedure1<Request> _function_1 = (Request it_1) -> { | ||
88 | EList<ApplicationType> _applicationTypes = cps.getApplicationTypes(); | ||
89 | for (final ApplicationType appType : _applicationTypes) { | ||
90 | EList<Requirement> _requirements = it_1.getRequirements(); | ||
91 | Requirement _createRequirement = this._cpsFactory.createRequirement(); | ||
92 | final Procedure1<Requirement> _function_2 = (Requirement it_2) -> { | ||
93 | it_2.setCount(this.nextInt(CpsGenerator.MIN_REPLICAS, CpsGenerator.MAX_REPLICAS)); | ||
94 | it_2.setType(appType); | ||
95 | if (this.populateAppInstances) { | ||
96 | int _count = it_2.getCount(); | ||
97 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _count, true); | ||
98 | for (final Integer j : _doubleDotLessThan) { | ||
99 | { | ||
100 | final ApplicationInstance app = this._cpsFactory.createApplicationInstance(); | ||
101 | app.setType(appType); | ||
102 | EList<ApplicationInstance> _instances = appType.getInstances(); | ||
103 | _instances.add(app); | ||
104 | EList<ApplicationInstance> _instances_1 = it_2.getInstances(); | ||
105 | _instances_1.add(app); | ||
106 | } | ||
107 | } | ||
108 | } | ||
109 | }; | ||
110 | Requirement _doubleArrow = ObjectExtensions.<Requirement>operator_doubleArrow(_createRequirement, _function_2); | ||
111 | _requirements.add(_doubleArrow); | ||
112 | } | ||
113 | }; | ||
114 | Request _doubleArrow = ObjectExtensions.<Request>operator_doubleArrow(_createRequest, _function_1); | ||
115 | _requests.add(_doubleArrow); | ||
116 | } | ||
117 | }; | ||
118 | _xblockexpression = ObjectExtensions.<CyberPhysicalSystem>operator_doubleArrow(_createCyberPhysicalSystem, _function); | ||
119 | } | ||
120 | return _xblockexpression; | ||
121 | } | ||
122 | |||
123 | private void createRandomApplicationType(final CyberPhysicalSystem it, final Collection<HostType> allowedHostTypes) { | ||
124 | final ApplicationType appType = this._cpsFactory.createApplicationType(); | ||
125 | final int memory = this.nextInt(CpsGenerator.MIN_MEMORY, CpsGenerator.MAX_MEMORY); | ||
126 | final int hdd = this.nextInt(CpsGenerator.MIN_HDD, CpsGenerator.MAX_HDD); | ||
127 | for (final HostType hostType : allowedHostTypes) { | ||
128 | EList<ResourceRequirement> _requirements = appType.getRequirements(); | ||
129 | ResourceRequirement _createResourceRequirement = this._cpsFactory.createResourceRequirement(); | ||
130 | final Procedure1<ResourceRequirement> _function = (ResourceRequirement it_1) -> { | ||
131 | it_1.setHostType(hostType); | ||
132 | it_1.setRequiredMemory(memory); | ||
133 | it_1.setRequiredHdd(hdd); | ||
134 | }; | ||
135 | ResourceRequirement _doubleArrow = ObjectExtensions.<ResourceRequirement>operator_doubleArrow(_createResourceRequirement, _function); | ||
136 | _requirements.add(_doubleArrow); | ||
137 | } | ||
138 | EList<ApplicationType> _applicationTypes = it.getApplicationTypes(); | ||
139 | _applicationTypes.add(appType); | ||
140 | } | ||
141 | |||
142 | private List<HostType> createLowCpuHostTypes(final CyberPhysicalSystem it) { | ||
143 | HostType _createHostType = this.createHostType(it, 2, 8, 75); | ||
144 | HostType _createHostType_1 = this.createHostType(it, 4, 16, 150); | ||
145 | HostType _createHostType_2 = this.createHostType(it, 3, 16, 75); | ||
146 | HostType _createHostType_3 = this.createHostType(it, 6, 32, 150); | ||
147 | return Collections.<HostType>unmodifiableList(CollectionLiterals.<HostType>newArrayList(_createHostType, _createHostType_1, _createHostType_2, _createHostType_3)); | ||
148 | } | ||
149 | |||
150 | private List<HostType> createHighCpuHostTypes(final CyberPhysicalSystem it) { | ||
151 | HostType _createHostType = this.createHostType(it, 2, 4, 50); | ||
152 | HostType _createHostType_1 = this.createHostType(it, 4, 8, 100); | ||
153 | return Collections.<HostType>unmodifiableList(CollectionLiterals.<HostType>newArrayList(_createHostType, _createHostType_1)); | ||
154 | } | ||
155 | |||
156 | private HostType createHostType(final CyberPhysicalSystem it, final int cost, final int memory, final int hdd) { | ||
157 | HostType _xblockexpression = null; | ||
158 | { | ||
159 | HostType _createHostType = this._cpsFactory.createHostType(); | ||
160 | final Procedure1<HostType> _function = (HostType it_1) -> { | ||
161 | it_1.setCost(cost); | ||
162 | it_1.setDefaultMemory(memory); | ||
163 | it_1.setDefaultHdd(hdd); | ||
164 | }; | ||
165 | final HostType hostType = ObjectExtensions.<HostType>operator_doubleArrow(_createHostType, _function); | ||
166 | EList<HostType> _hostTypes = it.getHostTypes(); | ||
167 | _hostTypes.add(hostType); | ||
168 | _xblockexpression = hostType; | ||
169 | } | ||
170 | return _xblockexpression; | ||
171 | } | ||
172 | |||
173 | private int nextInt(final int lower, final int upper) { | ||
174 | int _nextInt = this.random.nextInt(((upper - lower) + 1)); | ||
175 | return (lower + _nextInt); | ||
176 | } | ||
177 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.CpsMdeOptimiserMain.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.CpsMdeOptimiserMain.xtendbin deleted file mode 100644 index b9f0df1a..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.CpsMdeOptimiserMain.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.NonRedundantAllocationsConstraint.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.NonRedundantAllocationsConstraint.xtendbin deleted file mode 100644 index 86913d04..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.NonRedundantAllocationsConstraint.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.NotAllocatedAppInstancesConstraint.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.NotAllocatedAppInstancesConstraint.xtendbin deleted file mode 100644 index fd33b1a1..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.NotAllocatedAppInstancesConstraint.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.NotSatisfiedRequirementsConstraint.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.NotSatisfiedRequirementsConstraint.xtendbin deleted file mode 100644 index cc5c52dd..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.NotSatisfiedRequirementsConstraint.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.ResourceUtilizationUtil.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.ResourceUtilizationUtil.xtendbin deleted file mode 100644 index a80b5bc3..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.ResourceUtilizationUtil.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.TooLowAverageHddConstraint.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.TooLowAverageHddConstraint.xtendbin deleted file mode 100644 index 24309a53..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.TooLowAverageHddConstraint.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.TooLowAverageMemoryConstraint.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.TooLowAverageMemoryConstraint.xtendbin deleted file mode 100644 index 86af43db..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.TooLowAverageMemoryConstraint.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.TotalCostFitnessFunction.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.TotalCostFitnessFunction.xtendbin deleted file mode 100644 index f37b1a5c..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.TotalCostFitnessFunction.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.UnavailableHddConstraint.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.UnavailableHddConstraint.xtendbin deleted file mode 100644 index eeef5142..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.UnavailableHddConstraint.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.UnavailableMemoryConstraint.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.UnavailableMemoryConstraint.xtendbin deleted file mode 100644 index dd11fbd5..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.UnavailableMemoryConstraint.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.gitignore deleted file mode 100644 index 51a2537b..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/.gitignore +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | /.TotalCostFitnessFunction.java._trace | ||
2 | /.CpsMdeOptimiserMain.java._trace | ||
3 | /.ExcludedOptimisationInterpreter.java._trace | ||
4 | /.ExcludedMoeaOptimisation.java._trace | ||
5 | /.ExcludedRun.java._trace | ||
6 | /.SatisfiedRequirementsConstraint.java._trace | ||
7 | /.NotSatisfiedRequirementsConstraint.java._trace | ||
8 | /.NotAllocatedAppInstancesConstraint.java._trace | ||
9 | /.NonRedundantAllocationsConstraint.java._trace | ||
10 | /.UnavailableMemoryConstraint.java._trace | ||
11 | /.ResourceUtilizationUtil.java._trace | ||
12 | /.UnavailableHddConstraint.java._trace | ||
13 | /.TooLowAverageMemoryConstraint.java._trace | ||
14 | /.TooLowAverageHddUtilization.java._trace | ||
15 | /.TooLowAverageHddConstraint.java._trace | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/CpsMdeOptimiserMain.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/CpsMdeOptimiserMain.java deleted file mode 100644 index c047f255..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/CpsMdeOptimiserMain.java +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.generator.CpsGenerator; | ||
6 | import java.io.BufferedReader; | ||
7 | import java.io.BufferedWriter; | ||
8 | import java.io.FileReader; | ||
9 | import java.io.FileWriter; | ||
10 | import java.util.Collections; | ||
11 | import java.util.Map; | ||
12 | import java.util.Set; | ||
13 | import org.eclipse.emf.common.util.URI; | ||
14 | import org.eclipse.emf.ecore.EPackage; | ||
15 | import org.eclipse.emf.ecore.resource.Resource; | ||
16 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; | ||
17 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
18 | import org.eclipse.xtext.xbase.lib.Exceptions; | ||
19 | import org.eclipse.xtext.xbase.lib.Pair; | ||
20 | import uk.ac.kcl.inf.mdeoptimiser.interfaces.cli.Run; | ||
21 | |||
22 | @SuppressWarnings("all") | ||
23 | public class CpsMdeOptimiserMain { | ||
24 | private static final String PROJECT_PATH = "."; | ||
25 | |||
26 | private static final String PROBLEM_PATH = "model/problem.xmi"; | ||
27 | |||
28 | private static final String MOPT_PATH = "src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/cps.mopt"; | ||
29 | |||
30 | private CpsMdeOptimiserMain() { | ||
31 | new IllegalStateException("This is a static utility class and should not be instantiated directly."); | ||
32 | } | ||
33 | |||
34 | public static void main(final String[] args) { | ||
35 | try { | ||
36 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | ||
37 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | ||
38 | _extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, _xMIResourceFactoryImpl); | ||
39 | EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, CpsPackage.eINSTANCE); | ||
40 | final CpsGenerator generator = new CpsGenerator(1, 4, 1); | ||
41 | final CyberPhysicalSystem problem = generator.generateCpsProblem(); | ||
42 | Resource _eResource = problem.eResource(); | ||
43 | _eResource.setURI(URI.createFileURI(CpsMdeOptimiserMain.PROBLEM_PATH)); | ||
44 | problem.eResource().save(CollectionLiterals.<Object, Object>emptyMap()); | ||
45 | Pair<String, String> _mappedTo = Pair.<String, String>of("cps.ecore", CpsPackage.eNS_URI); | ||
46 | CpsMdeOptimiserMain.fixupHenshinModel("model/cps.henshin", "model/cps_fixup.henshin", Collections.<String, String>unmodifiableMap(CollectionLiterals.<String, String>newHashMap(_mappedTo))); | ||
47 | Run.main(new String[] { "-p", CpsMdeOptimiserMain.PROJECT_PATH, "-m", CpsMdeOptimiserMain.MOPT_PATH }); | ||
48 | } catch (Throwable _e) { | ||
49 | throw Exceptions.sneakyThrow(_e); | ||
50 | } | ||
51 | } | ||
52 | |||
53 | private static void fixupHenshinModel(final String originalPath, final String outputPath, final Map<String, String> remapMap) { | ||
54 | try { | ||
55 | FileReader _fileReader = new FileReader(originalPath); | ||
56 | final BufferedReader reader = new BufferedReader(_fileReader); | ||
57 | try { | ||
58 | FileWriter _fileWriter = new FileWriter(outputPath); | ||
59 | final BufferedWriter writer = new BufferedWriter(_fileWriter); | ||
60 | try { | ||
61 | String line = null; | ||
62 | while (((line = reader.readLine()) != null)) { | ||
63 | { | ||
64 | Set<Map.Entry<String, String>> _entrySet = remapMap.entrySet(); | ||
65 | for (final Map.Entry<String, String> entry : _entrySet) { | ||
66 | line = line.replace(entry.getKey(), entry.getValue()); | ||
67 | } | ||
68 | writer.write(line); | ||
69 | writer.write("\n"); | ||
70 | } | ||
71 | } | ||
72 | } finally { | ||
73 | writer.close(); | ||
74 | } | ||
75 | } finally { | ||
76 | reader.close(); | ||
77 | } | ||
78 | } catch (Throwable _e) { | ||
79 | throw Exceptions.sneakyThrow(_e); | ||
80 | } | ||
81 | } | ||
82 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NonRedundantAllocationsConstraint.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NonRedundantAllocationsConstraint.java deleted file mode 100644 index 6100d821..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NonRedundantAllocationsConstraint.java +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo; | ||
2 | |||
3 | import com.google.common.collect.HashMultiset; | ||
4 | import com.google.common.collect.Multiset; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.common.util.EList; | ||
12 | import org.eclipse.emf.ecore.EObject; | ||
13 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction; | ||
14 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution; | ||
15 | |||
16 | @SuppressWarnings("all") | ||
17 | public class NonRedundantAllocationsConstraint implements IGuidanceFunction { | ||
18 | @Override | ||
19 | public String getName() { | ||
20 | return "NonRedundantAllocations"; | ||
21 | } | ||
22 | |||
23 | @Override | ||
24 | public double computeFitness(final Solution solution) { | ||
25 | int _xblockexpression = (int) 0; | ||
26 | { | ||
27 | EObject _model = solution.getModel(); | ||
28 | final CyberPhysicalSystem cps = ((CyberPhysicalSystem) _model); | ||
29 | int cost = 0; | ||
30 | EList<HostType> _hostTypes = cps.getHostTypes(); | ||
31 | for (final HostType hostType : _hostTypes) { | ||
32 | EList<HostInstance> _instances = hostType.getInstances(); | ||
33 | for (final HostInstance host : _instances) { | ||
34 | { | ||
35 | final HashMultiset<Requirement> bins = HashMultiset.<Requirement>create(); | ||
36 | EList<ApplicationInstance> _applications = host.getApplications(); | ||
37 | for (final ApplicationInstance app : _applications) { | ||
38 | bins.add(app.getRequirement()); | ||
39 | } | ||
40 | Set<Multiset.Entry<Requirement>> _entrySet = bins.entrySet(); | ||
41 | for (final Multiset.Entry<Requirement> entry : _entrySet) { | ||
42 | int _cost = cost; | ||
43 | int _count = entry.getCount(); | ||
44 | int _minus = (_count - 1); | ||
45 | cost = (_cost + _minus); | ||
46 | } | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | _xblockexpression = cost; | ||
51 | } | ||
52 | return _xblockexpression; | ||
53 | } | ||
54 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NotAllocatedAppInstancesConstraint.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NotAllocatedAppInstancesConstraint.java deleted file mode 100644 index e9ade5de..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NotAllocatedAppInstancesConstraint.java +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; | ||
9 | import org.eclipse.emf.common.util.EList; | ||
10 | import org.eclipse.emf.ecore.EObject; | ||
11 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
12 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
13 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction; | ||
14 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution; | ||
15 | |||
16 | @SuppressWarnings("all") | ||
17 | public class NotAllocatedAppInstancesConstraint implements IGuidanceFunction { | ||
18 | @Override | ||
19 | public String getName() { | ||
20 | return "NotAllocatedAppInstances"; | ||
21 | } | ||
22 | |||
23 | @Override | ||
24 | public double computeFitness(final Solution solution) { | ||
25 | int _xblockexpression = (int) 0; | ||
26 | { | ||
27 | EObject _model = solution.getModel(); | ||
28 | final CyberPhysicalSystem cps = ((CyberPhysicalSystem) _model); | ||
29 | int cost = 0; | ||
30 | EList<ApplicationType> _applicationTypes = cps.getApplicationTypes(); | ||
31 | for (final ApplicationType appType : _applicationTypes) { | ||
32 | EList<ApplicationInstance> _instances = appType.getInstances(); | ||
33 | for (final ApplicationInstance app : _instances) { | ||
34 | if (((app.getAllocatedTo() == null) || (!IterableExtensions.<ResourceRequirement>exists(appType.getRequirements(), ((Function1<ResourceRequirement, Boolean>) (ResourceRequirement it) -> { | ||
35 | HostType _hostType = it.getHostType(); | ||
36 | HostType _type = app.getAllocatedTo().getType(); | ||
37 | return Boolean.valueOf(Objects.equal(_hostType, _type)); | ||
38 | }))))) { | ||
39 | cost++; | ||
40 | } | ||
41 | } | ||
42 | } | ||
43 | _xblockexpression = cost; | ||
44 | } | ||
45 | return _xblockexpression; | ||
46 | } | ||
47 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NotSatisfiedRequirementsConstraint.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NotSatisfiedRequirementsConstraint.java deleted file mode 100644 index 34f73952..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NotSatisfiedRequirementsConstraint.java +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.Request; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; | ||
9 | import org.eclipse.emf.common.util.EList; | ||
10 | import org.eclipse.emf.ecore.EObject; | ||
11 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction; | ||
12 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution; | ||
13 | |||
14 | @SuppressWarnings("all") | ||
15 | public class NotSatisfiedRequirementsConstraint implements IGuidanceFunction { | ||
16 | @Override | ||
17 | public String getName() { | ||
18 | return "NotSatisfiedRequirements"; | ||
19 | } | ||
20 | |||
21 | @Override | ||
22 | public double computeFitness(final Solution solution) { | ||
23 | int _xblockexpression = (int) 0; | ||
24 | { | ||
25 | EObject _model = solution.getModel(); | ||
26 | final CyberPhysicalSystem cps = ((CyberPhysicalSystem) _model); | ||
27 | int cost = 0; | ||
28 | EList<Request> _requests = cps.getRequests(); | ||
29 | for (final Request request : _requests) { | ||
30 | EList<Requirement> _requirements = request.getRequirements(); | ||
31 | for (final Requirement requirement : _requirements) { | ||
32 | { | ||
33 | int _cost = cost; | ||
34 | int _count = requirement.getCount(); | ||
35 | int _size = requirement.getInstances().size(); | ||
36 | int _minus = (_count - _size); | ||
37 | int _abs = Math.abs(_minus); | ||
38 | cost = (_cost + _abs); | ||
39 | EList<ApplicationInstance> _instances = requirement.getInstances(); | ||
40 | for (final ApplicationInstance app : _instances) { | ||
41 | ApplicationType _type = app.getType(); | ||
42 | ApplicationType _type_1 = requirement.getType(); | ||
43 | boolean _notEquals = (!Objects.equal(_type, _type_1)); | ||
44 | if (_notEquals) { | ||
45 | cost++; | ||
46 | } | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | } | ||
51 | _xblockexpression = cost; | ||
52 | } | ||
53 | return _xblockexpression; | ||
54 | } | ||
55 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/ResourceUtilizationUtil.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/ResourceUtilizationUtil.java deleted file mode 100644 index a03213e3..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/ResourceUtilizationUtil.java +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; | ||
8 | import org.eclipse.emf.common.util.EList; | ||
9 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
10 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
11 | |||
12 | @SuppressWarnings("all") | ||
13 | public class ResourceUtilizationUtil { | ||
14 | private ResourceUtilizationUtil() { | ||
15 | new IllegalStateException("This is a static utility class and should not be instantiated directly."); | ||
16 | } | ||
17 | |||
18 | public static int getMemoryUtilization(final HostInstance host) { | ||
19 | int _xblockexpression = (int) 0; | ||
20 | { | ||
21 | int utilization = 0; | ||
22 | EList<ApplicationInstance> _applications = host.getApplications(); | ||
23 | for (final ApplicationInstance app : _applications) { | ||
24 | { | ||
25 | final Function1<ResourceRequirement, Boolean> _function = (ResourceRequirement it) -> { | ||
26 | HostType _hostType = it.getHostType(); | ||
27 | HostType _type = host.getType(); | ||
28 | return Boolean.valueOf(Objects.equal(_hostType, _type)); | ||
29 | }; | ||
30 | final ResourceRequirement req = IterableExtensions.<ResourceRequirement>findFirst(app.getType().getRequirements(), _function); | ||
31 | if ((req != null)) { | ||
32 | int _utilization = utilization; | ||
33 | int _requiredMemory = req.getRequiredMemory(); | ||
34 | utilization = (_utilization + _requiredMemory); | ||
35 | } | ||
36 | } | ||
37 | } | ||
38 | _xblockexpression = utilization; | ||
39 | } | ||
40 | return _xblockexpression; | ||
41 | } | ||
42 | |||
43 | public static int getHddUtilization(final HostInstance host) { | ||
44 | int _xblockexpression = (int) 0; | ||
45 | { | ||
46 | int utilization = 0; | ||
47 | EList<ApplicationInstance> _applications = host.getApplications(); | ||
48 | for (final ApplicationInstance app : _applications) { | ||
49 | { | ||
50 | final Function1<ResourceRequirement, Boolean> _function = (ResourceRequirement it) -> { | ||
51 | HostType _hostType = it.getHostType(); | ||
52 | HostType _type = host.getType(); | ||
53 | return Boolean.valueOf(Objects.equal(_hostType, _type)); | ||
54 | }; | ||
55 | final ResourceRequirement req = IterableExtensions.<ResourceRequirement>findFirst(app.getType().getRequirements(), _function); | ||
56 | if ((req != null)) { | ||
57 | int _utilization = utilization; | ||
58 | int _requiredHdd = req.getRequiredHdd(); | ||
59 | utilization = (_utilization + _requiredHdd); | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | _xblockexpression = utilization; | ||
64 | } | ||
65 | return _xblockexpression; | ||
66 | } | ||
67 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageHddConstraint.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageHddConstraint.java deleted file mode 100644 index 0ff3c795..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageHddConstraint.java +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.mdeo.ResourceUtilizationUtil; | ||
7 | import org.eclipse.emf.common.util.EList; | ||
8 | import org.eclipse.emf.ecore.EObject; | ||
9 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction; | ||
10 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution; | ||
11 | |||
12 | @SuppressWarnings("all") | ||
13 | public class TooLowAverageHddConstraint implements IGuidanceFunction { | ||
14 | private static final double THRESHOLD = 0.25; | ||
15 | |||
16 | @Override | ||
17 | public String getName() { | ||
18 | return "TooLowAverageHdd"; | ||
19 | } | ||
20 | |||
21 | @Override | ||
22 | public double computeFitness(final Solution solution) { | ||
23 | double _xblockexpression = (double) 0; | ||
24 | { | ||
25 | EObject _model = solution.getModel(); | ||
26 | final CyberPhysicalSystem cps = ((CyberPhysicalSystem) _model); | ||
27 | double sumUtilization = 0; | ||
28 | int numHosts = 0; | ||
29 | EList<HostType> _hostTypes = cps.getHostTypes(); | ||
30 | for (final HostType hostType : _hostTypes) { | ||
31 | { | ||
32 | int _numHosts = numHosts; | ||
33 | int _size = hostType.getInstances().size(); | ||
34 | numHosts = (_numHosts + _size); | ||
35 | EList<HostInstance> _instances = hostType.getInstances(); | ||
36 | for (final HostInstance host : _instances) { | ||
37 | { | ||
38 | final int utilization = ResourceUtilizationUtil.getHddUtilization(host); | ||
39 | double _sumUtilization = sumUtilization; | ||
40 | int _defaultHdd = hostType.getDefaultHdd(); | ||
41 | double _divide = (((double) utilization) / _defaultHdd); | ||
42 | sumUtilization = (_sumUtilization + _divide); | ||
43 | } | ||
44 | } | ||
45 | } | ||
46 | } | ||
47 | final double averageUtilization = (sumUtilization / numHosts); | ||
48 | final double difference = (TooLowAverageHddConstraint.THRESHOLD - averageUtilization); | ||
49 | double _xifexpression = (double) 0; | ||
50 | if ((difference > 0)) { | ||
51 | _xifexpression = difference; | ||
52 | } else { | ||
53 | _xifexpression = 0; | ||
54 | } | ||
55 | _xblockexpression = _xifexpression; | ||
56 | } | ||
57 | return _xblockexpression; | ||
58 | } | ||
59 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageMemoryConstraint.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageMemoryConstraint.java deleted file mode 100644 index 341925bc..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageMemoryConstraint.java +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.mdeo.ResourceUtilizationUtil; | ||
7 | import org.eclipse.emf.common.util.EList; | ||
8 | import org.eclipse.emf.ecore.EObject; | ||
9 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction; | ||
10 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution; | ||
11 | |||
12 | @SuppressWarnings("all") | ||
13 | public class TooLowAverageMemoryConstraint implements IGuidanceFunction { | ||
14 | private static final double THRESHOLD = 0.25; | ||
15 | |||
16 | @Override | ||
17 | public String getName() { | ||
18 | return "TooLowAverageMemory"; | ||
19 | } | ||
20 | |||
21 | @Override | ||
22 | public double computeFitness(final Solution solution) { | ||
23 | double _xblockexpression = (double) 0; | ||
24 | { | ||
25 | EObject _model = solution.getModel(); | ||
26 | final CyberPhysicalSystem cps = ((CyberPhysicalSystem) _model); | ||
27 | double sumUtilization = 0; | ||
28 | int numHosts = 0; | ||
29 | EList<HostType> _hostTypes = cps.getHostTypes(); | ||
30 | for (final HostType hostType : _hostTypes) { | ||
31 | { | ||
32 | int _numHosts = numHosts; | ||
33 | int _size = hostType.getInstances().size(); | ||
34 | numHosts = (_numHosts + _size); | ||
35 | EList<HostInstance> _instances = hostType.getInstances(); | ||
36 | for (final HostInstance host : _instances) { | ||
37 | { | ||
38 | final int utilization = ResourceUtilizationUtil.getMemoryUtilization(host); | ||
39 | double _sumUtilization = sumUtilization; | ||
40 | int _defaultMemory = hostType.getDefaultMemory(); | ||
41 | double _divide = (((double) utilization) / _defaultMemory); | ||
42 | sumUtilization = (_sumUtilization + _divide); | ||
43 | } | ||
44 | } | ||
45 | } | ||
46 | } | ||
47 | final double averageUtilization = (sumUtilization / numHosts); | ||
48 | final double difference = (TooLowAverageMemoryConstraint.THRESHOLD - averageUtilization); | ||
49 | double _xifexpression = (double) 0; | ||
50 | if ((difference > 0)) { | ||
51 | _xifexpression = difference; | ||
52 | } else { | ||
53 | _xifexpression = 0; | ||
54 | } | ||
55 | _xblockexpression = _xifexpression; | ||
56 | } | ||
57 | return _xblockexpression; | ||
58 | } | ||
59 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TotalCostFitnessFunction.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TotalCostFitnessFunction.java deleted file mode 100644 index 7bb80ca8..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TotalCostFitnessFunction.java +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
6 | import org.eclipse.emf.common.util.EList; | ||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction; | ||
9 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution; | ||
10 | |||
11 | @SuppressWarnings("all") | ||
12 | public class TotalCostFitnessFunction implements IGuidanceFunction { | ||
13 | @Override | ||
14 | public String getName() { | ||
15 | return "TotalCost"; | ||
16 | } | ||
17 | |||
18 | @Override | ||
19 | public double computeFitness(final Solution solution) { | ||
20 | int _xblockexpression = (int) 0; | ||
21 | { | ||
22 | EObject _model = solution.getModel(); | ||
23 | final CyberPhysicalSystem cps = ((CyberPhysicalSystem) _model); | ||
24 | int cost = 0; | ||
25 | EList<ApplicationType> _applicationTypes = cps.getApplicationTypes(); | ||
26 | for (final ApplicationType appType : _applicationTypes) { | ||
27 | int _cost = cost; | ||
28 | int _size = appType.getInstances().size(); | ||
29 | int _multiply = (5 * _size); | ||
30 | cost = (_cost + _multiply); | ||
31 | } | ||
32 | EList<HostType> _hostTypes = cps.getHostTypes(); | ||
33 | for (final HostType hostType : _hostTypes) { | ||
34 | int _cost_1 = cost; | ||
35 | int _cost_2 = hostType.getCost(); | ||
36 | int _size_1 = hostType.getInstances().size(); | ||
37 | int _multiply_1 = (_cost_2 * _size_1); | ||
38 | cost = (_cost_1 + _multiply_1); | ||
39 | } | ||
40 | _xblockexpression = cost; | ||
41 | } | ||
42 | return _xblockexpression; | ||
43 | } | ||
44 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableHddConstraint.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableHddConstraint.java deleted file mode 100644 index 00d1c4e6..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableHddConstraint.java +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.mdeo.ResourceUtilizationUtil; | ||
7 | import org.eclipse.emf.common.util.EList; | ||
8 | import org.eclipse.emf.ecore.EObject; | ||
9 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction; | ||
10 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution; | ||
11 | |||
12 | @SuppressWarnings("all") | ||
13 | public class UnavailableHddConstraint implements IGuidanceFunction { | ||
14 | @Override | ||
15 | public String getName() { | ||
16 | return "UnavailableHdd"; | ||
17 | } | ||
18 | |||
19 | @Override | ||
20 | public double computeFitness(final Solution solution) { | ||
21 | int _xblockexpression = (int) 0; | ||
22 | { | ||
23 | EObject _model = solution.getModel(); | ||
24 | final CyberPhysicalSystem cps = ((CyberPhysicalSystem) _model); | ||
25 | int cost = 0; | ||
26 | EList<HostType> _hostTypes = cps.getHostTypes(); | ||
27 | for (final HostType hostType : _hostTypes) { | ||
28 | EList<HostInstance> _instances = hostType.getInstances(); | ||
29 | for (final HostInstance host : _instances) { | ||
30 | { | ||
31 | final int utilization = ResourceUtilizationUtil.getHddUtilization(host); | ||
32 | int _defaultHdd = hostType.getDefaultHdd(); | ||
33 | final int difference = (utilization - _defaultHdd); | ||
34 | if ((difference > 0)) { | ||
35 | int _cost = cost; | ||
36 | cost = (_cost + difference); | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 | } | ||
41 | _xblockexpression = cost; | ||
42 | } | ||
43 | return _xblockexpression; | ||
44 | } | ||
45 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableMemoryConstraint.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableMemoryConstraint.java deleted file mode 100644 index a9be9f1f..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableMemoryConstraint.java +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.mdeo.ResourceUtilizationUtil; | ||
7 | import org.eclipse.emf.common.util.EList; | ||
8 | import org.eclipse.emf.ecore.EObject; | ||
9 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction; | ||
10 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution; | ||
11 | |||
12 | @SuppressWarnings("all") | ||
13 | public class UnavailableMemoryConstraint implements IGuidanceFunction { | ||
14 | @Override | ||
15 | public String getName() { | ||
16 | return "UnavailableMemory"; | ||
17 | } | ||
18 | |||
19 | @Override | ||
20 | public double computeFitness(final Solution solution) { | ||
21 | int _xblockexpression = (int) 0; | ||
22 | { | ||
23 | EObject _model = solution.getModel(); | ||
24 | final CyberPhysicalSystem cps = ((CyberPhysicalSystem) _model); | ||
25 | int cost = 0; | ||
26 | EList<HostType> _hostTypes = cps.getHostTypes(); | ||
27 | for (final HostType hostType : _hostTypes) { | ||
28 | EList<HostInstance> _instances = hostType.getInstances(); | ||
29 | for (final HostInstance host : _instances) { | ||
30 | { | ||
31 | final int utilization = ResourceUtilizationUtil.getMemoryUtilization(host); | ||
32 | int _defaultMemory = hostType.getDefaultMemory(); | ||
33 | final int difference = (utilization - _defaultMemory); | ||
34 | if ((difference > 0)) { | ||
35 | int _cost = cost; | ||
36 | cost = (_cost + difference); | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 | } | ||
41 | _xblockexpression = cost; | ||
42 | } | ||
43 | return _xblockexpression; | ||
44 | } | ||
45 | } | ||