Merge pull request #56 from aaziz-alaoui/irace-interface
fastga add problem parameter + irace target runner
This commit is contained in:
commit
87246cc85d
2 changed files with 114 additions and 18 deletions
|
|
@ -34,7 +34,7 @@ eoAlgoFoundryFastGA<Bits>& make_foundry(
|
|||
// foundry.continuators.add< eoSteadyFitContinue<Bits> >(10,i);
|
||||
// }
|
||||
|
||||
for(double i=0.1; i<1.0; i+=0.1) {
|
||||
for(double i=0.1; i<1.0; i+=0.2) {
|
||||
foundry.crossover_rates.add<double>(i);
|
||||
foundry.mutation_rates.add<double>(i);
|
||||
}
|
||||
|
|
@ -47,10 +47,11 @@ eoAlgoFoundryFastGA<Bits>& make_foundry(
|
|||
foundry.offspring_sizes.add<size_t>(0); // 0 = use parents fixed pop size.
|
||||
|
||||
/***** Crossovers ****/
|
||||
for(double i=0.1; i<0.9; i+=0.1) {
|
||||
for(double i=0.1; i<1.0; i+=0.2) {
|
||||
foundry.crossovers.add< eoUBitXover<Bits> >(i); // preference over 1
|
||||
}
|
||||
for(size_t i=1; i < 11; i+=1) {
|
||||
for(size_t i=1; i < 10; i+=2) {
|
||||
|
||||
foundry.crossovers.add< eoNPtsBitXover<Bits> >(i); // nb of points
|
||||
}
|
||||
foundry.crossovers.add< eo1PtBitXover<Bits> >();
|
||||
|
|
@ -63,7 +64,7 @@ eoAlgoFoundryFastGA<Bits>& make_foundry(
|
|||
foundry.mutations.add< eoShiftedBitMutation<Bits> >(p); // proba of flipping k bits, k drawn in binomial distrib, changing zeros to one
|
||||
foundry.mutations.add< eoNormalBitMutation<Bits> >(p); // proba of flipping k bits, k drawn in normal distrib
|
||||
foundry.mutations.add< eoFastBitMutation<Bits> >(p); // proba of flipping k bits, k drawn in powerlaw distrib
|
||||
for(size_t i=1; i < 11; i+=1) {
|
||||
for(size_t i=1; i < 11; i+=2) {
|
||||
foundry.mutations.add< eoDetSingleBitFlip<Bits> >(i); // mutate k bits without duplicates
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +77,7 @@ eoAlgoFoundryFastGA<Bits>& make_foundry(
|
|||
ops.add< eoStochTournamentSelect<Bits> >(0.5);
|
||||
ops.add< eoSequentialSelect<Bits> >();
|
||||
ops.add< eoProportionalSelect<Bits> >();
|
||||
for(size_t i=2; i < 10; i+=4) {
|
||||
for(size_t i=2; i < 11; i+=4) {
|
||||
ops.add< eoDetTournamentSelect<Bits> >(i);
|
||||
}
|
||||
}
|
||||
|
|
@ -88,10 +89,10 @@ eoAlgoFoundryFastGA<Bits>& make_foundry(
|
|||
foundry.replacements.add< eoPlusReplacement<Bits> >();
|
||||
foundry.replacements.add< eoCommaReplacement<Bits> >();
|
||||
foundry.replacements.add< eoSSGAWorseReplacement<Bits> >();
|
||||
for(double i=0.51; i<0.91; i+=0.1) {
|
||||
for(double i=0.51; i<0.92; i+=0.2) {
|
||||
foundry.replacements.add< eoSSGAStochTournamentReplacement<Bits> >(i);
|
||||
}
|
||||
for(size_t i=2; i < 10; i+=1) {
|
||||
for(size_t i=2; i < 11; i+=2) {
|
||||
foundry.replacements.add< eoSSGADetTournamentReplacement<Bits> >(i);
|
||||
}
|
||||
|
||||
|
|
@ -150,14 +151,21 @@ int main(int argc, char* argv[])
|
|||
// rng is a global
|
||||
rng.reseed(seed);
|
||||
|
||||
auto pop_size_p = parser.getORcreateParam<size_t>(1,
|
||||
|
||||
auto problem_p = parser.getORcreateParam<size_t>(0,
|
||||
"problem", "Problem ID",
|
||||
'p', "Problem", /*required=*/true);
|
||||
const size_t problem = problem_p.value();
|
||||
|
||||
|
||||
auto pop_size_p = parser.getORcreateParam<size_t>(5,
|
||||
"pop-size", "Population size",
|
||||
'P', "Operator Choice", /*required=*/false);
|
||||
const size_t pop_size = pop_size_p.value();
|
||||
|
||||
auto instance_p = parser.getORcreateParam<size_t>(0,
|
||||
"instance", "Instance ID",
|
||||
'i', "Problem", /*required=*/true);
|
||||
'i', "Instance", /*required=*/false);
|
||||
const size_t instance = instance_p.value();
|
||||
|
||||
auto continuator_p = parser.getORcreateParam<size_t>(0,
|
||||
|
|
@ -207,7 +215,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
auto offspring_size_p = parser.getORcreateParam<size_t>(0,
|
||||
"offspring-size", "Offsprings size (0 = same size than the parents pop, see --pop-size)",
|
||||
'P', "Operator Choice", /*required=*/false); // Single alternative, not required.
|
||||
'O', "Operator Choice", /*required=*/false); // Single alternative, not required.
|
||||
const size_t offspring_size = offspring_size_p.value();
|
||||
|
||||
|
||||
|
|
@ -236,12 +244,13 @@ int main(int argc, char* argv[])
|
|||
* fake_foundry.continuators.size()
|
||||
* fake_foundry.offspring_sizes.size();
|
||||
std::clog << std::endl;
|
||||
std::clog << n << " possible algorithms instances." << std::endl;
|
||||
std::clog << n << " possible algorithms configurations." << std::endl;
|
||||
|
||||
std::clog << "Ranges of configurable parameters (redirect the stdout in a file to use it with iRace): " << std::endl;
|
||||
|
||||
std::cout << "# name\tswitch\ttype\trange" << std::endl;
|
||||
print_param_range( instance_p, 18, std::cout);
|
||||
print_param_range( instance_p, 41, std::cout);
|
||||
print_param_range( problem_p, 18, std::cout);
|
||||
print_param_range( continuator_p, fake_foundry.continuators .size(), std::cout);
|
||||
print_param_range( crossover_rate_p, fake_foundry.crossover_rates .size(), std::cout);
|
||||
print_param_range( crossover_selector_p, fake_foundry.crossover_selectors .size(), std::cout);
|
||||
|
|
@ -297,7 +306,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
|
||||
/***** IOH logger *****/
|
||||
auto max_target_para = problem_config_mapping[instance].max_target;
|
||||
auto max_target_para = problem_config_mapping[problem].max_target;
|
||||
IOHprofiler_RangeLinear<size_t> target_range(0, max_target_para, buckets);
|
||||
IOHprofiler_RangeLinear<size_t> budget_range(0, max_evals, buckets);
|
||||
IOHprofiler_ecdf_logger<int, size_t, size_t> logger(target_range, budget_range);
|
||||
|
|
@ -307,10 +316,10 @@ int main(int argc, char* argv[])
|
|||
logger.activate_logger();
|
||||
|
||||
/***** IOH problem *****/
|
||||
double w_model_suite_dummy_para = problem_config_mapping[instance].dummy;
|
||||
int w_model_suite_epitasis_para = problem_config_mapping[instance].epistasis;
|
||||
int w_model_suite_neutrality_para = problem_config_mapping[instance].neutrality;
|
||||
int w_model_suite_ruggedness_para = problem_config_mapping[instance].ruggedness;
|
||||
double w_model_suite_dummy_para = problem_config_mapping[problem].dummy;
|
||||
int w_model_suite_epitasis_para = problem_config_mapping[problem].epistasis;
|
||||
int w_model_suite_neutrality_para = problem_config_mapping[problem].neutrality;
|
||||
int w_model_suite_ruggedness_para = problem_config_mapping[problem].ruggedness;
|
||||
|
||||
W_Model_OneMax w_model_om;
|
||||
std::string problem_name = "OneMax";
|
||||
|
|
@ -329,7 +338,7 @@ int main(int argc, char* argv[])
|
|||
w_model_om.IOHprofiler_set_problem_name(problem_name);
|
||||
|
||||
/// Set problem_id as 1
|
||||
w_model_om.IOHprofiler_set_problem_id(0); // FIXME check what that means
|
||||
w_model_om.IOHprofiler_set_problem_id(problem); // FIXME check what that means
|
||||
w_model_om.IOHprofiler_set_instance_id(instance); // FIXME check what that means
|
||||
|
||||
/// Set dimension.
|
||||
|
|
|
|||
87
eo/contrib/irace/irace-algo-search/target-runner
Executable file
87
eo/contrib/irace/irace-algo-search/target-runner
Executable file
|
|
@ -0,0 +1,87 @@
|
|||
#!/bin/bash
|
||||
###############################################################################
|
||||
# This script is the command that is executed every run.
|
||||
# Check the examples in examples/
|
||||
#
|
||||
# This script is run in the execution directory (execDir, --exec-dir).
|
||||
#
|
||||
# PARAMETERS:
|
||||
# $1 is the candidate configuration number
|
||||
# $2 is the instance ID
|
||||
# $3 is the seed
|
||||
# $4 is the instance name
|
||||
# The rest ($* after `shift 4') are parameters to the run
|
||||
#
|
||||
# RETURN VALUE:
|
||||
# This script should print one numerical value: the cost that must be minimized.
|
||||
# Exit with 0 if no error, with 1 in case of error
|
||||
###############################################################################
|
||||
error() {
|
||||
echo "`TZ=UTC date`: $0: error: $@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
EXE="/home/aaziz-alaoui/Documents/GitHub/paradiseo/eo/contrib/irace/irace-algo-search/bin/fastga"
|
||||
|
||||
FIXED_PARAMS=""
|
||||
|
||||
CONFIG_ID=$1
|
||||
INSTANCE_ID=$2
|
||||
SEED=$3
|
||||
INSTANCE=$4
|
||||
CROSSOVER_RATE=$5
|
||||
CROSSOVER_SELECTOR=$6
|
||||
CROSSOVER=$7
|
||||
MUTATION_RATE=$8
|
||||
MUT_SELECTOR=$9
|
||||
MUTATION=${10}
|
||||
REPLACEMENT=${11}
|
||||
shift 11 || error "Not enough parameters"
|
||||
|
||||
CONFIG_PARAMS=$*
|
||||
|
||||
STDOUT=c${CONFIG_ID}-${INSTANCE_ID}-${SEED}.stdout
|
||||
STDERR=c${CONFIG_ID}-${INSTANCE_ID}-${SEED}.stderr
|
||||
|
||||
if [ ! -x "${EXE}" ]; then
|
||||
error "${EXE}: not found or not executable (pwd: $(pwd))"
|
||||
fi
|
||||
|
||||
# If the program just prints a number, we can use 'exec' to avoid
|
||||
# creating another process, but there can be no other commands after exec.
|
||||
#exec $EXE ${FIXED_PARAMS} -i $INSTANCE ${CONFIG_PARAMS}
|
||||
# exit 1
|
||||
#
|
||||
# Otherwise, save the output to a file, and parse the result from it.
|
||||
# (If you wish to ignore segmentation faults you can use '{}' around
|
||||
# the command.)
|
||||
$EXE ${FIXED_PARAMS} --instance=$INSTANCE --seed=${SEED} --crossover-rate=${CROSSOVER_RATE} --cross-selector=${CROSSOVER_SELECTOR} --crossover=${CROSSOVER} --mutation-rate=${MUTATION_RATE} --mut-selector=${MUT_SELECTOR} --mutation=${MUTATION} --replacement=${REPLACEMENT} 1> ${STDOUT} 2> ${STDERR}
|
||||
|
||||
#echo ${cmd}
|
||||
|
||||
|
||||
# --instance=$INSTANCE --seed=$SEED
|
||||
# remplacer config param par la même config que seed et instance id
|
||||
|
||||
|
||||
|
||||
# This may be used to introduce a delay if there are filesystem
|
||||
# issues.
|
||||
#SLEEPTIME=1
|
||||
#while [ ! -s "${STDOUT}" ]; do
|
||||
# sleep $SLEEPTIME
|
||||
# let "SLEEPTIME += 1"
|
||||
#done
|
||||
|
||||
# This is an example of reading a number from the output.
|
||||
# It assumes that the objective value is the first number in
|
||||
# the first column of the last line of the output.
|
||||
if [ -s "${STDOUT}" ]; then
|
||||
COST=$(tail -n 1 ${STDOUT} | grep -e '^[[:space:]]*[+-]\?[0-9]' | cut -f1)
|
||||
echo "$COST"
|
||||
rm -f "${STDOUT}" "${STDERR}"
|
||||
exit 0
|
||||
else
|
||||
error "${STDOUT}: No such file or directory"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue