improve build process
This commit is contained in:
parent
616f574d64
commit
cb1151c77f
3 changed files with 28 additions and 16 deletions
14
Makefile
14
Makefile
|
@ -17,10 +17,9 @@ format:
|
|||
|
||||
test: build
|
||||
@echo $(EXECUTING)
|
||||
./ftest.native
|
||||
mkdir -p test
|
||||
./ftest.native graphs/graph1
|
||||
@echo $(BUILDING_SVG)
|
||||
@echo "outfile..."
|
||||
@dot -Tsvg test/outfile > test/outfile.svg
|
||||
@echo "graph_init..."
|
||||
@dot -Tsvg test/graph_init > test/graph_init.svg
|
||||
@echo "graph_apply..."
|
||||
|
@ -31,6 +30,7 @@ test: build
|
|||
|
||||
demo: build
|
||||
@echo $(EXECUTING)
|
||||
mkdir -p run
|
||||
./ftest.native graphs/test2 0 5 run/solution
|
||||
@echo $(BUILDING_SVG)
|
||||
@echo "solution..."
|
||||
|
@ -41,6 +41,9 @@ demo: build
|
|||
clean:
|
||||
-rm -rf _build/
|
||||
-rm ftest.native
|
||||
-rm circulationtest.native
|
||||
-rm -rf run/
|
||||
-rm -rf test/
|
||||
|
||||
build_circulation:
|
||||
@echo $(COMPILING)
|
||||
|
@ -50,5 +53,6 @@ demo_circulation: build_circulation
|
|||
@echo $(EXECUTING)
|
||||
./circulationtest.native circulation_input_graphs/test1 run/circulation_solution
|
||||
@echo $(BUILDING_SVG)
|
||||
@echo "solution..."
|
||||
@dot -Tsvg run/circulation_solution > run/circulation_solution.svg
|
||||
@echo "circulation_solution..."
|
||||
@dot -Tsvg run/circulation_solution > run/circulation_solution.svg
|
||||
@echo ""
|
10
README.md
10
README.md
|
@ -23,11 +23,19 @@ Then open VSCode in the root directory of this repository.
|
|||
- code completion
|
||||
- automatic indentation on file save
|
||||
|
||||
## Setup
|
||||
|
||||
This project uses the Graphviz library to render svg graphs. To install it, simply type :
|
||||
|
||||
```shell
|
||||
sudo apt install graphviz
|
||||
```
|
||||
|
||||
## Build and Run
|
||||
|
||||
A makefile provides some useful commands:
|
||||
- `make build` to compile the base ff algorithm. This creates an ftest.native executable
|
||||
- `make test` to run the `ftest` program without arguments (executes tests) and generate svg files for each tests. This uses the `graph1` in the `graphs` folder and outputs in the `test` folder.
|
||||
- `make test` to run the `ftest` program with only the infile (executes tests on it) and generate svg files for each tests. This uses the `graph1` in the `graphs` folder and outputs in the `test` folder.
|
||||
- `make demo` to run the `ftest` program with some arguments and generate the final svg file. This uses graphs in the `graphs` folder and outputs in the `run` folder.
|
||||
- `make build_circulation` to compile the circulation-demand problem resolution. This creates a circulationtest.native executable
|
||||
- `make demo_circulation` to run the `circulationtest` program with some arguments and generate the final svg file. This uses graphs in the `circulation_input_graphs` folder and outputs in the `run` folder.
|
||||
|
|
20
src/ftest.ml
20
src/ftest.ml
|
@ -7,17 +7,17 @@ let flow_to_string gr = gmap gr (fun fl -> String.concat "/" [(string_of_int fl.
|
|||
|
||||
let test_ffalgo_init gr =
|
||||
let graph_init = initialize_graph gr in
|
||||
let () = export "graph_init" (flow_to_string graph_init) in
|
||||
let () = export "test/graph_init" (flow_to_string graph_init) in
|
||||
graph_init
|
||||
|
||||
let test_ffalgo_apply gr =
|
||||
let graph_apply = apply_path gr [(0, 3); (3, 1); (1, 4); (4, 5)] 1 in
|
||||
let () = export "graph_apply" (flow_to_string graph_apply) in
|
||||
let () = export "test/graph_apply" (flow_to_string graph_apply) in
|
||||
graph_apply
|
||||
|
||||
let test_ffalgo_res gr =
|
||||
let graph_res = build_res_graph gr in
|
||||
let () = export "graph_res" (gmap graph_res string_of_int) in
|
||||
let () = export "test/graph_res" (gmap graph_res string_of_int) in
|
||||
graph_res
|
||||
|
||||
let test_ffalgo_min gr =
|
||||
|
@ -43,21 +43,21 @@ let test_ffalgo gr =
|
|||
let () =
|
||||
|
||||
(* Check the number of command-line arguments *)
|
||||
if Array.length Sys.argv <> 5 && Array.length Sys.argv <> 0 then
|
||||
if Array.length Sys.argv <> 5 && Array.length Sys.argv <> 2 then
|
||||
begin
|
||||
Printf.printf "\nUsage: %s infile source sink outfile\n%!" Sys.argv.(0) ;
|
||||
Printf.printf "Or no parameters to run tests\n\n%!" ;
|
||||
Printf.printf "Specify only infile to run tests on it\n\n%!" ;
|
||||
exit 0
|
||||
end ;
|
||||
|
||||
|
||||
(* Arguments are : infile(1) source-id(2) sink-id(3) outfile(4) *)
|
||||
|
||||
if Array.length Sys.argv <> 0 then
|
||||
let infile = Sys.argv.(1)
|
||||
and outfile = Sys.argv.(4)
|
||||
and source = int_of_string Sys.argv.(2)
|
||||
let infile = Sys.argv.(1) in
|
||||
if Array.length Sys.argv <> 2 then
|
||||
let source = int_of_string Sys.argv.(2)
|
||||
and sink = int_of_string Sys.argv.(3)
|
||||
and outfile = Sys.argv.(4)
|
||||
in
|
||||
(* Open file *)
|
||||
let graph = from_file infile in
|
||||
|
@ -74,7 +74,7 @@ let () =
|
|||
else
|
||||
(* TESTS *)
|
||||
(* Open file *)
|
||||
let graph = from_file "graph1" in
|
||||
let graph = from_file infile in
|
||||
let () = test_ffalgo (gmap graph int_of_string) in
|
||||
(* let graph2 = clone_nodes graph in *)
|
||||
(* let graph2 = gmap (gmap (gmap graph int_of_string) (fun x -> x + 1)) string_of_int in *)
|
||||
|
|
Loading…
Reference in a new issue