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
77cb25dd
Commit
77cb25dd
authored
Sep 23, 2013
by
baliosian
Browse files
Merge branch 'withWeights' of
https://github.com/baliosian/tau-fst.git
into withWeights
parents
6031ce5c
39e2278e
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/fsm_template.lua
View file @
77cb25dd
...
...
@@ -99,7 +99,7 @@ local function fst_step()
i_event
=
i_event
+
1
current_state
=
transition
.
new
print
(
current_state
,
#
fsm
[
current_state
],
#
ret_call
,
is_accept
[
current_state
],
#
fsm
[
current_state
]
==
0
)
print
(
"NEW STATE:"
,
current_state
,
"#TRANS:"
,
#
fsm
[
current_state
],
"#RETS:"
,
#
ret_call
,
"ACCEPT:"
,
is_accept
[
current_state
],
"FINAL:"
,
#
fsm
[
current_state
]
==
0
)
return
ret_call
,
is_accept
[
current_state
],
#
fsm
[
current_state
]
==
0
end
...
...
src/uy/edu/fing/mina/fsa/test/RateAndPower_LuPA.java
View file @
77cb25dd
...
...
@@ -66,11 +66,11 @@ public class RateAndPower_LuPA {
//----
s11
.
addOutTran
(
new
Transition
(
tfinp
1
,
ActionTf
.
Epsilon
(),
s12
));
s11
.
addOutTran
(
new
Transition
(
tfinp
1
.
not
(),
ActionTf
.
Epsilon
(),
s11
));
s11
.
addOutTran
(
new
Transition
(
tfinp
2
,
ActionTf
.
Epsilon
(),
s12
));
s11
.
addOutTran
(
new
Transition
(
tfinp
2
.
not
(),
ActionTf
.
Epsilon
(),
s11
));
s12
.
addOutTran
(
new
Transition
(
tfinp
2
,
ActionTf
.
Epsilon
(),
s13
));
s12
.
addOutTran
(
new
Transition
(
tfinp
2
.
not
(),
ActionTf
.
Epsilon
(),
s12
));
s12
.
addOutTran
(
new
Transition
(
tfinp
1
,
ActionTf
.
Epsilon
(),
s13
));
s12
.
addOutTran
(
new
Transition
(
tfinp
1
.
not
(),
ActionTf
.
Epsilon
(),
s12
));
s10
.
addOutTran
(
new
Transition
(
tfinp3
,
ActionTf
.
Epsilon
(),
s11
));
s10
.
addOutTran
(
new
Transition
(
tfinp3
.
not
(),
ActionTf
.
Epsilon
(),
s10
));
...
...
@@ -99,9 +99,16 @@ public class RateAndPower_LuPA {
tffst0
.
inLabelEpsilonRemoval
();
tffst1
.
inLabelEpsilonRemoval
();
tffst2
.
inLabelEpsilonRemoval
();
// Utils.showDot(tffst0.toDot("tffst0"));
// Utils.showDot(tffst1.toDot("tffst1"));
// Utils.showDot(tffst2.toDot("tffst2"));
Tffst
tffst
=
tffst0
.
union
(
tffst1
).
union
(
tffst2
);
// Utils.showDot(tffst.toDot("tffst"));
return
tffst
;
}
...
...
@@ -140,6 +147,12 @@ public class RateAndPower_LuPA {
EventTf
hp
=
new
EventTf
();
hp
.
setName
(
"hp"
);
EventTf
lr
=
new
EventTf
();
lr
.
setName
(
"lr"
);
EventTf
hr
=
new
EventTf
();
hr
.
setName
(
"hr"
);
ActionTf
kr
=
new
ActionTf
();
kr
.
setName
(
"kr"
);
kr
.
setUniverse
(
"rate"
);
...
...
@@ -164,8 +177,8 @@ public class RateAndPower_LuPA {
kp
.
setName
(
"kp"
);
kp
.
setUniverse
(
"power"
);
rules
.
add
(
rap
.
ruleTemplate
(
l
l
.
not
()
,
EventTf
.
Epsilon
(),
hp
,
dr
,
kp
));
rules
.
add
(
rap
.
ruleTemplate
(
l
l
.
not
()
,
EventTf
.
Epsilon
(),
hp
.
not
()
,
kr
,
ip
));
rules
.
add
(
rap
.
ruleTemplate
(
h
l
,
EventTf
.
Epsilon
(),
hp
,
dr
,
kp
));
rules
.
add
(
rap
.
ruleTemplate
(
h
l
,
EventTf
.
Epsilon
(),
lp
,
kr
,
ip
));
rules
.
add
(
rap
.
ruleTemplate
(
ll
,
EventTf
.
Epsilon
(),
EventTf
.
Epsilon
(),
ir
,
kp
));
//TODO que pasa cuando me llegan eventos de rate, los cuales no considero en las reglas
...
...
@@ -195,12 +208,12 @@ public class RateAndPower_LuPA {
//low | high | low | keep | keep
//low | not high | low | increase | keep
//
rules.add(rap.ruleTemplate(
(new SimpleTf("ll")).not() ,(new SimpleTf("lr")).not() ,SimpleTf.Epsilon() , new SimpleTf("dr"), new SimpleTf("kp")
));
//
rules.add(rap.ruleTemplate(
(new SimpleTf("ll")).not() ,(new SimpleTf("lr")) ,(new SimpleTf("hp")) , new SimpleTf("kr"), new SimpleTf("kp")
));
// rules.add(rap.ruleTemplate(
(new SimpleTf("ll")).not() ,(new SimpleTf("lr")) ,(new SimpleTf("hp")).not() , new SimpleTf("kr"), new SimpleTf("ip")
));
// rules.add(rap.ruleTemplate(
(new SimpleTf("ll")) ,SimpleTf.Epsilon() ,(new SimpleTf("lp")).not() , new SimpleTf("kr"), new SimpleTf("dp")
));
// rules.add(rap.ruleTemplate(
(new SimpleTf("ll")) ,(new SimpleTf("hr")) ,(new SimpleTf("lp")) , new SimpleTf("kr"), new SimpleTf("kp")
));
// rules.add(rap.ruleTemplate(
(new SimpleTf("ll")) ,(new SimpleTf("hr")).not() ,(new SimpleTf("lp")) , new SimpleTf("ir"), new SimpleTf("kp")
));
rules
.
add
(
rap
.
ruleTemplate
(
hl
,
hr
,
EventTf
.
Epsilon
(),
dr
,
kp
));
rules
.
add
(
rap
.
ruleTemplate
(
hl
,
lr
,
hp
,
kr
,
kp
));
// rules.add(rap.ruleTemplate(
hl, lr, lp, kr, ip
));
// rules.add(rap.ruleTemplate(
ll, EventTf.Epsilon(), hp, kr, dp
));
// rules.add(rap.ruleTemplate(
ll, hr, lp, kr, kp
));
// rules.add(rap.ruleTemplate(
ll, lr, lp, ir, kp
));
Tffst
rateAndPower
=
new
Tffst
();
...
...
@@ -209,16 +222,16 @@ public class RateAndPower_LuPA {
rateAndPower
=
rateAndPower
.
union
(
tffst
);
}
Utils
.
showDot
(
rateAndPower
.
toDot
(
"before kleene"
));
//
Utils.showDot(rateAndPower.toDot("before kleene"));
rateAndPower
=
rateAndPower
.
kleene
();
Utils
.
showDot
(
rateAndPower
.
toDot
(
"before det"
));
//
Utils.showDot(rateAndPower.toDot("before det"));
rateAndPower
.
setDeterministic
(
false
);
rateAndPower
.
determinize
();
Utils
.
showDot
(
rateAndPower
.
toDot
(
"after all"
));
//
Utils.showDot(rateAndPower.toDot("after all"));
try
{
LupaExporterRatePower
.
generateLupaFiles
(
rateAndPower
,
"src/fsm_template.lua"
,
"fsm_rate_loss"
);
...
...
src/uy/edu/fing/mina/lupa/LupaExporterRatePower.java
View file @
77cb25dd
...
...
@@ -561,7 +561,7 @@ public class LupaExporterRatePower {
out
=
out
.
concat
(
"(1-(functions."
+
functionName
(
function
.
not
())
+
"(lr)))"
+
", "
);
}
else
{
out
=
out
.
concat
(
"functions."
+
functionName
+
", "
);
out
=
out
.
concat
(
"functions."
+
functionName
+
"
(lr)
, "
);
}
}
ActionTf
function
=
(
ActionTf
)
rateIt
.
next
();
...
...
@@ -570,11 +570,11 @@ public class LupaExporterRatePower {
out
=
out
.
concat
(
"(1-(functions."
+
functionName
(
function
.
not
())
+
"(lr)))"
);
}
else
{
out
=
out
.
concat
(
"functions."
+
functionName
);
out
=
out
.
concat
(
"functions."
+
functionName
+
"(lr)"
);
}
size
=
compositeActionsRate
.
size
();
for
(
int
i
=
0
;
i
<
size
-
1
;
i
++){
out
=
out
.
concat
(
"
,lr
)"
);
out
=
out
.
concat
(
")"
);
}
out
=
out
.
concat
(
"\n"
);
...
...
@@ -590,7 +590,7 @@ public class LupaExporterRatePower {
out
=
out
.
concat
(
"(1-(functions."
+
functionName
(
function
.
not
())
+
"(lp)))"
+
", "
);
}
else
{
out
=
out
.
concat
(
"functions."
+
functionName
+
", "
);
out
=
out
.
concat
(
"functions."
+
functionName
+
"
(lp)
, "
);
}
}
function
=
(
ActionTf
)
powerIt
.
next
();
...
...
@@ -599,11 +599,11 @@ public class LupaExporterRatePower {
out
=
out
.
concat
(
"(1-(functions."
+
functionName
(
function
.
not
())
+
"(lp)))"
);
}
else
{
out
=
out
.
concat
(
"functions."
+
functionName
);
out
=
out
.
concat
(
"functions."
+
functionName
+
"(lp)"
);
}
size
=
compositeActionsPower
.
size
();
for
(
int
i
=
0
;
i
<
size
-
1
;
i
++){
out
=
out
.
concat
(
"
,lp
)"
);
out
=
out
.
concat
(
")"
);
}
out
=
out
.
concat
(
"\n"
);
out
=
out
.
concat
(
"\t\t\tif (retRate <= retPower) and (retRate > retMax) then\n"
+
...
...
@@ -638,7 +638,7 @@ public class LupaExporterRatePower {
out
=
out
.
concat
(
"(1-(functions."
+
functionName
(
function
.
not
())
+
"(lr)))"
+
", "
);
}
else
{
out
=
out
.
concat
(
"functions."
+
functionName
+
", "
);
out
=
out
.
concat
(
"functions."
+
functionName
+
"
(lr)
, "
);
}
}
ActionTf
function
=
(
ActionTf
)
rateIt
.
next
();
...
...
@@ -647,11 +647,11 @@ public class LupaExporterRatePower {
out
=
out
.
concat
(
"(1-(functions."
+
functionName
(
function
.
not
())
+
"(lr)))"
);
}
else
{
out
=
out
.
concat
(
"functions."
+
functionName
);
out
=
out
.
concat
(
"functions."
+
functionName
+
"(lr)"
);
}
size
=
compositeActionsRate
.
size
();
for
(
int
i
=
0
;
i
<
size
-
1
;
i
++){
out
=
out
.
concat
(
"
,lr
)"
);
out
=
out
.
concat
(
")"
);
}
out
=
out
.
concat
(
"\n"
);
out
=
out
.
concat
(
"\t\tif ret > retMax then\n"
+
...
...
@@ -679,7 +679,7 @@ public class LupaExporterRatePower {
out
=
out
.
concat
(
"(1-(functions."
+
functionName
(
function
.
not
())
+
"(lp)))"
+
", "
);
}
else
{
out
=
out
.
concat
(
"functions."
+
functionName
+
", "
);
out
=
out
.
concat
(
"functions."
+
functionName
+
"
(lp)
, "
);
}
}
ActionTf
function
=
(
ActionTf
)
powerIt
.
next
();
...
...
@@ -688,11 +688,11 @@ public class LupaExporterRatePower {
out
=
out
.
concat
(
"(1-(functions."
+
functionName
(
function
.
not
())
+
"(lp)))"
);
}
else
{
out
=
out
.
concat
(
"functions."
+
functionName
);
out
=
out
.
concat
(
"functions."
+
functionName
+
"(lp)"
);
}
size
=
compositeActionsPower
.
size
();
for
(
int
i
=
0
;
i
<
size
-
1
;
i
++){
out
=
out
.
concat
(
"
,lp
)"
);
out
=
out
.
concat
(
")"
);
}
out
=
out
.
concat
(
"\n"
);
out
=
out
.
concat
(
"\t\tif ret > retMax then\n"
+
...
...
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