Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Javier Baliosian
Learning FSTs
Commits
2235dca8
Commit
2235dca8
authored
Sep 17, 2013
by
Matias Richart
Browse files
final adhoc exporter for rate and power rules
parent
c76234c6
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/fsm_template.lua
View file @
2235dca8
...
...
@@ -114,7 +114,7 @@ function step()
if
ret_step
then
for
_
,
r
in
ipairs
(
ret_step
)
do
ret
[
#
ret
+
1
]
=
r
end
--queue generated actions
end
until
accept
or
i_event
==
#
window
until
accept
or
i_event
>
#
window
assert
(
not
(
final
and
not
accept
))
if
accept
then
...
...
src/uy/edu/fing/mina/fsa/test/RateAndPower_LuPA.java
View file @
2235dca8
...
...
@@ -69,7 +69,7 @@ public class RateAndPower_LuPA {
//-------------------------------------------------------------
//not low | | high | decrease | keep
//not low | | not high | keep | increase
//low | | |
keep
| keep
//low | | |
increase
| keep
EventTf
ll
=
new
EventTf
();
ll
.
setName
(
"ll"
);
...
...
@@ -97,6 +97,10 @@ public class RateAndPower_LuPA {
dr
.
setName
(
"dr"
);
dr
.
setUniverse
(
"rate"
);
ActionTf
ir
=
new
ActionTf
();
ir
.
setName
(
"ir"
);
ir
.
setUniverse
(
"rate"
);
ActionTf
ip
=
new
ActionTf
();
ip
.
setName
(
"ip"
);
ip
.
setUniverse
(
"power"
);
...
...
@@ -109,9 +113,9 @@ public class RateAndPower_LuPA {
kp
.
setName
(
"kp"
);
kp
.
setUniverse
(
"power"
);
/*
rules.add(rap.ruleTemplate(ll.not(), EventTf.Epsilon(), hp, dr, kp));
rules
.
add
(
rap
.
ruleTemplate
(
ll
.
not
(),
EventTf
.
Epsilon
(),
hp
,
dr
,
kp
));
rules
.
add
(
rap
.
ruleTemplate
(
ll
.
not
(),
EventTf
.
Epsilon
(),
hp
.
not
(),
kr
,
ip
));
rules.add(rap.ruleTemplate(ll, EventTf.Epsilon(), EventTf.Epsilon(),
k
r, kp));
*/
rules
.
add
(
rap
.
ruleTemplate
(
ll
,
EventTf
.
Epsilon
(),
EventTf
.
Epsilon
(),
i
r
,
kp
));
//-----------------------------------------------------------
...
...
@@ -121,7 +125,7 @@ public class RateAndPower_LuPA {
//rules.add(rap.ruleTemplate(new CompositeTf(Operator.AND,hl,ml), EventTf.Epsilon(),lp , ip.not(), (new CompositeTf(Operator.AND,ip,kr.not())).not()));
rules
.
add
(
rap
.
ruleTemplate
(
hl
,
EventTf
.
Epsilon
(),
lp
,
ip
.
not
(),
kr
));
//
rules.add(rap.ruleTemplate(hl, EventTf.Epsilon(),lp , ip.not(), kr));
//rules.add(rap.ruleTemplate(ml, SimpleTf.Epsilon(),mp , kr, new CompositeTf("AND", ip, new CompositeTf("AND",kr,dp))));
// rules.add(rap.ruleTemplate((new SimpleTf("hl")) , SimpleTf.Epsilon(),(new SimpleTf("mp")) , new SimpleTf("kr"), new SimpleTf("ip")));
// rules.add(rap.ruleTemplate((new SimpleTf("ll")) , SimpleTf.Epsilon(),(new SimpleTf("pi")) , new SimpleTf("kr"), new SimpleTf("kp")));
...
...
src/uy/edu/fing/mina/lupa/LupaExporterRatePower.java
View file @
2235dca8
...
...
@@ -426,7 +426,7 @@ public class LupaExporterRatePower {
"\t\t\tl = lr\n"
+
"\t\tend\n"
+
"\tend\n"
+
"\treturn notifs.change
R
ate(l,e)\n"
+
"\treturn notifs.change
_r
ate(l,e)\n"
+
"end\n"
);
}
else
{
...
...
@@ -440,15 +440,23 @@ public class LupaExporterRatePower {
"\t\t\tl = lp\n"
+
"\t\tend\n"
+
"\tend\n"
+
"\treturn notifs.change
P
ower(l,e)\n"
+
"end\n"
);
"\treturn notifs.change
_p
ower(l,e)\n"
+
"end\n
\n
"
);
}
out
=
out
.
concat
(
"\t-- "
+
function
Header
+
"\n"
);
out
=
out
.
concat
(
"functions."
+
functionName
+
" = function(
e
)\n"
);
out
=
out
.
concat
(
"\t--
Membership function for
"
+
function
Name
+
"\n"
);
out
=
out
.
concat
(
"functions."
+
functionName
+
" = function(
l
)\n"
);
out
=
out
.
concat
(
"\t------------------------------------------------\n"
);
out
=
out
.
concat
(
"\t-- TODO: Complete this with your function code. --\n"
);
out
=
out
.
concat
(
"\t------------------------------------------------\n"
);
out
=
out
.
concat
(
"end\n\n"
);
// out = out.concat("\t-- Notification generator for " + functionName + "\n");
// out = out.concat("notifs." + functionName + " = function(l,e)\n");
// out = out.concat("\t------------------------------------------------\n");
// out = out.concat("\t-- TODO: Complete this with your notification code. --\n");
// out = out.concat("\t------------------------------------------------\n");
// out = out.concat("end\n\n");
}
}
...
...
@@ -562,7 +570,7 @@ public class LupaExporterRatePower {
out
=
out
.
concat
(
"(1-(functions."
+
functionName
(
function
.
not
())
+
"(lr)))"
);
}
else
{
out
=
out
.
concat
(
"functions."
+
functionName
+
"(lr)
,
"
);
out
=
out
.
concat
(
"functions."
+
functionName
+
"(lr)"
);
}
size
=
compositeActionsRate
.
size
();
for
(
int
i
=
0
;
i
<
size
-
1
;
i
++){
...
...
@@ -591,7 +599,7 @@ public class LupaExporterRatePower {
out
=
out
.
concat
(
"(1-(functions."
+
functionName
(
function
.
not
())
+
"(lp)))"
);
}
else
{
out
=
out
.
concat
(
"functions."
+
functionName
+
"(lp)
,
"
);
out
=
out
.
concat
(
"functions."
+
functionName
+
"(lp)"
);
}
size
=
compositeActionsPower
.
size
();
for
(
int
i
=
0
;
i
<
size
-
1
;
i
++){
...
...
@@ -609,7 +617,7 @@ public class LupaExporterRatePower {
"\t\t\tend\n"
+
"\t\tend\n"
+
"\tend\n"
+
"\treturn notifs.change
R
ate
AndP
ower(lRate,lPower,e)\n"
+
"\treturn notifs.change
_r
ate
_p
ower(lRate,lPower,e)\n"
+
"end\n"
);
}
...
...
@@ -639,7 +647,7 @@ public class LupaExporterRatePower {
out
=
out
.
concat
(
"(1-(functions."
+
functionName
(
function
.
not
())
+
"(lr)))"
);
}
else
{
out
=
out
.
concat
(
"functions."
+
functionName
+
"(lr)
,
"
);
out
=
out
.
concat
(
"functions."
+
functionName
+
"(lr)"
);
}
size
=
compositeActionsRate
.
size
();
for
(
int
i
=
0
;
i
<
size
-
1
;
i
++){
...
...
@@ -651,7 +659,7 @@ public class LupaExporterRatePower {
"\t\t\tl = lr\n"
+
"\t\tend\n"
+
"\tend\n"
+
"\treturn notifs.change
R
ate(l,e)\n"
+
"\treturn notifs.change
_r
ate(l,e)\n"
+
"end\n"
);
}
else
{
...
...
@@ -680,7 +688,7 @@ public class LupaExporterRatePower {
out
=
out
.
concat
(
"(1-(functions."
+
functionName
(
function
.
not
())
+
"(lp)))"
);
}
else
{
out
=
out
.
concat
(
"functions."
+
functionName
+
"(lp)
,
"
);
out
=
out
.
concat
(
"functions."
+
functionName
+
"(lp)"
);
}
size
=
compositeActionsPower
.
size
();
for
(
int
i
=
0
;
i
<
size
-
1
;
i
++){
...
...
@@ -692,7 +700,7 @@ public class LupaExporterRatePower {
"\t\t\tl = lr\n"
+
"\t\tend\n"
+
"\tend\n"
+
"\treturn notifs.change
P
ower(l,e)\n"
+
"\treturn notifs.change
_p
ower(l,e)\n"
+
"end\n"
);
}
}
...
...
@@ -996,7 +1004,6 @@ public class LupaExporterRatePower {
* @throws UnsupportedTFFSTException
*/
public
static
void
generateLupaFiles
(
Tffst
fst
,
String
templateFilename
,
String
filename
)
throws
UnsupportedTFFSTException
{
try
{
functionsCounter
=
new
Integer
(
0
);
functionNames
=
new
HashMap
<
TfI
,
String
>();
mainEvents
=
new
HashMap
<
String
,
TfI
>();
...
...
@@ -1005,17 +1012,14 @@ public class LupaExporterRatePower {
compositeActions
=
new
HashMap
<
String
,
ArrayList
<
ArrayList
<
TfI
>>>();
// Tffst proctffst = fst.toSimpleTransitions();
Tffst
proctffst
;
proctffst
=
fst
.
clone
();
//
Tffst proctffst;
//
proctffst = fst.clone();
loadActionsAndEvents
(
proctf
fst
);
loadActionsAndEvents
(
fst
);
String
manualFunctions
=
updateManualLupa
(
proctf
fst
,
filename
);
String
manualFunctions
=
updateManualLupa
(
fst
,
filename
);
writeGeneratedLupa
(
proctffst
,
templateFilename
,
filename
,
manualFunctions
);
}
catch
(
CloneNotSupportedException
e
)
{
e
.
printStackTrace
();
}
writeGeneratedLupa
(
fst
,
templateFilename
,
filename
,
manualFunctions
);
}
}
...
...
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