Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AMOEBA3
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMAC
Learning Group
AMOEBA3
Commits
3154c15c
Commit
3154c15c
authored
5 years ago
by
BrunoDatoMeneses
Browse files
Options
Downloads
Patches
Plain Diff
ADD: working multiUI amoeba launcher
parent
568d4c1d
Branches
Branches containing commit
No related tags found
1 merge request
!4
Exp rein
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_LauncherMultiUI.java
+223
-34
223 additions, 34 deletions
...experiments/nDimensionsLaunchers/F_N_LauncherMultiUI.java
with
223 additions
and
34 deletions
AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_LauncherMultiUI.java
+
223
−
34
View file @
3154c15c
...
@@ -15,6 +15,7 @@ import fr.irit.smac.amak.ui.VUIMulti;
...
@@ -15,6 +15,7 @@ import fr.irit.smac.amak.ui.VUIMulti;
import
gui.AmoebaMultiUIWindow
;
import
gui.AmoebaMultiUIWindow
;
import
gui.AmoebaWindow
;
import
gui.AmoebaWindow
;
import
javafx.application.Application
;
import
javafx.application.Application
;
import
javafx.application.Platform
;
import
javafx.beans.value.ChangeListener
;
import
javafx.beans.value.ChangeListener
;
import
javafx.beans.value.ObservableValue
;
import
javafx.beans.value.ObservableValue
;
import
javafx.scene.control.Slider
;
import
javafx.scene.control.Slider
;
...
@@ -24,6 +25,7 @@ import kernel.StudiedSystem;
...
@@ -24,6 +25,7 @@ import kernel.StudiedSystem;
import
kernel.backup.BackupSystem
;
import
kernel.backup.BackupSystem
;
import
kernel.backup.IBackupSystem
;
import
kernel.backup.IBackupSystem
;
import
kernel.backup.SaveHelperImpl
;
import
kernel.backup.SaveHelperImpl
;
import
utils.TRACE_LEVEL
;
/**
/**
...
@@ -48,7 +50,15 @@ public class F_N_LauncherMultiUI extends Application implements Serializable {
...
@@ -48,7 +50,15 @@ public class F_N_LauncherMultiUI extends Application implements Serializable {
public
static
final
int
nbCycle
=
1000
;
public
static
final
int
nbCycle
=
1000
;
AMOEBA
amoeba
;
StudiedSystem
studiedSystem
;
VUIMulti
amoebaVUI
;
AmoebaMultiUIWindow
amoebaUI
;
AMOEBA
amoeba2
;
StudiedSystem
studiedSystem2
;
VUIMulti
amoebaVUI2
;
AmoebaMultiUIWindow
amoebaUI2
;
public
static
void
main
(
String
[]
args
)
throws
IOException
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
...
@@ -67,21 +77,9 @@ public class F_N_LauncherMultiUI extends Application implements Serializable {
...
@@ -67,21 +77,9 @@ public class F_N_LauncherMultiUI extends Application implements Serializable {
Configuration
.
waitForGUI
=
true
;
Configuration
.
waitForGUI
=
true
;
Configuration
.
plotMilliSecondsUpdate
=
20000
;
Configuration
.
plotMilliSecondsUpdate
=
20000
;
VUIMulti
amoebaVUI
=
new
VUIMulti
(
"2D"
);
amoebaVUI
=
new
VUIMulti
(
"2D"
);
AmoebaMultiUIWindow
amoebaUI
=
new
AmoebaMultiUIWindow
(
"ELLSA"
,
amoebaVUI
);
amoebaUI
=
new
AmoebaMultiUIWindow
(
"ELLSA"
,
amoebaVUI
);
AMOEBA
amoeba
=
new
AMOEBA
(
amoebaUI
,
amoebaVUI
);
StudiedSystem
studiedSystem
=
new
F_N_Manager
(
spaceSize
,
dimension
,
nbOfModels
,
normType
,
randomExploration
,
explorationIncrement
,
explorationWidht
,
limitedToSpaceZone
,
oracleNoiseRange
);
amoeba
.
setStudiedSystem
(
studiedSystem
);
IBackupSystem
backupSystem
=
new
BackupSystem
(
amoeba
);
File
file
=
new
File
(
"resources/twoDimensionsLauncher.xml"
);
backupSystem
.
load
(
file
);
amoeba
.
saver
=
new
SaveHelperImpl
(
amoeba
);
amoeba
.
allowGraphicalScheduler
(
true
);
amoeba
.
setRenderUpdate
(
true
);
amoeba
.
data
.
learningSpeed
=
learningSpeed
;
amoeba
.
data
.
numberOfPointsForRegression
=
regressionPoints
;
amoeba
.
getEnvironment
().
setMappingErrorAllowed
(
mappingErrorAllowed
);
// Exemple for adding a tool in the toolbar
// Exemple for adding a tool in the toolbar
Slider
slider
=
new
Slider
(
0.01
,
0.1
,
mappingErrorAllowed
);
Slider
slider
=
new
Slider
(
0.01
,
0.1
,
mappingErrorAllowed
);
...
@@ -98,24 +96,31 @@ public class F_N_LauncherMultiUI extends Application implements Serializable {
...
@@ -98,24 +96,31 @@ public class F_N_LauncherMultiUI extends Application implements Serializable {
});
});
amoebaUI
.
addToolbar
(
slider
);
amoebaUI
.
addToolbar
(
slider
);
studiedSystem
.
playOneStep
();
amoeba
.
learn
(
studiedSystem
.
getOutput
());
amoebaVUI2
=
new
VUIMulti
(
"2D"
);
studiedSystem
.
playOneStep
();
amoebaUI2
=
new
AmoebaMultiUIWindow
(
"ELLSA"
,
amoebaVUI2
);
amoeba
.
learn
(
studiedSystem
.
getOutput
());
studiedSystem
.
playOneStep
();
amoeba
.
learn
(
studiedSystem
.
getOutput
());
// Exemple for adding a tool in the toolbar
studiedSystem
.
playOneStep
();
Slider
slider2
=
new
Slider
(
0.01
,
0.1
,
mappingErrorAllowed
);
amoeba
.
learn
(
studiedSystem
.
getOutput
());
slider2
.
setShowTickLabels
(
true
);
slider2
.
setShowTickMarks
(
true
);
long
start
=
System
.
currentTimeMillis
();
slider2
.
valueProperty
().
addListener
(
new
ChangeListener
<
Number
>()
{
for
(
int
i
=
0
;
i
<
100
;
++
i
)
{
@Override
System
.
out
.
println
(
i
);
public
void
changed
(
ObservableValue
<?
extends
Number
>
observable
,
Number
oldValue
,
Number
newValue
)
{
studiedSystem
.
playOneStep
();
System
.
out
.
println
(
"new Value "
+
newValue
);
amoeba
.
learn
(
studiedSystem
.
getOutput
());
mappingErrorAllowed
=
(
double
)
newValue
;
}
amoeba2
.
getEnvironment
().
setMappingErrorAllowed
(
mappingErrorAllowed
);
long
end
=
System
.
currentTimeMillis
();
}
System
.
out
.
println
(
"Done in : "
+
(
end
-
start
)
);
});
amoebaUI2
.
addToolbar
(
slider2
);
startTask
(
100
,
1000
);
startTask2
(
500
,
100
);
// VUIMulti amoebaVUI2 = VUIMulti.get("2D");
// VUIMulti amoebaVUI2 = VUIMulti.get("2D");
...
@@ -171,6 +176,190 @@ public class F_N_LauncherMultiUI extends Application implements Serializable {
...
@@ -171,6 +176,190 @@ public class F_N_LauncherMultiUI extends Application implements Serializable {
}
}
public
void
startTask
(
long
wait
,
int
cycles
)
{
// Create a Runnable
Runnable
task
=
new
Runnable
()
{
public
void
run
()
{
runTask
(
wait
,
cycles
);
}
};
// Run the task in a background thread
Thread
backgroundThread
=
new
Thread
(
task
);
// Terminate the running thread if the application exits
backgroundThread
.
setDaemon
(
true
);
// Start the thread
backgroundThread
.
start
();
}
public
void
startTask2
(
long
wait
,
int
cycles
)
{
// Create a Runnable
Runnable
task
=
new
Runnable
()
{
public
void
run
()
{
runTask2
(
wait
,
cycles
);
}
};
// Run the task in a background thread
Thread
backgroundThread
=
new
Thread
(
task
);
// Terminate the running thread if the application exits
backgroundThread
.
setDaemon
(
true
);
// Start the thread
backgroundThread
.
start
();
}
public
void
runTask
(
long
wait
,
int
cycles
)
{
try
{
// Update the Label on the JavaFx Application Thread
Platform
.
runLater
(
new
Runnable
()
{
@Override
public
void
run
()
{
amoeba
=
new
AMOEBA
(
amoebaUI
,
amoebaVUI
);
studiedSystem
=
new
F_N_Manager
(
spaceSize
,
dimension
,
nbOfModels
,
normType
,
randomExploration
,
explorationIncrement
,
explorationWidht
,
limitedToSpaceZone
,
oracleNoiseRange
);
amoeba
.
setStudiedSystem
(
studiedSystem
);
IBackupSystem
backupSystem
=
new
BackupSystem
(
amoeba
);
File
file
=
new
File
(
"resources/twoDimensionsLauncher.xml"
);
backupSystem
.
load
(
file
);
amoeba
.
saver
=
new
SaveHelperImpl
(
amoeba
);
amoeba
.
allowGraphicalScheduler
(
true
);
amoeba
.
setRenderUpdate
(
true
);
amoeba
.
data
.
learningSpeed
=
learningSpeed
;
amoeba
.
data
.
numberOfPointsForRegression
=
regressionPoints
;
amoeba
.
getEnvironment
().
setMappingErrorAllowed
(
mappingErrorAllowed
);
}
});
Thread
.
sleep
(
wait
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
for
(
int
i
=
0
;
i
<
cycles
;
i
++)
{
try
{
// Get the Status
final
String
status
=
"Processing "
+
i
+
" of "
+
cycles
;
// Update the Label on the JavaFx Application Thread
Platform
.
runLater
(
new
Runnable
()
{
@Override
public
void
run
()
{
studiedSystem
.
playOneStep
();
amoeba
.
learn
(
studiedSystem
.
getOutput
());
if
(
amoeba
.
getHeadAgent
().
isActiveLearning
())
{
studiedSystem
.
setActiveLearning
(
true
);
studiedSystem
.
setSelfRequest
(
amoeba
.
getHeadAgent
().
getSelfRequest
());
}
System
.
out
.
println
(
status
);
}
});
Thread
.
sleep
(
wait
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
public
void
runTask2
(
long
wait
,
int
cycles
)
{
try
{
// Update the Label on the JavaFx Application Thread
Platform
.
runLater
(
new
Runnable
()
{
@Override
public
void
run
()
{
amoeba2
=
new
AMOEBA
(
amoebaUI2
,
amoebaVUI2
);
studiedSystem2
=
new
F_N_Manager
(
spaceSize
,
dimension
,
nbOfModels
,
normType
,
randomExploration
,
explorationIncrement
,
explorationWidht
,
limitedToSpaceZone
,
oracleNoiseRange
);
amoeba2
.
setStudiedSystem
(
studiedSystem2
);
IBackupSystem
backupSystem2
=
new
BackupSystem
(
amoeba2
);
File
file2
=
new
File
(
"resources/twoDimensionsLauncher.xml"
);
backupSystem2
.
load
(
file2
);
amoeba2
.
saver
=
new
SaveHelperImpl
(
amoeba2
);
amoeba2
.
allowGraphicalScheduler
(
true
);
amoeba2
.
setRenderUpdate
(
true
);
amoeba2
.
data
.
learningSpeed
=
learningSpeed
;
amoeba2
.
data
.
numberOfPointsForRegression
=
regressionPoints
;
amoeba2
.
getEnvironment
().
setMappingErrorAllowed
(
mappingErrorAllowed
);
}
});
Thread
.
sleep
(
wait
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
for
(
int
i
=
0
;
i
<
cycles
;
i
++)
{
try
{
// Get the Status
final
String
status
=
"Processing "
+
i
+
" of "
+
cycles
;
// Update the Label on the JavaFx Application Thread
Platform
.
runLater
(
new
Runnable
()
{
@Override
public
void
run
()
{
studiedSystem2
.
playOneStep
();
amoeba2
.
learn
(
studiedSystem2
.
getOutput
());
if
(
amoeba2
.
getHeadAgent
().
isActiveLearning
())
{
studiedSystem2
.
setActiveLearning
(
true
);
studiedSystem2
.
setSelfRequest
(
amoeba2
.
getHeadAgent
().
getSelfRequest
());
}
System
.
out
.
println
(
status
);
}
});
Thread
.
sleep
(
wait
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
@Override
@Override
public
void
stop
()
throws
Exception
{
public
void
stop
()
throws
Exception
{
super
.
stop
();
super
.
stop
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment