#!/usr/bin/perl
#
# ANTs farm scenario running script
# Bryan Horling - Aug 2002
# ##################################################################

# ###
# The include file below contains a number of utility functions
# and default variable settings.  If you wish to change these
# (for example, to change the remote machines used to run the
# plugins), you should edit that file.  Other parameters, such
# as the actual plugins and the parameters they use, should
# be changed in this file below.
# ###
require "../lib/runfunctions.pl";

# How long should it run for? (0 = forever)
$END = 60000;

# Make the arg list, currently this is passed into the FarmDriver
# To see what the FarmDriver supports, look for calls to getCommandLineArgument
# in its source code.
$ARGS = join(" ", @ARGV);

# The Metagents.  Adjust NUM_AGENTS to control how many metagents are
# spawned, and the AGENTS assignment line to control which metagent
# is used.  The format is $AGENTS{"<java arguments>"} = "<run path>";
$NUM_AGENTS = $ENV{'NUM_AGENTS'} || 3;
for ($i = 0; $i < $NUM_AGENTS; $i++) {
	$AGENTS{"farm.ants.agent.AntsMetAgent $PLUGARGS -name MA$i -msgmintime 0 -msgmaxtime 0 -msgbytetime 0 -msglossrate 0 -endrun true 2> MA$i.log"} = "$FARM_DIR/ants";
}

# The Plugins.  Add new plugins to this list as needed.  The format
# is roughly the same as the agents above.
%PLUGINS = (
	"farm.generic.plugins.drivers.TimeDriver $PLUGARGS -gui -end $END 2> fathertime.log" => "$FARM_DIR/generic",
	"farm.generic.plugins.gui.GraphGui $PLUGARGS -track \"TotalUtility:Average,TotalMessagesSent,TotalMessagesReceived,TotalUtility,PossibleUtility,PossibleTracks,TotalTracks,PossibleConflicts,TotalConflicts,OptimalUtility,OptimalTracks\" 2> graph.log" => "$FARM_DIR/generic",
#	"farm.generic.plugins.gui.GraphGui $PLUGARGS -track \"TotalUtility,RealOptimalUtility,TotalConflicts,AgentOptimalUtility,RealRandomUtility\"" => "$FARM_DIR/generic",
#	"farm.generic.plugins.PropertyLog $PLUGARGS -log \"TotalUtility,RealOptimalUtility,AgentOptimalUtility,RealRandomUtility\" -o ../ants/utility.log 2> property.log" => "$FARM_DIR/generic",
	"farm.generic.plugins.PropertyLog $PLUGARGS -log \"TotalUtility,PossibleUtility,RealRandomUtility\" -o ../ants/utility.log 2> property.log" => "$FARM_DIR/generic",
	"farm.generic.plugins.AverageAnalysis $PLUGARGS -props \"TotalUtility,RealRandomUtility\" 2> averager.log" => "$FARM_DIR/generic",
#	"farm.generic.plugins.PropertyLog $PLUGARGS -log \":sched\" -o ../ants/schedules.log" => "$FARM_DIR/generic",
	"farm.ants.plugins.FarmDriver $PLUGARGS $ARGS -gui -metagents $NUM_AGENTS 2> driver.log" => "$FARM_DIR/ants",
	"farm.ants.plugins.AntsAllocationAnalysis $PLUGARGS 2> analysis.log" => "$FARM_DIR/ants",
	"farm.ants.plugins.FarmDisplay $PLUGARGS 2> display.log" => "$FARM_DIR/ants",
#	"farm.ants.plugins.AntsOptimalAllocation $PLUGARGS" => "$FARM_DIR/ants",
	"farm.ants.plugins.AntsRandomAllocation $PLUGARGS 2> random.log" => "$FARM_DIR/ants",
);

# Simulator.  This is used to spawn the simulator.
$NUM_PLUGINS = $NUM_AGENTS + keys(%PLUGINS);
%SIMULATORS = (
	"farm.simulator.FarmSimulator -m $NUM_PLUGINS $PROPOWNERS 2> simulator.log" => "$FARM_DIR/simulator"
);

###################################################################
# You shouldn't need to change anything below this line
###################################################################

run();
