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).
- Use
ocamlbuild ftest.byteto build the bytecode executable, orocamlbuild ftest.nativeto build the native executable. You might choose only one of these 2 methods. - To run the executable, type on command line :
./ftest.byteor./ftest.nativeaccording to chosen compiling method.
The base project contains two modules and a main program:
graph.mli&graph.mlwhich define a moduleGraphgfile.mli&gfile.mlwhich define a moduleGfileftest.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 :
- Source point with its supply capacity. By example, a source named "a" with supply capacity "25" is presented as : S a "25"
- Destination point with its demand capacity. By example, a destination named "d" with demand capcity "30" is presented as : D d "30"
- Transport roads between points, as well as its maximal capacity. By example, if user is expecting a transport road between "a" and "d" with a maximal capacity of "20 products", it is presented as : C a d "20"
In this part, the project contains :
tfile.mli&tfile.mldefining moduleTfile.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.mlwhich define a moduleBgalfogCostfile.mli&gCostfile.mlwhich define a moduleGCostfiledemoGC.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.byteto build the program. -
./ftest.byte graph1 0 5 test1wheregraph1is the text-formatted input graph andtest1is the result graph. Here we choose0and5as source and sink. -
dot -Tpng test1 > test1.pngto visualize the text-formatted result graph by converting it into an image.
-
ocamlbuild tfiletest.byteto build the program -
./tfiletest.byte tab2 test2 graph2wheretab2is the transport's problem written in the correct format precised in part II,test2is the result graph andgraph2is the input graph, obtained by translating the transport problem. -
dot -Tpng graph2 > graph2.pngto visualize the starting graph -
dot -Tpng test2 > test2.pngto visualize the result graph
-
ocamlbuild demoGC.byteto build the program -
./demoGC.byte tab3 1 5 graph3 test3withtab3as input file,1and5are source and sink,graph3as starting graph obtained by translatingtab3into graph file, andtest3as result graph. -
dot -Tpng graph3 > graph3.pngto visualize the starting graph -
dot -Tpng test3 > test3.pngto visualize the result graph