Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Benoit Barbot
WordGen
Commits
7fc577a7
Commit
7fc577a7
authored
Oct 08, 2021
by
Benoit Barbot
Browse files
fix graphviz
parent
4e8af1e3
Pipeline
#2287
passed with stages
in 1 minute and 39 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
web-view/worker.ml
View file @
7fc577a7
...
...
@@ -12,16 +12,16 @@ let only_parse = ref false
let
computation
ta
outfile
=
if
!
only_parse
then
npoly
:=
-
1
;
let
module
Bound
=
(
val
if
!
npoly
<
0
then
(
module
ZoneGraphInput
.
GeneralBound
:
ZoneGraphInput
.
BoundType
)
else
(
module
ZoneGraphInput
.
LinearBound
)
)
(
val
if
!
npoly
<
0
then
(
module
ZoneGraphInput
.
GeneralBound
:
ZoneGraphInput
.
BoundType
)
else
(
module
ZoneGraphInput
.
LinearBound
))
in
let
module
ZGI
=
ZoneGraphInput
.
Make
(
Bound
)
in
let
rg
=
ZGI
.
input_from_string
ta
in
Js_of_ocaml
.
Worker
.
post_message
ParseOK
;
let
module
Param
=
(
val
Compute
.
gen_param
rg
.
ZoneGraph
.
var_string
!
rational_impl
!
frequency
!
expected_duration
!
boltzmann_param
!
expected_size
!
verbose
!
npoly
)
(
val
Compute
.
gen_param
rg
.
ZoneGraph
.
var_string
!
rational_impl
!
frequency
!
expected_duration
!
boltzmann_param
!
expected_size
!
verbose
!
npoly
)
in
if
not
!
only_parse
then
(
let
module
Weight
=
Compute
.
Instantiate
(
Fl
.
Num
)
(
Bound
)
(
Param
)
()
in
...
...
@@ -31,12 +31,19 @@ let computation ta outfile =
Weight
.
compute_params
?
seed
:!
random_seed
!
template
rgpoly
in
if
!
print_rg
then
printf
"%a@."
(
ZoneGraph
.
print
Bound
.
print
)
rgpoly
;
if
!
print_rg
then
(
let
buff
=
Buffer
.
create
100
in
let
form
=
Format
.
formatter_of_buffer
buff
in
ZoneGraph
.
print_dot
rgpoly
Bound
.
print
form
;
Format
.
fprintf
form
"@."
;
Format
.
printf
"%a@."
(
ZoneGraph
.
print
Bound
.
print
)
rgpoly
;
Js_of_ocaml
.
Worker
.
post_message
(
Graph
(
String
.
escaped
(
Buffer
.
contents
buff
))));
Weight
.
sample
smp
~
outfile
?
seed
:!
Arguments
.
random_seed
?
boltz
~
out_style
:
(
!
out_style
,
false
)
~
max_iter
:!
max_iteration
~
sampler
:
(
Low_disc_sampler
.
get_sampler
!
sampler
)
~
store_traj
:!
store_traj
rgpoly
!
template
!
nbtraj
)
~
store_traj
:!
store_traj
rgpoly
!
template
!
nbtraj
)
let
main
cmd
ta
out_formatter
=
reset
spec_short
;
...
...
@@ -59,27 +66,27 @@ let _ =
print_endline "Stop"
| Task x ->*)
(
is_stopped
:=
false
;
print_endline
"New Job"
;
let
buff_std
=
Buffer
.
create
10
in
Format
.
set_formatter_output_functions
(
Buffer
.
add_substring
buff_std
)
(
fun
()
->
let
m
=
Buffer
.
contents
buff_std
in
Buffer
.
clear
buff_std
;
Js_of_ocaml
.
Worker
.
post_message
(
StdOut
m
));
let
buff_out
=
Buffer
.
create
100
in
let
out_formatter
=
Format
.
make_formatter
(
Buffer
.
add_substring
buff_out
)
(
fun
()
->
let
m
=
Buffer
.
contents
buff_out
in
Buffer
.
clear
buff_out
;
Js_of_ocaml
.
Worker
.
post_message
(
Data
m
))
in
(*computation out_formatter x;*)
try
main
cmd
ta
out_formatter
;
Js_of_ocaml
.
Worker
.
post_message
Finish
with
|
Interrupted
->
()
|
x
->
Js_of_ocaml
.
Worker
.
post_message
(
Error
(
String
.
escaped
(
Printexc
.
to_string
x
)))
))
(
is_stopped
:=
false
;
print_endline
"New Job"
;
let
buff_std
=
Buffer
.
create
10
in
Format
.
set_formatter_output_functions
(
Buffer
.
add_substring
buff_std
)
(
fun
()
->
let
m
=
Buffer
.
contents
buff_std
in
Buffer
.
clear
buff_std
;
Js_of_ocaml
.
Worker
.
post_message
(
StdOut
m
));
let
buff_out
=
Buffer
.
create
100
in
let
out_formatter
=
Format
.
make_formatter
(
Buffer
.
add_substring
buff_out
)
(
fun
()
->
let
m
=
Buffer
.
contents
buff_out
in
Buffer
.
clear
buff_out
;
Js_of_ocaml
.
Worker
.
post_message
(
Data
m
))
in
(*computation out_formatter x;*)
try
main
cmd
ta
out_formatter
;
Js_of_ocaml
.
Worker
.
post_message
Finish
with
|
Interrupted
->
()
|
x
->
Js_of_ocaml
.
Worker
.
post_message
(
Error
(
String
.
escaped
(
Printexc
.
to_string
x
)))))
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment