#!/bin/bash
# Test whether cmpl exist or not 
test -s ../bin/cmpl; r0=$?
test -s ../bin/cmpl.exe; r1=$?

isGurobi=0
isCplex=0


if [ "$r0" = 0 -o "$r1" = 0 ]; then

    echo "######### start Cmpl tests ##############################"

	./test-cmpl 01_Standardmodell.cmpl -ca -m 01_Standardmodell.mps 
	./test-cmpl 02_Standardmodell.cmpl -ca -m 02_Standardmodell.mps 
	./test-cmpl 03_Fibonacci.cmpl -ca -f% 20.0f -fm 03_Fibonacci.mps 
	./test-cmpl 04_Primzahlen.cmpl -ca -m 04_Primzahlen.mps 
	./test-cmpl 05_IntervallLinearisierung.cmpl -ca -m 05_IntervallLinearisierung.mps 
	./test-cmpl 06_Variablenprodukte.A.cmpl -m 06_Variablenprodukte.A.mps 
	./test-cmpl 06_Variablenprodukte.B.cmpl -fm 06_Variablenprodukte.B.mps 
	./test-cmpl 06_Variablenprodukte.C.cmpl -fm 06_Variablenprodukte.C.mps 
	./test-cmpl 07_Mehrkriteriell.cmpl -m 07_Mehrkriteriell.mps 
	./test-cmpl 08_SummeNegiert.cmpl -m 08_SummeNegiert.mps 
	./test-cmpl 09_Beispiel_Steglich.cmpl -ca -fm 09_Beispiel_Steglich.mps 
	./test-cmpl 10_Beispiel_Rost.cmpl -m 10_Beispiel_Rost.mps 
	./test-cmpl 11_Beispiel_Roemer.cmpl -ca -m 11_Beispiel_Roemer.mps 
	./test-cmpl 11_Beispiel_Roemer2.cmpl -fm 11_Beispiel_Roemer2.mps 
	./test-cmpl 12_Test_Loop.cmpl -noOutput 
	./test-cmpl 13_Test_Set.cmpl -noOutput
	./test-cmpl 14_Test_Summe.cmpl -fm 14_Test_Summe.mps 
	./test-cmpl 15_Test_Osil.cmpl -x 15_Test_Osil.osil 
	./test-cmpl 16_diet.cmpl -x 16_diet.osil 
	./test-cmpl 17_knapsack-min-presolved.cmpl -ca -noOutput  
	./test-cmpl 18_max-negative-convex-function.cmpl -ca -noOutput 
	./test-cmpl 19_quadratic-assignment.cmpl -ca -x 19_quadratic-assignment.osil
	./test-cmpl 20_math-functions.cmpl -noOutput
	./test-cmpl 21_testcsvrand.cmpl -x 21_testcsvrand.osil 
  
	./test-cmpl 22_diet.cmpl -ca -silent 
    ./test-cmpl 23_production-mix.cmpl -ca -silent 
    ./test-cmpl 24_test.cmpl -silent 
    ./test-cmpl 25_test_B.cmpl -silent 
    ./test-cmpl 26_transportation.cmpl -silent 
    ./test-cmpl 27_transportation_B.cmpl -silent 
    if [ "$isGurobi" = 1 ]; then 
    	./test-cmpl 28_test_G.cmpl -silent 
    	./test-cmpl 29_transportation_G.cmpl -silent 
    fi
    if [ "$isCplex" = 1 ]; then 
    	./test-cmpl 30_test_C.cmpl -silent 
    	./test-cmpl 31_transportation_C.cmpl -silent 
    fi
    
 	./test-cmpl 32_Standardmodell-data.cmpl -m 32_Standardmodell-data.mps 
	./test-cmpl 33_Standardmodell-data.cmpl -m 33_Standardmodell-data.mps 
	./test-cmpl 34_IntervallLinearisierung-data.cmpl -m 34_IntervallLinearisierung-data.mps
	./test-cmpl 35_Variablenprodukte-data.A.cmpl -m 35_Variablenprodukte-data.A.mps 
	./test-cmpl 36_Variablenprodukte-data.B.cmpl -fm 36_Variablenprodukte-data.B.mps 
	./test-cmpl 37_Mehrkriteriell-data.cmpl -m 37_Mehrkriteriell-data.mps 
	./test-cmpl 38_Beispiel_Roemer-data.cmpl -m 38_Beispiel_Roemer-data.mps
	./test-cmpl 39_Test_Summe-data.cmpl -fm 39_Test_Summe-data.mps
	./test-cmpl 40_Test_Osil-data.cmpl -x 40_Test_Osil-data.osil
	./test-cmpl 41_testcsvrand-data.cmpl -x 41_testcsvrand-data.osil
	./test-cmpl 42_diet-data.cmpl -x 42_diet-data.osil
	./test-cmpl 43_transportation-tupel.cmpl -silent 
	./test-cmpl 44_transportation-tupel-data.cmpl -silent
	./test-cmpl 45_tupel-test.cmpl
	./test-cmpl 46_tsp_cbc-all.cmpl -silent
	./test-cmpl 47_tsp_cbc-csv.cmpl -silent
	./test-cmpl 48_tsp_cbc-sol-kurz.cmpl -silent
	./test-cmpl 49_tsp_cbc-sol-kurz-csv.cmpl -silent
	
	if [ "$isGurobi" = 1 ]; then 
		./test-cmpl 50_tsp_gurobi-solutionPool-all.cmpl -silent
		./test-cmpl 51_tsp_gurobi-solutionPool-all-csv.cmpl -silent
		./test-cmpl 52_tsp_gurobi-solutionPool-kurz.cmpl -silent
		./test-cmpl 53_tsp_gurobi-solutionPool-kurz-csv.cmpl -silent
	fi
	if [ "$isCplex" = 1 ]; then 
		./test-cmpl 54_tsp_cplex-solutionPool-all.cmpl -silent
		./test-cmpl 55_tsp_cplex-solutionPool-all-csv.cmpl -silent
		./test-cmpl 56_tsp_cplex-solutionPool-kurz.cmpl -silent
		./test-cmpl 57_tsp_cplex-solutionPool-kurz-csv.cmpl -silent
	fi
 
    echo "######### Cmpl tests done  ###############################"
    
    if [ -f cplex.log ] ; then rm cplex.log ; fi
	if [ -f gurobi.log ] ; then rm gurobi.log ; fi
    
    
else 
	echo "CMPL does not exist in ../bin"
fi

