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
89f4873c
Commit
89f4873c
authored
5 years ago
by
BrunoDatoMeneses
Browse files
Options
Downloads
Patches
Plain Diff
ADD: new multiUI launches
parent
878cdb72
Branches
Branches containing commit
No related tags found
1 merge request
!4
Exp rein
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
AMAKFX/src/fr/irit/smac/amak/examples/randomantsMultiUi/AntsLaunchExampleMultiUI.java
+13
-5
13 additions, 5 deletions
.../examples/randomantsMultiUi/AntsLaunchExampleMultiUI.java
AMOEBAonAMAK/src/experiments/AdvancedMain.java
+145
-122
145 additions, 122 deletions
AMOEBAonAMAK/src/experiments/AdvancedMain.java
with
158 additions
and
127 deletions
AMAKFX/src/fr/irit/smac/amak/examples/randomantsMultiUi/AntsLaunchExampleMultiUI.java
+
13
−
5
View file @
89f4873c
...
@@ -27,15 +27,23 @@ public class AntsLaunchExampleMultiUI extends Application{
...
@@ -27,15 +27,23 @@ public class AntsLaunchExampleMultiUI extends Application{
AmasMultiUIWindow
window
=
new
AmasMultiUIWindow
(
"Random Ants Multi UI 1"
);
AmasMultiUIWindow
window
=
new
AmasMultiUIWindow
(
"Random Ants Multi UI 1"
);
AmasMultiUIWindow
window2
=
new
AmasMultiUIWindow
(
"Random Ants Multi UI 2"
);
//
AmasMultiUIWindow window2 = new AmasMultiUIWindow("Random Ants Multi UI 2");
WorldExampleMultiUI
env
=
new
WorldExampleMultiUI
(
window
);
WorldExampleMultiUI
env
=
new
WorldExampleMultiUI
(
window
);
WorldExampleMultiUI
env2
=
new
WorldExampleMultiUI
(
window2
);
//
WorldExampleMultiUI env2 = new WorldExampleMultiUI(window2);
AntHillExampleMultiUI
amas1
=
new
AntHillExampleMultiUI
(
window
,
VUIMulti
.
getDefault
(),
env
);
AntHillExampleMultiUI
ants
=
new
AntHillExampleMultiUI
(
window
,
VUIMulti
.
get
(
"Ants VUI 1"
),
env
);
AntHillExampleMultiUI
amas2
=
new
AntHillExampleMultiUI
(
window2
,
VUIMulti
.
getDefault
(),
env2
);
//new AntHillExampleMultiUI(window2, VUIMulti.get("Ants VUI 2"), env2);
for
(
int
i
=
0
;
i
<
1000
;
i
++)
ants
.
cycle
();
}
@Override
public
void
stop
()
throws
Exception
{
super
.
stop
();
System
.
exit
(
0
);
}
}
}
}
This diff is collapsed.
Click to expand it.
AMOEBAonAMAK/src/experiments/AdvancedMain.java
+
145
−
122
View file @
89f4873c
package
experiments
;
package
experiments
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
fr.irit.smac.amak.Configuration
;
import
fr.irit.smac.amak.Configuration
;
import
fr.irit.smac.amak.tools.Log
;
import
fr.irit.smac.amak.tools.Log
;
import
gui.AmoebaWindow
;
import
fr.irit.smac.amak.ui.VUIMulti
;
import
javafx.beans.value.ChangeListener
;
import
gui.AmoebaMultiUIWindow
;
import
javafx.beans.value.ObservableValue
;
import
gui.AmoebaWindow
;
import
javafx.scene.control.Slider
;
import
javafx.application.Application
;
import
kernel.AMOEBA
;
import
javafx.beans.value.ChangeListener
;
import
kernel.StudiedSystem
;
import
javafx.beans.value.ObservableValue
;
import
kernel.backup.BackupSystem
;
import
javafx.scene.control.Slider
;
import
kernel.backup.IBackupSystem
;
import
javafx.stage.Stage
;
import
kernel.backup.SaveHelperImpl
;
import
kernel.AMOEBA
;
import
kernel.StudiedSystem
;
/**
import
kernel.backup.BackupSystem
;
* A more advanced and complete main.
import
kernel.backup.IBackupSystem
;
* @author Hugo
import
kernel.backup.SaveHelperImpl
;
*
*/
/**
public
class
AdvancedMain
{
* A more advanced and complete main.
* @author Hugo
public
static
void
main
(
String
[]
args
)
throws
IOException
{
*
// Instantiating the MainWindow before usage.
*/
// It also allows you to change some of its behavior before creating an AMOEBA.
public
class
AdvancedMain
extends
Application
{
// If you use Configuration.commandLineMode = True , then you should skip it.
AmoebaWindow
.
instance
();
example
();
public
static
void
main
(
String
[]
args
)
throws
IOException
{
}
// Application.launch(args) launches JavaFX process
private
static
void
example
()
throws
IOException
{
// It also allows you to change some of its behavior before creating an AMOEBA.
// If you use Configuration.commandLineMode = True , then you should skip it.
// Set AMAK configuration before creating an AMOEBA
Application
.
launch
(
args
);
Configuration
.
commandLineMode
=
false
;
Configuration
.
allowedSimultaneousAgentsExecution
=
1
;
Configuration
.
waitForGUI
=
true
;
}
// Create an AMOEBA
@Override
AMOEBA
amoeba
=
new
AMOEBA
();
public
void
start
(
Stage
primaryStage
)
throws
Exception
,
IOException
{
// Create a studied system and add it to the amoeba.
// Adding a studied system to an amoeba allow you to control the learning speed (the simulation : how many cycles per second)
example
();
// with amoeba's scheduler, graphically or programmatically.
StudiedSystem
studiedSystem
=
new
F_XY_System
(
50.0
);
}
amoeba
.
setStudiedSystem
(
studiedSystem
);
// A window appeared, allowing to control the simulation, but if you try to run it
// it will crash (there's no percepts !). We need to load a configuration :
private
static
void
example
()
throws
IOException
{
// Change how new Context are rendered.
//Context.defaultRenderStrategy = NoneRenderer.class;
// Set AMAK configuration before creating an AMOEBA
Configuration
.
commandLineMode
=
false
;
// Create a backup system for the AMOEBA
Configuration
.
allowedSimultaneousAgentsExecution
=
1
;
IBackupSystem
backupSystem
=
new
BackupSystem
(
amoeba
);
Configuration
.
waitForGUI
=
true
;
// Load a configuration matching the studied system
Configuration
.
multiUI
=
true
;
File
file
=
new
File
(
"resources/twoDimensionsLauncher.xml"
);
backupSystem
.
load
(
file
);
// Note : if you intend to use a SaveHelper, you can use SaveHelper.load instead of a BackupSystem
VUIMulti
amoebaVUI
=
VUIMulti
.
get
(
"2D"
);
AmoebaMultiUIWindow
amoebaUI
=
new
AmoebaMultiUIWindow
(
"ELLSA"
,
amoebaVUI
);
// We add an optional saver, allowing us to autosave the amoeba at each cycle.
// The SaveHelper also add graphical tools to save and load AMOEBA's state.
// Create an AMOEBA
amoeba
.
saver
=
new
SaveHelperImpl
(
amoeba
);
AMOEBA
amoeba
=
new
AMOEBA
(
amoebaUI
,
amoebaVUI
);
// Autosave slow execution, if you want fast training, set saver to null,
// Create a studied system and add it to the amoeba.
// or saver.autoSave = false.
// Adding a studied system to an amoeba allow you to control the learning speed (the simulation : how many cycles per second)
// with amoeba's scheduler, graphically or programmatically.
// The amoeba is ready to be used.
StudiedSystem
studiedSystem
=
new
F_XY_System
(
50.0
);
// Next we show how to control it with code :
amoeba
.
setStudiedSystem
(
studiedSystem
);
// A window appeared, allowing to control the simulation, but if you try to run it
// We deny the possibility to change simulation speed with the UI
// it will crash (there's no percepts !). We need to load a configuration :
amoeba
.
allowGraphicalScheduler
(
false
);
// We allow rendering
// Change how new Context are rendered.
amoeba
.
setRenderUpdate
(
true
);
//Context.defaultRenderStrategy = NoneRenderer.class;
long
start
=
System
.
currentTimeMillis
();
// We run some learning cycles
// Create a backup system for the AMOEBA
int
nbCycle
=
1000
;
IBackupSystem
backupSystem
=
new
BackupSystem
(
amoeba
);
for
(
int
i
=
0
;
i
<
nbCycle
;
++
i
)
{
// Load a configuration matching the studied system
studiedSystem
.
playOneStep
();
File
file
=
new
File
(
"resources/twoDimensionsLauncher.xml"
);
amoeba
.
learn
(
studiedSystem
.
getOutput
());
backupSystem
.
load
(
file
);
}
// Note : if you intend to use a SaveHelper, you can use SaveHelper.load instead of a BackupSystem
long
end
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
"Done in : "
+
(
end
-
start
)
/
1000.0
);
// We add an optional saver, allowing us to autosave the amoeba at each cycle.
// The SaveHelper also add graphical tools to save and load AMOEBA's state.
// We create a manual save point
amoeba
.
saver
=
new
SaveHelperImpl
(
amoeba
);
amoeba
.
saver
.
newManualSave
(
"TestManualSave"
);
// Autosave slow execution, if you want fast training, set saver to null,
// or saver.autoSave = false.
// We set the log level to INFORM, to avoid debug logs that slow down simulation
Log
.
defaultMinLevel
=
Log
.
Level
.
INFORM
;
// The amoeba is ready to be used.
// Next we show how to control it with code :
// We deactivate rendering
amoeba
.
setRenderUpdate
(
false
);
// We deny the possibility to change simulation speed with the UI
// Do some more learning
amoeba
.
allowGraphicalScheduler
(
false
);
start
=
System
.
currentTimeMillis
();
// We allow rendering
for
(
int
i
=
0
;
i
<
nbCycle
;
++
i
)
{
amoeba
.
setRenderUpdate
(
true
);
studiedSystem
.
playOneStep
();
long
start
=
System
.
currentTimeMillis
();
amoeba
.
learn
(
studiedSystem
.
getOutput
());
// We run some learning cycles
}
int
nbCycle
=
1000
;
end
=
System
.
currentTimeMillis
();
for
(
int
i
=
0
;
i
<
nbCycle
;
++
i
)
{
System
.
out
.
println
(
"Done in : "
+
(
end
-
start
)
/
1000.0
);
studiedSystem
.
playOneStep
();
amoeba
.
learn
(
studiedSystem
.
getOutput
());
}
// Activate rendering back
long
end
=
System
.
currentTimeMillis
();
amoeba
.
setRenderUpdate
(
true
);
System
.
out
.
println
(
"Done in : "
+
(
end
-
start
)
/
1000.0
);
// After activating rendering we need to update agent's visualization
amoeba
.
updateAgentsVisualisation
();
// We create a manual save point
// We allow simulation control with the UI
amoeba
.
saver
.
newManualSave
(
"TestManualSave"
);
amoeba
.
allowGraphicalScheduler
(
true
);
// We set the log level to INFORM, to avoid debug logs that slow down simulation
// Exemple for adding a tool in the toolbar
Log
.
defaultMinLevel
=
Log
.
Level
.
INFORM
;
Slider
slider
=
new
Slider
(
0
,
10
,
0
);
slider
.
setShowTickLabels
(
true
);
// We deactivate rendering
slider
.
setShowTickMarks
(
true
);
amoeba
.
setRenderUpdate
(
false
);
slider
.
valueProperty
().
addListener
(
new
ChangeListener
<
Number
>()
{
// Do some more learning
@Override
start
=
System
.
currentTimeMillis
();
public
void
changed
(
ObservableValue
<?
extends
Number
>
observable
,
Number
oldValue
,
Number
newValue
)
{
for
(
int
i
=
0
;
i
<
nbCycle
;
++
i
)
{
System
.
out
.
println
(
"new Value "
+
newValue
);
studiedSystem
.
playOneStep
();
}
amoeba
.
learn
(
studiedSystem
.
getOutput
());
});
}
AmoebaWindow
.
addToolbar
(
slider
);
end
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
"Done in : "
+
(
end
-
start
)
/
1000.0
);
System
.
out
.
println
(
"End main"
);
}
}
// Activate rendering back
amoeba
.
setRenderUpdate
(
true
);
// After activating rendering we need to update agent's visualization
amoeba
.
updateAgentsVisualisation
();
// We allow simulation control with the UI
amoeba
.
allowGraphicalScheduler
(
true
);
// Exemple for adding a tool in the toolbar
Slider
slider
=
new
Slider
(
0
,
10
,
0
);
slider
.
setShowTickLabels
(
true
);
slider
.
setShowTickMarks
(
true
);
slider
.
valueProperty
().
addListener
(
new
ChangeListener
<
Number
>()
{
@Override
public
void
changed
(
ObservableValue
<?
extends
Number
>
observable
,
Number
oldValue
,
Number
newValue
)
{
System
.
out
.
println
(
"new Value "
+
newValue
);
}
});
amoebaUI
.
addToolbar
(
slider
);
System
.
out
.
println
(
"End main"
);
}
}
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