Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
E
EMADL2CPP
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
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
monticore
EmbeddedMontiArc
generators
EMADL2CPP
Commits
cc9a61ce
Commit
cc9a61ce
authored
Jul 18, 2019
by
Nicola Gatto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve critic as EMADL component
parent
7b077576
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
22 deletions
+60
-22
src/main/java/de/monticore/lang/monticar/emadl/generator/EMADLGenerator.java
...nticore/lang/monticar/emadl/generator/EMADLGenerator.java
+36
-10
src/test/resources/models/reinforcementModel/mountaincar/agent/MountaincarCritic.cnna
...inforcementModel/mountaincar/agent/MountaincarCritic.cnna
+0
-12
src/test/resources/models/reinforcementModel/mountaincar/agent/MountaincarCritic.emadl
...nforcementModel/mountaincar/agent/MountaincarCritic.emadl
+24
-0
No files found.
src/main/java/de/monticore/lang/monticar/emadl/generator/EMADLGenerator.java
View file @
cc9a61ce
...
...
@@ -115,6 +115,18 @@ public class EMADLGenerator {
processedArchitecture
=
new
HashMap
<>();
setModelsPath
(
modelPath
);
TaggingResolver
symtab
=
EMADLAbstractSymtab
.
createSymTabAndTaggingResolver
(
getModelsPath
());
EMAComponentInstanceSymbol
instance
=
resolveComponentInstanceSymbol
(
qualifiedName
,
symtab
);
generateFiles
(
symtab
,
instance
,
symtab
,
pythonPath
,
forced
);
if
(
doCompile
)
{
compile
();
}
processedArchitecture
=
null
;
}
private
EMAComponentInstanceSymbol
resolveComponentInstanceSymbol
(
String
qualifiedName
,
TaggingResolver
symtab
)
{
EMAComponentSymbol
component
=
symtab
.<
EMAComponentSymbol
>
resolve
(
qualifiedName
,
EMAComponentSymbol
.
KIND
).
orElse
(
null
);
List
<
String
>
splitName
=
Splitters
.
DOT
.
splitToList
(
qualifiedName
);
...
...
@@ -126,15 +138,7 @@ public class EMADLGenerator {
System
.
exit
(
1
);
}
EMAComponentInstanceSymbol
instance
=
component
.
getEnclosingScope
().<
EMAComponentInstanceSymbol
>
resolve
(
instanceName
,
EMAComponentInstanceSymbol
.
KIND
).
get
();
generateFiles
(
symtab
,
instance
,
symtab
,
pythonPath
,
forced
);
if
(
doCompile
)
{
compile
();
}
processedArchitecture
=
null
;
return
component
.
getEnclosingScope
().<
EMAComponentInstanceSymbol
>
resolve
(
instanceName
,
EMAComponentInstanceSymbol
.
KIND
).
get
();
}
public
void
compile
()
throws
IOException
{
...
...
@@ -530,7 +534,29 @@ public class EMADLGenerator {
final
String
fullConfigName
=
String
.
join
(
"."
,
names
);
ArchitectureSymbol
correspondingArchitecture
=
this
.
processedArchitecture
.
get
(
fullConfigName
);
assert
correspondingArchitecture
!=
null
:
"No architecture found for train "
+
fullConfigName
+
" configuration!"
;
configuration
.
setTrainedArchitecture
(
new
ArchitectureAdapter
(
correspondingArchitecture
));
configuration
.
setTrainedArchitecture
(
new
ArchitectureAdapter
(
correspondingArchitecture
.
getName
(),
correspondingArchitecture
));
// Resolve critic network if critic is present
if
(
configuration
.
getCriticName
().
isPresent
())
{
String
fullCriticName
=
configuration
.
getCriticName
().
get
();
int
indexOfFirstNameCharacter
=
fullCriticName
.
lastIndexOf
(
'.'
)
+
1
;
fullCriticName
=
fullCriticName
.
substring
(
0
,
indexOfFirstNameCharacter
)
+
fullCriticName
.
substring
(
indexOfFirstNameCharacter
,
indexOfFirstNameCharacter
+
1
).
toUpperCase
()
+
fullCriticName
.
substring
(
indexOfFirstNameCharacter
+
1
);
TaggingResolver
symtab
=
EMADLAbstractSymtab
.
createSymTabAndTaggingResolver
(
getModelsPath
());
EMAComponentInstanceSymbol
instanceSymbol
=
resolveComponentInstanceSymbol
(
fullCriticName
,
symtab
);
EMADLCocos
.
checkAll
(
instanceSymbol
);
Optional
<
ArchitectureSymbol
>
critic
=
instanceSymbol
.
getSpannedScope
().
resolve
(
""
,
ArchitectureSymbol
.
KIND
);
if
(!
critic
.
isPresent
())
{
Log
.
error
(
"During the resolving of critic component: Critic component "
+
fullCriticName
+
" does not have a CNN implementation but is required to have one"
);
System
.
exit
(-
1
);
}
configuration
.
setCriticNetwork
(
new
ArchitectureAdapter
(
fullCriticName
,
critic
.
get
()));
}
cnnTrainGenerator
.
setInstanceName
(
componentInstance
.
getFullName
().
replaceAll
(
"\\."
,
"_"
));
Map
<
String
,
String
>
fileContentMap
=
cnnTrainGenerator
.
generateStrings
(
configuration
);
...
...
src/test/resources/models/reinforcementModel/mountaincar/agent/MountaincarCritic.cnna
deleted
100644 → 0
View file @
7b077576
implementation Critic(state, action) {
(state ->
FullyConnected(units=400) ->
Relu() ->
FullyConnected(units=300)
|
action ->
FullyConnected(units=300)
) ->
Add() ->
Relu()
}
\ No newline at end of file
src/test/resources/models/reinforcementModel/mountaincar/agent/MountaincarCritic.emadl
0 → 100644
View file @
cc9a61ce
package
mountaincar
.
agent
;
component
MountaincarCritic
{
ports
in
Q
^{
2
}
state
,
in
Q
^{
2
}
action
,
out
Q
(-
1
:
1
)^{
1
}
qvalues
;
implementation
CNN
{
(
state
->
FullyConnected
(
units
=
400
)
->
Relu
()
->
FullyConnected
(
units
=
300
)
|
action
->
FullyConnected
(
units
=
300
)
)
->
Add
()
->
Relu
()
->
FullyConnected
(
units
=
1
)
->
qvalues
;
}
}
\ No newline at end of file
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