Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
eraser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenLicht
eraser
Merge requests
!3
Integration of Learner
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Integration of Learner
learner
into
dev
Overview
0
Commits
37
Pipelines
1
Changes
78
Merged
René Schöne
requested to merge
learner
into
dev
5 years ago
Overview
0
Commits
37
Pipelines
1
Changes
78
Changes:
Fixed pattern to parse datetime coming from openHAB.
add benchmark
Create RecognitionEvents in component Plan.
Add expression printing and fix expression tests.
Fixing tests.
Remove build artefacts of datasets module.
Fixing item behavior.
Fix bug when adding item using REST API.
More debug output for REST application and MQTT receiver
Flush cache if new MQTT Host is set
first integration for test
update integration activity ML
add item room_brightness
add ML Items in starter file
fix import error
update newData function
Fix Learner bugs.
Let ExternalMachineLearningModel.check() return true instead of throwing an exception
In Learner, use temporary files to store encog model
In MachineLearningImpl, do not use result for now (as newData won't work at the moment)
Minor fixes for base (add logger, add correct input to jastadd gradle task)
Progressing to integration of machine learning.
Added setKnowledgeBase to MachineLearningEncoder and -Decoder, and removed Root argument in other methods
Changed Learner-Impl to match new adapters
Updated starter to new adapters, and to use CSV files for initialization of learner
update readercsv
Fix imports and dependencies.
Fix errors with changed MachineLearningEncoder interface.
upate learner
add ML interfaces
implement decode encode
learner with activity and preference
0
0
Merge request reports
Compare
dev
dev (base)
and
latest version
latest version
40d1d484
37 commits,
5 years ago
78 files
+
3776
−
1157
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
78
benchmark/src/main/java/de/tudresden/inf/st/eraser/benchmark/Benchmark.java
0 → 100644
+
146
−
0
View file @ 40d1d484
Edit in single-file editor
Open in Web IDE
package
de.tudresden.inf.st.eraser.benchmark
;
import
com.opencsv.CSVReader
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.fluent.Request
;
import
org.apache.http.entity.ContentType
;
import
org.apache.http.util.EntityUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.util.Arrays
;
public
class
Benchmark
{
//read every 5 s from csv
//activity CSV
/**
* Col 1: smartphone acceleration x
* Col 2: smartphone acceleration y
* Col 3: smartphone acceleration z
* Col 4: smartphone rotation x
* Col 5: smartphone rotation y
* Col 6: smartphone rotation z
* Col 7: watch acceleration x
* Col 8: watch acceleration y
* Col 9: watch acceleration z
* Col 10: watch rotation x
* Col 11: watch rotation y
* Col 12: watch rotation z/*/
//preference CSV
/**
* Col 1: Activity
* Col 2: watch brightness range "bright, medium, dimmer, dark"*/
private
String
a_csv_file_path
;
private
String
p_csv_file_path
;
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
Benchmark
.
class
);
private
static
final
String
ERASER_ITEM_URI
=
"http://localhost:4567/model/items/"
;
//TODO ITEM_NAME HAS TO BE DISCUSSED
private
static
final
String
[]
ACTIVITY_ITEM_NAME
=
{
"m_accel_x"
,
"m_accel_y"
,
"m_accel_z"
,
"m_rotation_x"
,
"m_rotation_y"
,
"m_rotation_z"
,
"w_accel_x"
,
"w_accel_y"
,
"w_accel_z"
,
"w_rotation_x"
,
"w_rotation_y"
,
"w_rotation_z"
};
private
static
final
String
[]
PREFERENCE_ITEM_NAME
=
{
"w_brightness"
};
private
static
boolean
flag2
=
true
;
//csv_type is activity or preference
Benchmark
(
String
a_csv_file_path
,
String
p_csv_file_path
)
{
this
.
a_csv_file_path
=
a_csv_file_path
;
this
.
p_csv_file_path
=
p_csv_file_path
;
}
void
start
(){
String
PREFERENCE_URL
=
"http://localhost:4567/model/items/iris1_item/state"
;
String
ACTIVITY_URL
=
"http://localhost:4567/activity/current"
;
int
TIME_PERIOD
=
5000
;
File
a_file
;
File
p_file
;
FileReader
a_file_reader
;
FileReader
p_file_reader
;
CSVReader
a_csv_reader
;
CSVReader
p_csv_reader
;
String
[]
a_next_record
;
String
[]
p_next_record
;
boolean
flag1
;
a_file
=
new
File
(
a_csv_file_path
);
p_file
=
new
File
(
p_csv_file_path
);
try
{
a_file_reader
=
new
FileReader
(
a_file
);
p_file_reader
=
new
FileReader
(
p_file
);
a_csv_reader
=
new
CSVReader
(
a_file_reader
);
p_csv_reader
=
new
CSVReader
(
p_file_reader
);
while
((((
a_next_record
=
a_csv_reader
.
readNext
())!=
null
)
&&
flag2
)){
try
{
Thread
.
sleep
(
TIME_PERIOD
);}
catch
(
InterruptedException
e
){
e
.
printStackTrace
();}
String
[]
values
=
Arrays
.
copyOf
(
a_next_record
,
12
);
setNewValue
(
values
,
ACTIVITY_ITEM_NAME
,
"activity"
);
HttpResponse
response
=
Request
.
Get
(
ACTIVITY_URL
).
execute
().
returnResponse
();
String
status
=
response
.
getStatusLine
().
toString
();
if
(
status
.
contains
(
"200"
)){
flag1
=
true
;
logger
.
info
(
"activity should be (read direct from CSV): "
+
a_next_record
[
12
]);
logger
.
info
(
EntityUtils
.
toString
(
response
.
getEntity
()));
logger
.
info
(
"get activity from web server: response 200 ok"
);
}
else
{
flag1
=
false
;
flag2
=
false
;
logger
.
info
(
"can not get the activity from the web server"
);
}
while
((((
p_next_record
=
p_csv_reader
.
readNext
())
!=
null
)
&&
flag1
))
{
try
{
Thread
.
sleep
(
TIME_PERIOD
);}
catch
(
InterruptedException
e
){
e
.
printStackTrace
();}
String
[]
values1
=
Arrays
.
copyOf
(
p_next_record
,
2
);
setNewValue
(
values1
,
PREFERENCE_ITEM_NAME
,
"preference"
);
HttpResponse
response1
=
Request
.
Get
(
PREFERENCE_URL
).
execute
().
returnResponse
();
String
status1
=
response1
.
getStatusLine
().
toString
();
if
(
status1
.
contains
(
"200"
)){
flag2
=
true
;
logger
.
info
(
"get the iris1_item preference from web server: response 200 ok, value is: "
+
EntityUtils
.
toString
(
response1
.
getEntity
()));
}
else
{
flag2
=
false
;
logger
.
info
(
"can not get the iris1_item from the web server"
);}
break
;
}
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
private
void
setNewValue
(
String
[]
values
,
String
[]
name
,
String
file_typ
){
if
(
file_typ
.
equals
(
"activity"
))
{
int
i
=
0
;
for
(
String
value
:
values
){
String
uri
=
ERASER_ITEM_URI
+
name
[
i
]
+
"/state"
;
try
{
HttpResponse
httpResponse
=
Request
.
Put
(
uri
)
.
bodyString
(
value
,
ContentType
.
TEXT_PLAIN
)
.
execute
().
returnResponse
();
String
status
=
httpResponse
.
getStatusLine
().
toString
();
if
(
status
.
contains
(
"200"
)){
logger
.
info
(
"put activity input name: "
+
name
[
i
]+
", value: "
+
value
+
"to web server: response 200 ok"
);
}
else
{
logger
.
info
(
"can not put activity inputs to rest server"
);
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
i
+=
1
;
}
}
else
{
String
uri
=
ERASER_ITEM_URI
+
"w_brightness"
+
"/state"
;
try
{
HttpResponse
httpResponse
=
Request
.
Put
(
uri
)
.
bodyString
(
values
[
1
],
ContentType
.
TEXT_PLAIN
)
.
execute
().
returnResponse
();
String
put_response
=
httpResponse
.
getStatusLine
().
toString
();
if
(
put_response
.
contains
(
"200"
)){
logger
.
info
(
"put w_brightness to web server: response 200 ok"
);}
else
{
logger
.
info
(
"can not put w_brightness to rest server"
);
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
}
}
\ No newline at end of file
Loading