Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qpme-core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Descartes Research
qpme-core
Commits
a4660014
Commit
a4660014
authored
Apr 09, 2020
by
Simon Trapp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented WEKA support in QPME.
parent
d2d1bf56
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
42 deletions
+79
-42
sources/qpme.simqpn.kernel/META-INF/MANIFEST.MF
sources/qpme.simqpn.kernel/META-INF/MANIFEST.MF
+2
-1
sources/qpme.simqpn.kernel/src/de/tud/cs/simqpn/kernel/loading/distributions/MARS.java
...c/de/tud/cs/simqpn/kernel/loading/distributions/MARS.java
+4
-3
sources/qpme.simqpn.kernel/src/de/tud/cs/simqpn/kernel/loading/distributions/WEKA.java
...c/de/tud/cs/simqpn/kernel/loading/distributions/WEKA.java
+54
-4
sources/qpme.simqpn.kernel/src/de/tud/cs/simqpn/kernel/loading/distributions/WEKACreator.java
...d/cs/simqpn/kernel/loading/distributions/WEKACreator.java
+19
-34
No files found.
sources/qpme.simqpn.kernel/META-INF/MANIFEST.MF
View file @
a4660014
...
...
@@ -33,7 +33,8 @@ Require-Bundle: org.dom4j,
cern.colt;bundle-version="1.2.0",
edu.bonn.cs.net.jbarrier;bundle-version="1.0.0",
org.eclipse.equinox.concurrent;bundle-version="1.1.0",
org.eclipse.swt
org.eclipse.swt,
nz.ac.waikato.cms.weka;bundle-version="3.9.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.apache.commons.math.distribution
Automatic-Module-Name: qpme.simqpn.kernel
sources/qpme.simqpn.kernel/src/de/tud/cs/simqpn/kernel/loading/distributions/MARS.java
View file @
a4660014
...
...
@@ -64,7 +64,6 @@ public class MARS implements AbstractDistribution {
if
(
functions
==
null
)
createFunctions
(
qplace
.
colors
);
double
result
=
constant
;
System
.
out
.
println
(
"START"
);
for
(
int
i
=
0
;
i
<
functions
.
length
;
i
++)
{
result
+=
functions
[
i
].
calculate
(
qplace
.
getQueueTokenPop
(),
color
);
}
...
...
@@ -107,7 +106,8 @@ public class MARS implements AbstractDistribution {
public
double
calculate
(
int
[]
tokenNumbers
,
int
mainColor
)
{
int
tokenNumber
=
tokenNumbers
[
colorId
];
if
(
colorId
==
mainColor
)
if
(
colorId
==
mainColor
)
// TODO: this excludes the processed request from the concurrency -> change
// training data so this can be removed
tokenNumber
=
tokenNumber
-
1
;
if
(
tokenNumber
>=
knot
)
return
0.0
;
...
...
@@ -135,7 +135,8 @@ public class MARS implements AbstractDistribution {
public
double
calculate
(
int
[]
tokenNumbers
,
int
mainColor
)
{
int
tokenNumber
=
tokenNumbers
[
colorId
];
if
(
colorId
==
mainColor
)
if
(
colorId
==
mainColor
)
// TODO: this excludes the processed request from the concurrency -> change
// training data so this can be removed
tokenNumber
=
tokenNumber
-
1
;
if
(
tokenNumber
<=
knot
)
return
0.0
;
...
...
sources/qpme.simqpn.kernel/src/de/tud/cs/simqpn/kernel/loading/distributions/WEKA.java
View file @
a4660014
...
...
@@ -40,17 +40,67 @@
*/
package
de.tud.cs.simqpn.kernel.loading.distributions
;
import
java.util.ArrayList
;
import
de.tud.cs.simqpn.kernel.entities.QPlace
;
import
weka.classifiers.Classifier
;
import
weka.core.Attribute
;
import
weka.core.DenseInstance
;
import
weka.core.Instance
;
import
weka.core.Instances
;
public
class
WEKA
implements
AbstractDistribution
{
public
WEKA
()
{
// TODO
Classifier
wekaModel
;
Instances
dataStructure
=
null
;
public
WEKA
(
Classifier
model
)
{
if
(
model
==
null
)
throw
new
NullPointerException
();
wekaModel
=
model
;
}
@Override
public
double
nextDouble
(
QPlace
qplace
,
int
color
)
{
return
0.0
;
// TODO
int
[]
tokenNumbers
=
qplace
.
getQueueTokenPop
();
// gets an array with the concurrencies for each WC
if
(
dataStructure
==
null
)
initializeDataStructure
(
tokenNumbers
.
length
);
Instance
dataPoint
=
new
DenseInstance
(
dataStructure
.
numAttributes
());
dataPoint
.
setDataset
(
dataStructure
);
for
(
int
i
=
0
;
i
<
tokenNumbers
.
length
;
i
++)
{
dataPoint
.
setValue
(
i
+
1
,
tokenNumbers
[
i
]);
}
try
{
return
wekaModel
.
classifyInstance
(
dataPoint
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
0.0
;
}
}
/**
* initializes the data structure with slots for response time and the
* concurrencies for each workload class
*
* @param wc_count The amount of workload classes available at the queueing
* place to be predicted by the model
*/
private
void
initializeDataStructure
(
int
wc_count
)
{
ArrayList
<
Attribute
>
attributes
=
new
ArrayList
<>();
final
Attribute
attr_RT
=
new
Attribute
(
"Response Time"
);
// first attribute is ALWAYS response time
attributes
.
add
(
attr_RT
);
for
(
int
i
=
0
;
i
<
wc_count
;
i
++)
{
final
Attribute
attr_CC
=
new
Attribute
(
"Concurrency "
+
(
i
+
1
));
// Concurrencies must be ordered the same
// in QPME and the weka model training
// data
attributes
.
add
(
attr_CC
);
}
dataStructure
=
new
Instances
(
"Data Structure"
,
attributes
,
0
);
dataStructure
.
setClass
(
attr_RT
);
}
}
}
\ No newline at end of file
sources/qpme.simqpn.kernel/src/de/tud/cs/simqpn/kernel/loading/distributions/WEKACreator.java
View file @
a4660014
...
...
@@ -41,51 +41,36 @@
*/
package
de.tud.cs.simqpn.kernel.loading.distributions
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.ObjectInputStream
;
import
de.tud.cs.simqpn.kernel.SimQPNException
;
import
weka.classifiers.Classifier
;
public
class
WEKACreator
extends
DistributionCreator
{
double
constant
;
List
<
Double
>
coefficients
=
new
LinkedList
<
Double
>();
List
<
Double
>
knots
=
new
LinkedList
<
Double
>();
List
<
Integer
>
sides
=
new
LinkedList
<
Integer
>();
List
<
String
>
colorIds
=
new
LinkedList
<
String
>();
String
marsFilename
;
String
wekaFilename
;
Classifier
wekaModel
;
@Override
protected
void
loadParams
()
throws
SimQPNException
{
marsFilename
=
this
.
loadStringParam
(
"wekaFile"
);
// TODO: model in memory laden
// loadMARSModelFromFile(marsFilename);
}
wekaFilename
=
this
.
loadStringParam
(
"wekaFile"
);
try
{
FileInputStream
fis
=
new
FileInputStream
(
wekaFilename
);
ObjectInputStream
ois
=
new
ObjectInputStream
(
fis
);
wekaModel
=
(
Classifier
)
ois
.
readObject
();
ois
.
close
();
fis
.
close
();
}
catch
(
ClassNotFoundException
|
IOException
e
)
{
e
.
printStackTrace
();
}
// private void loadMARSModelFromFile(String fileName) {
// coefficients.clear();
// knots.clear();
// sides.clear();
// colorIds.clear();
// try (BufferedReader br = new BufferedReader(new FileReader(new File(fileName)))) {
// String line = br.readLine();
// constant = Double.valueOf(line);
// while ((line = br.readLine()) != null) {
// String[] segments = line.split(" ");
// coefficients.add(Double.valueOf(segments[0]));
// knots.add(Double.valueOf(segments[1]));
// sides.add(Integer.valueOf(segments[2]));
// colorIds.add(segments[3]);
// }
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
}
@Override
public
AbstractDistribution
getDistribution
()
throws
SimQPNException
{
return
new
WEKA
();
return
new
WEKA
(
wekaModel
);
}
@Override
...
...
@@ -95,7 +80,7 @@ public class WEKACreator extends DistributionCreator {
@Override
public
String
getConstructionText
()
{
return
"("
+
mars
Filename
+
")"
;
return
"("
+
weka
Filename
+
")"
;
}
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment