Commit 4aed6dc3 authored by Erwan Jahier's avatar Erwan Jahier
Browse files

lurette 1.1 Mon, 08 Sep 2003 16:02:09 +0200 by jahier

Parent-Version:      0.143
Version-Log:

Major change in the lucky syntax.

Also add structured types (in lucky only, for the time being).

Project-Description: Lurette
parent 2b40538c
This diff is collapsed.
*********** BUGS
:-)
* ZZZ une contrainte du style "0<x<100 and x<>2" va tirer "1" une fois sur 2 !!!
car "x<>2" est traduit en "x<2 or x>2" et le choix sur le or est effectué de
facon équitable ...
En particulier, je ne peux donc pas representer des enum par des entiers...
=> Solution on remonte du bdd le nombre de solutions entieres presentes
a chaque feuille.
pour cela, je dois changer un peu de philosophie (cf solver.ml).
Avant:
1- calcul du nombre de solutions d'un point de vue Booleen
2- tirage dans le bdd tenant compte des poids obtenu en (1)
en verifiant au fur et a mesure les contraintes numeriques
faciles, a savoir celles de dimensions 1
3- une fois aux feuilles, s'il reste des contraintes de dimensions > 1,
faire appel à Polka.
Apres:
1- calcul du nombre de solutions d'un point de vue Booleen ET
des variables numériques de dimension 1.
2- tirage dans le bdd tenant compte des poids obtenu en (1)
3- comme avant
en d'autre termes, je fais la vérif de satisfiabilité des intervalles
lors du calcul du nombre de solutions, et pas lors du tirage dans le bdd.
*********** A faire maintenant
* install: gnuplot-rif n'est pas dans le path
* Nouvelle syntaxe pour lucky
*********** A faire maintenant
* renommer les scripts et les executables comme suit:
- les noeuds sont des string
- les formules ont la syntaxe lustre
- syntaxe concrete :
xlurette -> xlurette_exe
xlurette.sh -> xlurette
les declarations de types:
et ainsi de suite ...
typedef {
Ident : TypeExp ;
ex_array : bool ^ 3 ;
ex_struct : {a:bool; b: float} ;
ex_enum : (bleu, blanc, rouge) ;
}
* rajouter un jeu de test testant les types structures ainsi que la
nouvelle syntaxe (gestions des poids dynamique, etc.)
les declarations de variables:
inputs { -- (resp output, locals)
Ident : type [-Flag = Exp ]* ;
* Integrer la possibilité d'utiliser des types structurés avec lurette et scade
v : float -min 1 -max 10 -default 5 ;
u : bool -alias (v > 6) ;
}
* Faire un lustre2lucky comme TP avec Yussef
Exp = Feuille | ( Arbre )
* Faire l'elimination des DAGS, ie,
finir la fonction duplicate_graph_from_node automata.ml
Flag = -min | -max | -default | -alias
* faire un passage sur map vs rev_map
Les noeuds :
InitialNode ::=
initial { Ident }
* documenter les options ~default, ~alias, etc.
Nodes ::=
nodes {
Ident : <stable | transient> [-NodeFlag = Value]* ;
}
* Signaler les approximations faites (en dimension > 1)
- volumes des polyhedres pas calculés (=> pb d'equité)
- pour le choix des entiers, on travaille dans les reels,
puis on tronque (truncate) => l'entier tiré n'est alors parfois
meme pas solution des contraintes !!!
N.B. pour l'instant pas de NodeFlag
* dire dans la doc que on ne peut avoir qu'au plus une transition sortante
avec un poids infini (ca n'a pas un sens bien clair et on peut toujours
faire autrement). Dire aussi que 2 transitions ne peuvent a la fois avoir
meme origine et arrivée.
Les transitions :
Transitions ::=
transitions {
Ident -> Ident [-TransFlag = Exp]* ;
ex_etat1 -> ex_etat2 -weight 3 -formula (x >= 4)
}
* ajouter les options --product-mode {multiply | arbiter}
qui disent comment on multiplie 2 automates (cf papier)
* env_state devrait etre un objet ...
(1) Portage pour scade, esterel ...
-> structure, tableau, types structures, etc.
(1) Portage Reluc
......@@ -146,8 +162,6 @@ Les transitions :
* Ecrire une batterie de test plus sérieuse !
* Ecrire un papier qui explique la transformation en automate.
* Réfléchir à une version d'un tireur sans bdd ou les choix seraient
effectués pendant le parcours de la formule (pas d'équité, mais bon) +
......
inputs = (Heat_on , bool),
outputs = (U,float),
locals = (Dudt ,float),
pre = (pre(1,U),float); (pre(1, Dudt), float) ,
ctrl_expr = ,
start_node = 0,
arcs_nb = 0,
nodes_nb = 0,
arcs =
From 0 To 1 With 1:(&& (= U 17.5) (= Dudt 0.1)) ;
From 1 To 1 With
1:
( && (= U pre(1,U) + pre(1, Dudt))
&& ( > Dudt (IfThenElseNum Heat_on 0. (- 5.)))
( < Dudt (IfThenElseNum Heat_on 2. 0.) )
) .
inputs {
Heat_on %this_a_label:this is a pragma%
%this_is_another_label: "and this is another pragma"%
: bool
}
outputs {
U:real ~min 1. ~max 60
}
locals {
Dudt %scr:15,2,16,2% %foo:bar%
: float ~min -100. ~max 100.
}
start_node { 0 }
nodes {
}
transitions {
0 -> %titi: transition pragma %
1 ~cond ((U = 17.0) and (Dudt = 0.0)) ;
1 -> 1 ~cond
%toto:this is a formula pragma%
-- %titi: this is an other one %
((U = pre(U) + pre(Dudt)) and
(Dudt > (if Heat_on then 0.0 else -5.0))
and
( (1.0 * Dudt + 0.0) < (if Heat_on then 2.0 else 0.0)))
}
......@@ -1326,13 +1326,13 @@ let toolbar8 = GButton.toolbar
()
in
let sim2chro = toolbar8#insert_button
~text: "sim2chro"
~text: "View with sim2chro"
~icon:(GMisc.pixmap (GDraw.pixmap_from_xpm ~file:((Unix.getenv "PIXMAP_DIR") ^ "chrono.xpm") ()) ())#coerce
()
in
let _ = tooltips#set_tip ~text:"Call sim2chro with the selected file" sim2chro#coerce in
let button39 = toolbar8#insert_button
~text: "gnuplot "
~text: "View with gnuplot "
~icon:(GMisc.pixmap (GDraw.pixmap_from_xpm ~file:((Unix.getenv "PIXMAP_DIR") ^ "gnuplot-rif.xpm") ()) ())#coerce
()
in
......@@ -1343,6 +1343,11 @@ let delete_rif_button = toolbar8#insert_button
()
in
let _ = tooltips#set_tip ~text:"Delete selected file" delete_rif_button#coerce in
let edit_rif = toolbar8#insert_button
~text: "Edit "
~icon:(GMisc.pixmap (GDraw.pixmap_from_xpm ~file:((Unix.getenv "PIXMAP_DIR") ^ "open.xpm") ()) ())#coerce
()
in
let label27 = GMisc.label
~text: "This page does not work yet, sorry"
~packing:(vbox15#pack ~padding:0
......@@ -1535,6 +1540,7 @@ method toolbar8 = toolbar8
method sim2chro = sim2chro
method button39 = button39
method delete_rif_button = delete_rif_button
method edit_rif = edit_rif
method label27 = label27
method time_diagrams_label = time_diagrams_label
initializer callbacks#set_xlurette self;
......@@ -2209,25 +2215,6 @@ let extra_includedirs_label = GMisc.label
~line_wrap:false
()
in
let extra_cfiles_entry = GEdit.entry
~packing:(table7#attach ~left:1
~top:0
~right:2
~bottom:1
~xpadding:0
~ypadding:0
~expand:`X
~shrink:`NONE
~fill:`X
)
~width:400
~max_length:0
~visibility:true
~editable:true
()
in
let _ = GtkBase.Widget.set_can_focus extra_cfiles_entry#as_widget true in
let _ = tooltips#set_tip ~text:"Set the EXTRA_CFILES environment variable. May be necessary if the sut or the oracle uses external C files " extra_cfiles_entry#coerce in
let extra_libs_entry = GEdit.entry
~packing:(table7#attach ~left:1
~top:1
......@@ -2374,6 +2361,25 @@ let button66 = toolbar19#insert_button
()
in
let _ = tooltips#set_tip ~text:"Browse for a directory" button66#coerce in
let extra_cfiles_entry = GEdit.entry
~packing:(table7#attach ~left:1
~top:0
~right:2
~bottom:1
~xpadding:0
~ypadding:0
~expand:`X
~shrink:`NONE
~fill:`X
)
~width:400
~max_length:0
~visibility:true
~editable:true
()
in
let _ = GtkBase.Widget.set_can_focus extra_cfiles_entry#as_widget true in
let _ = tooltips#set_tip ~text:"Set the EXTRA_CFILES environment variable. May be necessary if the sut or the oracle uses external C files " extra_cfiles_entry#coerce in
let vbox22 = GPack.vbox
~spacing:0
~homogeneous:true
......@@ -2440,7 +2446,6 @@ method extra_cfiles_label = extra_cfiles_label
method extra_libs_label = extra_libs_label
method extra_libdirs_label = extra_libdirs_label
method extra_includedirs_label = extra_includedirs_label
method extra_cfiles_entry = extra_cfiles_entry
method extra_libs_entry = extra_libs_entry
method extra_libdirs_entry = extra_libdirs_entry
method extra_includedirs_entry = extra_includedirs_entry
......@@ -2452,6 +2457,7 @@ method toolbar18 = toolbar18
method button65 = button65
method toolbar19 = toolbar19
method button66 = button66
method extra_cfiles_entry = extra_cfiles_entry
method vbox22 = vbox22
method vbox23 = vbox23
method hbox20 = hbox20
......
......@@ -85,12 +85,21 @@ let (give_fresh_file_name : string -> string -> string) =
let get_rif_file _ = !rif_file
let chop_ext file =
try Filename.chop_extension file
with _ -> file
let (update_rif_file_name : string -> string -> string -> string -> unit) =
fun rif_base_name0 str1 str2 str3 ->
fun rif_base_name0 sut_str env_str0 l_str ->
(*
invent a fresh file name, using the provided in rif_base_name0 if not
empty, the 3 other strings otherwise
*)
let str_list = Str.split (Str.regexp " ") env_str0 in
let env_str =
(* when several env are involved, this string contains blank char *)
String.concat "-" (List.map (chop_ext) str_list)
in
let rif_base_name =
if
rif_base_name0 <> ""
......@@ -98,7 +107,7 @@ let (update_rif_file_name : string -> string -> string -> string -> unit) =
rif_base_name0
else
(* We invent a name if no one is provided *)
(str1 ^ "-" ^ str2 ^ "-" ^ str3 ^ "-")
(sut_str ^ "-" ^ env_str ^ "-" ^ l_str ^ "-")
in
rif_file := (give_fresh_file_name rif_base_name ".rif")
......@@ -298,7 +307,7 @@ class customized_callbacks = object(self)
let lurette_pid = String.sub str 22 ((String.length str) - 22) in
lpid := int_of_string lurette_pid;
()
else if
String.length str > 36
&& String.sub str 0 34 = "The random engine was initialized "
......@@ -342,7 +351,7 @@ class customized_callbacks = object(self)
with _ -> ()
);
true
method show_step_window () =
self#top_step_by_step_window#step_by_step_window#show ()
......@@ -352,7 +361,7 @@ class customized_callbacks = object(self)
flush oc;
self#top_xlurette#output_window#insert "Clean-up temporary files ...\n"
(* sut help window *)
method on_sut_help_button_clicked () =
......@@ -364,14 +373,14 @@ class customized_callbacks = object(self)
(* env help window *)
method on_env_help_button_clicked () =
self#top_env_help_window#env_help_window#show ()
method ok_env_help_clicked () =
self#top_env_help_window#env_help_window#misc#hide ()
(* oracle help window *)
method on_oracle_help_button_clicked () =
self#top_oracle_help_window#oracle_help_window#show ()
method ok_oracle_help_clicked () =
self#top_oracle_help_window#oracle_help_window#misc#hide ()
......@@ -588,41 +597,41 @@ class customized_callbacks = object(self)
method on_delete_rif_button_clicked () =
(* Sys.remove *)
(* let _ = (self#top_xlurette#list_rif_files#clear_item 1) *)
(* ~callback: *)
(* (begin fun li -> *)
(* let text = (List.hd li#children)#misc#name in *)
(* print_string text; *)
(* end *)
(* ) *)
(* in *)
output_string oc "\nDelete file \n";
flush oc
(* Sys.remove *)
(* let _ = (self#top_xlurette#list_rif_files#clear_item 1) *)
(* ~callback: *)
(* (begin fun li -> *)
(* let text = (List.hd li#children)#misc#name in *)
(* print_string text; *)
(* end *)
(* ) *)
(* in *)
output_string oc "\nDelete file \n";
flush oc
method gnuplot_rif () =
let cmd_display =
if (get_rif_file ()) = "" then "" else
("set_output \"" ^ (get_rif_file ()) ^ "\"\n" ^ "gnuplot\n")
("set_output \"" ^ (get_rif_file ()) ^ "\"\n" ^ "gnuplot\n")
in
output_string oc cmd_display ;
if debug then (output_string stderr cmd_display;flush stderr);
flush oc
method call_sim2chro_clicked () =
let cmd_display =
if (get_rif_file ()) = "" then "" else
("set_output \"" ^ (get_rif_file ()) ^ "\"\n" ^ "sim2chro\n")
("set_output \"" ^ (get_rif_file ()) ^ "\"\n" ^ "sim2chro\n")
in
output_string oc cmd_display ;
if debug then (output_string stderr cmd_display;flush stderr);
flush oc
(* returns all the command to be sent to lurettetop in order to run the test *)
method get_all_cmds () =
let sut = String.escaped self#top_xlurette#sut_name#entry#text
and sut_node = self#top_xlurette#sut_node#entry#text in
......@@ -638,8 +647,14 @@ class customized_callbacks = object(self)
let cmd_sut_compiler =
("set_sut_compiler " ^ (self#get_sut_compiler ()) ^ "\n")
in
in
let cmd_oracle_compiler =
if
self#top_xlurette#oracle_name#entry#text = ""
then
(* to be sure we use a compiler that is installed *)
self#set_oracle_compiler (self#get_sut_compiler ());
("set_oracle_compiler " ^ (self#get_oracle_compiler ()) ^ "\n")
in
......@@ -706,14 +721,14 @@ class customized_callbacks = object(self)
("set_extra_cfiles \"" ^
(String.escaped self#top_extra_env_var_window#extra_cfiles_entry#text) ^ "\"\n")
and extra_libs =
("set_extra_libs \"" ^
(String.escaped self#top_extra_env_var_window#extra_libs_entry#text) ^ "\"\n")
("set_extra_libs \"" ^
(String.escaped self#top_extra_env_var_window#extra_libs_entry#text) ^ "\"\n")
and extra_libdirs =
("set_extra_libdirs \"" ^
(String.escaped self#top_extra_env_var_window#extra_libdirs_entry#text) ^ "\"\n")
("set_extra_libdirs \"" ^
(String.escaped self#top_extra_env_var_window#extra_libdirs_entry#text) ^ "\"\n")
and extra_includedirs =
("set_extra_includedirs \"" ^
(String.escaped self#top_extra_env_var_window#extra_includedirs_entry#text) ^ "\"\n")
("set_extra_includedirs \"" ^
(String.escaped self#top_extra_env_var_window#extra_includedirs_entry#text) ^ "\"\n")
in
cmd_test_length ^ cmd_formula_nb ^ cmd_draw_nb
......@@ -723,133 +738,133 @@ class customized_callbacks = object(self)
extra_cfiles ^ extra_libs ^ extra_libdirs ^ extra_includedirs
method on_sut_name_changed () =
let sut = self#top_xlurette#sut_name#entry#text in
if
sut = ""
then
(
self#top_xlurette#sut_node#entry#set_text "";
self#top_xlurette#env_name_entry#entry#set_text ""
)
else
(
let nodes = (lusinfo self#top_xlurette#sut_name#entry#text) in
if
(* this test is to avoid spurious strings to be written *)
nodes <> []
then
(
self#top_xlurette#sut_node#set_popdown_strings nodes;
let sut_node = self#top_xlurette#sut_node#entry#text in
if
sut_node <> !pre_sut_node
then
(
self#top_xlurette#env_name_entry#entry#set_text "";
pre_sut_node := sut_node
)
)
)
method on_sut_node_changed () =
let sut_node = self#top_xlurette#sut_node_entry#entry#text in
if
sut_node <> !pre_sut_node
then
(
self#top_xlurette#env_name_entry#entry#set_text "" ;
self#top_xlurette#oracle_name_entry#entry#set_text "" ;
self#top_xlurette#oracle_node_entry#entry#set_text "" ;
pre_sut_node := sut_node
)
method read_lustre_files () =
let files = (get_files_list_filtered "*.lus *.saofdm" [""]) in
let sut = self#top_xlurette#sut_name#entry#text
and oracle = self#top_xlurette#oracle_name#entry#text
and sut_node = self#top_xlurette#sut_node_entry#entry#text
and oracle_node = self#top_xlurette#oracle_node_entry#entry#text
in
if files <> [] then
(
self#top_xlurette#sut_name#set_popdown_strings files ;
self#top_xlurette#oracle_name#set_popdown_strings files ;
self#top_xlurette#sut_name#entry#set_text sut;
self#top_xlurette#oracle_name#entry#set_text oracle;
self#top_xlurette#sut_node_entry#entry#set_text sut_node;
self#top_xlurette#oracle_node_entry#entry#set_text oracle_node
)
method on_sut_name_changed () =
let sut = self#top_xlurette#sut_name#entry#text in
if
sut = ""
then
(
self#top_xlurette#sut_node#entry#set_text "";
self#top_xlurette#env_name_entry#entry#set_text ""
)
else
(
let nodes = (lusinfo self#top_xlurette#sut_name#entry#text) in
if
(* this test is to avoid spurious strings to be written *)
nodes <> []
then
(
self#top_xlurette#sut_node#set_popdown_strings nodes;
let sut_node = self#top_xlurette#sut_node#entry#text in
if
sut_node <> !pre_sut_node
then
(
self#top_xlurette#env_name_entry#entry#set_text "";
pre_sut_node := sut_node
)
)
)
method read_env_files () =
let env = self#top_xlurette#env_name#entry#text in
let files = (get_files_list_filtered "*.lut *.luc" [""]) in
if files <> [] then
(
self#top_xlurette#env_name#set_popdown_strings files ;
self#top_xlurette#env_name#entry#set_text env
)
method on_sut_node_changed () =
let sut_node = self#top_xlurette#sut_node_entry#entry#text in
if
sut_node <> !pre_sut_node
then
(
self#top_xlurette#env_name_entry#entry#set_text "" ;
self#top_xlurette#oracle_name_entry#entry#set_text "" ;
self#top_xlurette#oracle_node_entry#entry#set_text "" ;
pre_sut_node := sut_node
)
method read_rif_files () =
(* let rif_files = (List.rev (get_files_list_filtered "*.rif" [])) in *)
(* if rif_files <> [] then *)
(* self#top_xlurette#list_rif_files#clear_items 0 100; *)
(* ( *)
(* let _ = *)
(* List.fold_left *)
(* (fun i str -> *)
(* let li = (GTree.tree_item ~label:str ()) in *)
(* self#top_xlurette#list_rif_files#insert li ~pos:i; *)
(* (i+1) *)
(* ) *)
(* 1 *)
(* rif_files *)
(* in *)
()
(* self#top_xlurette#env_name#entry#set_text env *)
(* ) *)
method on_oracle_name_changed () =
let oracle = self#top_xlurette#oracle_name#entry#text in
if oracle <> "" then
let nodes = (lusinfo oracle) in
if nodes <> [] then self#top_xlurette#oracle_node#set_popdown_strings nodes;
else
self#top_xlurette#oracle_node_entry#entry#set_text ""
method run_lurette () =
update_rif_file_name
self#top_xlurette#rif_file_basename#text
(remove_extension self#top_xlurette#sut_name_entry#entry#text)
(remove_extension self#top_xlurette#env_name_entry#entry#text)
self#top_xlurette#test_length#text ;
(* .saofdm must be compiled with scade.*)
if
Filename.check_suffix self#top_xlurette#sut_name_entry#entry#text ".saofdm"
then