
# $Id: Makefile,v 1.16 1999/09/15 14:41:03 gcla Exp $
#
# file       	: Makefile
# description	: Run PEPA models
# author     	: Graham Clark
# Time-stamp	: <15 Sep 99 15:35:39 gcla>
#
#

BASEDIR = $(shell pwd)/..

include $(BASEDIR)/Makefile.config

ifndef BASE
BASE =	test2
endif

bcg :
	$(MAKE) solve
	calcmatrixsize.pl < pwbout > $(BASE).size
	gendata.pl < $(BASE).pepa > experiments/$(BASE).data
	evalvars.pl < experiments/$(BASE).data > experiments/$(BASE).exp
	-process_var $(BASE).var `cat $(BASE).size`
	var2pwbsolve.pl experiments/$(BASE).exp
	pwbsolve `cat $(BASE).size` 100 150 1 1e-15 dummy \
	  > solutions/$(BASE).soln
	#experiment.sh experiments/ solutions/ $(BASE).var $(BASE)
	$(MAKE) printrewards

solve:
	echo $(BASE) | ../$(ARCH)/bin/pwb --hashing=on --aggregation=off --bcg | tee pwbout

printrewards:
	for i in $(BASE)-*.rew ; do \
	  calcreward.pl solutions/$(BASE).soln $$i ; \
	done


maple: maple-num

maple-sym: A.size $(BASE).maple use.maple
	genmaple.pl $(BASE) `cat A.size`
	mv $(BASE)use.maple deleteme
	echo -n "nonexistentdirectory" > basename
	m4 -P < deleteme > $(BASE)use.maple
	-rm deleteme basename

maple-num: A.size $(BASE).maple use.maple
	genmaple.pl $(BASE) `cat A.size`
	mv $(BASE)use.maple deleteme
	echo -n $(BASE) > basename
	m4 -P < deleteme > $(BASE)use.maple
	-rm deleteme basename


clean :
	-mv use.maple use.retain
	-rm pwbout
	-rm *.size *.var
	-rm *.table *.hash *.maple *.rew *.m
	-rm pwbsolve.*
	-rm experiments/*.exp
	-rm solutions/*.soln
	-mv use.retain use.maple

