aboutsummaryrefslogtreecommitdiffstats
path: root/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.java
diff options
context:
space:
mode:
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.java')
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.java177
1 files changed, 0 insertions, 177 deletions
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 @@
1package hu.bme.mit.inf.dslreasoner.domains.cps.generator;
2
3import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance;
4import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType;
5import hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory;
6import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem;
7import hu.bme.mit.inf.dslreasoner.domains.cps.HostType;
8import hu.bme.mit.inf.dslreasoner.domains.cps.Request;
9import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement;
10import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement;
11import java.util.Collection;
12import java.util.Collections;
13import java.util.List;
14import java.util.Random;
15import org.eclipse.emf.common.util.EList;
16import org.eclipse.emf.common.util.URI;
17import org.eclipse.emf.ecore.EObject;
18import org.eclipse.emf.ecore.resource.Resource;
19import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
20import org.eclipse.xtext.xbase.lib.CollectionLiterals;
21import org.eclipse.xtext.xbase.lib.ExclusiveRange;
22import org.eclipse.xtext.xbase.lib.Extension;
23import org.eclipse.xtext.xbase.lib.ObjectExtensions;
24import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
25
26@SuppressWarnings("all")
27public 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}