# point.io/Point.hs kdtree/Kdtree.hs nn/Nn.hs nn/Nnrun.hs frp/Frp.hs greedy/Greedy1.hs pqgreedy/Pqgreedy.hs

all:	artigo.pdf tsp.nn tsp.frp tsp.greedy tsp.pqgreedy

artigo.pdf: doc/artigo.tex
	pdflatex -o artigo.pdf doc/artigo.tex

tsp.nn: nn/tsp.nn.hs nn/Nn.hs point.io/Point.hs
	ghc -prof -O2 -o tsp.nn point.io/Point.hs \
			nn/Nn.hs \
			nn/tsp.nn.hs

tsp.frp: frp/tsp.frp.hs frp/Frp.hs nn/Nn.hs kdtree/Kdtree.hs point.io/Point.hs
	ghc -prof -O2 -fglasgow-exts -auto-all -o tsp.frp point.io/Point.hs \
			kdtree/Kdtree.hs \
			nn/Nn.hs \
			frp/Frp.hs \
			frp/tsp.frp.hs

tsp.greedy: greedy/tsp.greedy.hs greedy/Greedy.hs point.io/Point.hs 
	ghc -prof -O2 -fglasgow-exts -auto-all -o tsp.greedy point.io/Point.hs \
			greedy/Greedy.hs \
			greedy/tsp.greedy.hs

tsp.pqgreedy: pqgreedy/tsp.pqgreedy.hs pqgreedy/Pqgreedy.hs  kdtree/Kdtree.hs point.io/Point.hs 
	ghc -prof -O2 -fglasgow-exts -auto-all -o tsp.pqgreedy point.io/Point.hs \
			kdtree/Kdtree.hs \
			pqgreedy/Pqgreedy.hs \
			pqgreedy/tsp.pqgreedy.hs

greedy: greedy/Greedy.hs point.io/Point.hs 
	ghc -prof -O2 -fglasgow-exts -auto-all -H14m -o Greedy point.io/Point.hs \
			greedy/Greedy.hs

clearall:	clear clearprof

clear:	
	rm */*.hi */*.o

clearprof:
	rm *.prof

ratioall: ratio.nn ratio.frp ratio.greedy ratio.pqgreedy

ratio.nn:
	time test.data/tourcmp.pl test.data/pr1002.tsp.gz test.data/frtsplib.pl \
	./tsp.nn \
	./tour.eval/tourlen test.data/tsplibopt.pl

ratio.frp:
	time test.data/tourcmp.pl test.data/pr1002.tsp.gz test.data/frtsplib.pl \
	./tsp.frp \
	./tour.eval/tourlen test.data/tsplibopt.pl

ratio.greedy:
	time test.data/tourcmp.pl test.data/att48.tsp.gz test.data/frtsplib.pl \
	./tsp.greedy \
	./tour.eval/tourlen test.data/tsplibopt.pl

ratio.pqgreedy:
	time test.data/tourcmp.pl test.data/kroA100.tsp.gz test.data/frtsplib.pl \
	./tsp.pqgreedy \
	./tour.eval/tourlen test.data/tsplibopt.pl

profall: prof.nn prof.frp prof.greedy prof.pqgreedy

prof.nn:
	gzip -dc test.data/pr1002.tsp.gz | ./test.data/frtsplib.pl | \
	./tsp.nn  +RTS -p > p.p

prof.frp:
	gzip -dc test.data/pr1002.tsp.gz | ./test.data/frtsplib.pl | \
	./tsp.frp  +RTS -p > p.p

prof.greedy:
	gzip -dc test.data/pr1002.tsp.gz | ./test.data/frtsplib.pl | \
	./tsp.greedy  +RTS -p > p.p

prof.pqgreedy:
	time gzip -dc test.data/linhp318.tsp.gz | ./test.data/frtsplib.pl | \
	./tsp.pqgreedy  +RTS -p > p.p


