INSA 4IR- OCaml Project - Graph & Constraint Programming
This project is done by : TRAN Trong Hieu & TRAN Le Minh, a pair of students in 4IR, INSA Toulouse.
This project consists of implementing an algorithm computing the max-flow of a flow graph, based on Ford–Fulkerson algorithm, and optionally improve it to take into account other constraints (e.g. minimize cost).
ocamlbuild ftest.byte
to build the bytecode executable, or ocamlbuild ftest.native
to build the native executable. You might choose only one of these 2 methods../ftest.byte
or ./ftest.native
according to chosen compiling method. The base project contains two modules and a main program:
graph.mli
& graph.ml
which define a module Graph
gfile.mli
& gfile.ml
which define a module Gfile
ftest.ml
, the main program To generate an image from a dot file, type on command line:
dot -Tpng your-dot-file > some-output-file
(if the png format is unrecognized, try svg)
In this part, we have to understand and implement the Ford-Fulkerson algorithm (in the module Ffalgo
, which define a module Ffalgo), then test it on several examples and verify.
Find an use-case of this algorithm and writes a program that solves the problem (reference : max flow page).
In this part, we build a module named Tfile
which allows user to “translate” a real life problem into a flow graph problem.
In order to use module Tfile, user has to create an input file with the imposed format and precise the following elements :
In this part, the project contains :
tfile.mli
& tfile.ml
defining module Tfile
.tfiletest.ml
, part II’s main program.Advanced implementation of the basic Ford Fulkerson algorithm by considering other constraints - and implementing the max-flow min-cost algorithm (Busacker-Gowen Algorithm).
The project contains :
bgalgo.mli
& bgalgo.ml
which define a module Bgalfo
gCostfile.mli
& gCostfile.ml
which define a module GCostfile
demoGC.ml
, the main program In order to test the project’s validity, we ran the programs on some examples and compared the results with those obtained by using other tools/programs, by calculating by hand and paper, etc.
ocamlbuild ftest.byte
to build the program.
./ftest.byte graph1 0 5 test1
where graph1
is the text-formatted input graph and test1
is the result graph. Here we choose 0
and 5
as source and sink.
dot -Tpng test1 > test1.png
to visualize the text-formatted result graph by converting it into an image.
ocamlbuild tfiletest.byte
to build the program
./tfiletest.byte tab2 test2 graph2
where tab2
is the transport’s problem written in the correct format precised in part II, test2
is the result graph and graph2
is the input graph, obtained by translating the transport problem.
dot -Tpng graph2 > graph2.png
to visualize the starting graph
dot -Tpng test2 > test2.png
to visualize the result graph
ocamlbuild demoGC.byte
to build the program
./demoGC.byte tab3 1 5 graph3 test3
with tab3
as input file, 1
and 5
are source and sink, graph3
as starting graph obtained by translating tab3
into graph file, and test3
as result graph.
dot -Tpng graph3 > graph3.png
to visualize the starting graph
dot -Tpng test3 > test3.png
to visualize the result graph