From cfc30f34f3f57e62851ed35fd098bc1457d7e34d Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Sat, 18 Nov 2023 15:40:16 -0600 Subject: [PATCH 1/4] Set exit status from search. --- src/SearchEngine.cpp | 582 ++++++++++++++++++++-------------------- src/sat/sat_planner.cpp | 162 +++++------ src/sat/sat_planner.h | 2 +- 3 files changed, 375 insertions(+), 371 deletions(-) diff --git a/src/SearchEngine.cpp b/src/SearchEngine.cpp index 30886c53..074f36a1 100644 --- a/src/SearchEngine.cpp +++ b/src/SearchEngine.cpp @@ -160,338 +160,340 @@ void printHeuristicHelp(){ int main(int argc, char *argv[]) { - //speed_test(); - //return 42; + //speed_test(); + //return 42; #ifndef NDEBUG - cout - << "You have compiled the search engine without setting the NDEBUG flag. This will make it slow and should only be done for debug." - << endl; + cout + << "You have compiled the search engine without setting the NDEBUG flag. This will make it slow and should only be done for debug." + << endl; #endif - gengetopt_args_info args_info; - if (cmdline_parser(argc, argv, &args_info) != 0) return 1; - if (args_info.heuristicHelp_given){ - printHeuristicHelp(); - return 0; - } + gengetopt_args_info args_info; + if (cmdline_parser(argc, argv, &args_info) != 0) return 1; + if (args_info.heuristicHelp_given){ + printHeuristicHelp(); + return 0; + } - // set debug mode - if (args_info.debug_given) setDebugMode(true); + // set debug mode + if (args_info.debug_given) setDebugMode(true); - int seed = args_info.seed_arg; // has default value - cout << "Random seed: " << seed << endl; - srand(seed); + int seed = args_info.seed_arg; // has default value + cout << "Random seed: " << seed << endl; + srand(seed); - int timeL = args_info.timelimit_arg; - cout << "Time limit: " << timeL << " seconds" << endl; - - // get input files - std::vector inputFiles; - for ( unsigned i = 0 ; i < args_info.inputs_num ; ++i ) - inputFiles.push_back(args_info.inputs[i]); - - std::string inputFilename = "-"; - - if (inputFiles.size() > 1){ - std::cerr << "You may specify at most one file as input: the SAS+ problem description" << std::endl; - return 1; - } else { - if (inputFiles.size()) - inputFilename = inputFiles[0]; - } - - std::istream * inputStream; - if (inputFilename == "-") { - std::cout << "Reading input from standard input." << std::endl; - inputStream = &std::cin; - } else { - std::cout << "Reading input from " << inputFilename << "." << std::endl; - - std::ifstream * fileInput = new std::ifstream(inputFilename); - if (!fileInput->good()) - { - std::cerr << "Unable to open input file " << inputFilename << ": " << strerror (errno) << std::endl; - return 1; - } - - inputStream = fileInput; - } - - // - - bool useTaskHash = true; - - - - /* Read model */ - // todo: the correct value of maintainTaskRechability depends on the heuristic - eMaintainTaskReachability reachability = mtrACTIONS; - bool trackContainedTasks = useTaskHash; - Model* htn = new Model(trackContainedTasks, reachability, true, true); - htn->filename = inputFilename; - if (args_info.satmutexes_flag) htn->rintanenInvariants = true; - htn->read(inputStream); - assert(htn->isHtnModel); - searchNode* tnI = htn->prepareTNi(htn); + int timeL = args_info.timelimit_arg; + cout << "Time limit: " << timeL << " seconds" << endl; + + // get input files + std::vector inputFiles; + for ( unsigned i = 0 ; i < args_info.inputs_num ; ++i ) + inputFiles.push_back(args_info.inputs[i]); + + std::string inputFilename = "-"; + + if (inputFiles.size() > 1){ + std::cerr << "You may specify at most one file as input: the SAS+ problem description" << std::endl; + return 1; + } else { + if (inputFiles.size()) + inputFilename = inputFiles[0]; + } + + std::istream * inputStream; + if (inputFilename == "-") { + std::cout << "Reading input from standard input." << std::endl; + inputStream = &std::cin; + } else { + std::cout << "Reading input from " << inputFilename << "." << std::endl; + + std::ifstream * fileInput = new std::ifstream(inputFilename); + if (!fileInput->good()) + { + std::cerr << "Unable to open input file " << inputFilename << ": " << strerror (errno) << std::endl; + return 1; + } + + inputStream = fileInput; + } + + // + + bool useTaskHash = true; + int searchRes; // collect the result of runTranslationPlanner + + + + /* Read model */ + // todo: the correct value of maintainTaskRechability depends on the heuristic + eMaintainTaskReachability reachability = mtrACTIONS; + bool trackContainedTasks = useTaskHash; + Model* htn = new Model(trackContainedTasks, reachability, true, true); + htn->filename = inputFilename; + if (args_info.satmutexes_flag) htn->rintanenInvariants = true; + htn->read(inputStream); + assert(htn->isHtnModel); + searchNode* tnI = htn->prepareTNi(htn); - if (inputFilename != "-") ((ifstream*) inputStream)->close(); + if (inputFilename != "-") ((ifstream*) inputStream)->close(); - if (args_info.writeInputToHDDL_given){ - cout << "writing input problem to file" << endl; - if (inputFilename == "-"){ - cout << "Cannot determine proper file names when reading from stdin" << endl; - return 1; - } - string dName = inputFilename + ".d.hddl"; - string pName = inputFilename + ".p.hddl"; - htn->buildOrderingDatastructures(); - htn->writeToPDDL(dName,pName); + if (args_info.writeInputToHDDL_given){ + cout << "writing input problem to file" << endl; + if (inputFilename == "-"){ + cout << "Cannot determine proper file names when reading from stdin" << endl; + return 1; + } + string dName = inputFilename + ".d.hddl"; + string pName = inputFilename + ".p.hddl"; + htn->buildOrderingDatastructures(); + htn->writeToPDDL(dName,pName); - return 0; - } + return 0; + } - if(reachability != mtrNO) { - htn->calcSCCs(); - htn->calcSCCGraph(); + if(reachability != mtrNO) { + htn->calcSCCs(); + htn->calcSCCGraph(); - // add reachability information to initial task network - htn->updateReachability(tnI); - } + // add reachability information to initial task network + htn->updateReachability(tnI); + } -// Heuristic *hLMC = new hhLMCount(htn, 0, tnI, lmfFD); + // Heuristic *hLMC = new hhLMCount(htn, 0, tnI, lmfFD); - planningAlgorithm algo = PROGRESSION; - if (args_info.progression_given) algo = PROGRESSION; - if (args_info.sat_given) algo = SAT; - if (args_info.bdd_given) algo = BDD; - if (args_info.interactive_given) algo = INTERACTIVE; - if (args_info.translation_given) algo = TRANSLATION; + planningAlgorithm algo = PROGRESSION; + if (args_info.progression_given) algo = PROGRESSION; + if (args_info.sat_given) algo = SAT; + if (args_info.bdd_given) algo = BDD; + if (args_info.interactive_given) algo = INTERACTIVE; + if (args_info.translation_given) algo = TRANSLATION; - if (algo == INTERACTIVE){ - cout << "Selected Planning Algorihtm: interactive"; - interactivePlanner(htn,tnI); - } else if (algo == PROGRESSION){ - cout << "Selected Planning Algorithm: progression search"; + if (algo == INTERACTIVE){ + cout << "Selected Planning Algorihtm: interactive"; + interactivePlanner(htn,tnI); + } else if (algo == PROGRESSION){ + cout << "Selected Planning Algorithm: progression search"; - int hLength = args_info.heuristic_given; - cout << "Parsing heuristics ..." << endl; - cout << "Number of specified heuristics: " << hLength << endl; - if (hLength == 0){ - cout << "No heuristics given, setting default ... " << endl; - hLength = 1; - } - Heuristic **heuristics = new Heuristic *[hLength]; - map>, int> heuristics_so_far; - for (int i = 0; i < hLength; i++){ - auto [hName, args] = parse_heuristic_with_arguments_from_braced_expression(args_info.heuristic_arg[i]); + int hLength = args_info.heuristic_given; + cout << "Parsing heuristics ..." << endl; + cout << "Number of specified heuristics: " << hLength << endl; + if (hLength == 0){ + cout << "No heuristics given, setting default ... " << endl; + hLength = 1; + } + Heuristic **heuristics = new Heuristic *[hLength]; + map>, int> heuristics_so_far; + for (int i = 0; i < hLength; i++){ + auto [hName, args] = parse_heuristic_with_arguments_from_braced_expression(args_info.heuristic_arg[i]); - if (heuristics_so_far.count({hName, args})){ - heuristics[i] = heuristics[heuristics_so_far[{hName, args}]]; - cout << "\tHeuristic duplicate: Nr. " << i << " is the same as " << heuristics_so_far[{hName, args}] << endl; - continue; - } - heuristics_so_far[{hName, args}] = i; - - if (hName == "zero"){ - heuristics[i] = new hhZero(htn, i); - } else if (hName == "modDepth"){ - string invertString = (args.count("invert"))?args["invert"]:args["arg1"]; - bool invert = false; - if (invertString == "true" || invertString == "invert") invert = true; - - heuristics[i] = new hhModDepth(htn, i, invert); - } else if (hName == "mixedModDepth"){ - string invertString = (args.count("invert"))?args["invert"]:args["arg1"]; - bool invert = false; - if (invertString == "true" || invertString == "invert") invert = true; - - heuristics[i] = new hhMixedModDepth(htn, i, invert); - } else if (hName == "cost"){ - string invertString = (args.count("invert"))?args["invert"]:args["arg1"]; - bool invert = false; - if (invertString == "true" || invertString == "invert") invert = true; - - heuristics[i] = new hhCost(htn, i, invert); - } else if (hName == "rc2"){ - string subName = (args.count("h"))?args["h"]:args["arg1"]; + if (heuristics_so_far.count({hName, args})){ + heuristics[i] = heuristics[heuristics_so_far[{hName, args}]]; + cout << "\tHeuristic duplicate: Nr. " << i << " is the same as " << heuristics_so_far[{hName, args}] << endl; + continue; + } + heuristics_so_far[{hName, args}] = i; + + if (hName == "zero"){ + heuristics[i] = new hhZero(htn, i); + } else if (hName == "modDepth"){ + string invertString = (args.count("invert"))?args["invert"]:args["arg1"]; + bool invert = false; + if (invertString == "true" || invertString == "invert") invert = true; + + heuristics[i] = new hhModDepth(htn, i, invert); + } else if (hName == "mixedModDepth"){ + string invertString = (args.count("invert"))?args["invert"]:args["arg1"]; + bool invert = false; + if (invertString == "true" || invertString == "invert") invert = true; + + heuristics[i] = new hhMixedModDepth(htn, i, invert); + } else if (hName == "cost"){ + string invertString = (args.count("invert"))?args["invert"]:args["arg1"]; + bool invert = false; + if (invertString == "true" || invertString == "invert") invert = true; + + heuristics[i] = new hhCost(htn, i, invert); + } else if (hName == "rc2"){ + string subName = (args.count("h"))?args["h"]:args["arg1"]; - string estimate_string = (args.count("est"))?args["est"]:args["arg2"]; - eEstimate estimate = estDISTANCE; - if (estimate_string == "cost") - estimate = estCOSTS; - if (estimate_string == "mixed") - estimate = estMIXED; + string estimate_string = (args.count("est"))?args["est"]:args["arg2"]; + eEstimate estimate = estDISTANCE; + if (estimate_string == "cost") + estimate = estCOSTS; + if (estimate_string == "mixed") + estimate = estMIXED; - string correct_task_count_string = (args.count("taskcount"))?args["taskcount"]:args["arg3"]; - bool correctTaskCount = true; - if (correct_task_count_string == "no") - correctTaskCount = false; - - if (subName == "lmc") - heuristics[i] = new hhRC2(htn, i, estimate, correctTaskCount); - else if (subName == "add"){ - heuristics[i] = new hhRC2(htn, i, estimate, correctTaskCount); - ((hhRC2*)heuristics[i])->sasH->heuristic = sasAdd; - } else if (subName == "ff"){ - heuristics[i] = new hhRC2(htn, i, estimate, correctTaskCount); - ((hhRC2*)heuristics[i])->sasH->heuristic = sasFF; - } else if (subName == "filter") - heuristics[i] = new hhRC2(htn, i, estimate, correctTaskCount); - else { - cout << "No inner heuristic specified for RC. Using FF" << endl; - heuristics[i] = new hhRC2(htn, i, estimate, correctTaskCount); - ((hhRC2*)heuristics[i])->sasH->heuristic = sasFF; - } - } else if (hName == "dof"){ + string correct_task_count_string = (args.count("taskcount"))?args["taskcount"]:args["arg3"]; + bool correctTaskCount = true; + if (correct_task_count_string == "no") + correctTaskCount = false; + + if (subName == "lmc") + heuristics[i] = new hhRC2(htn, i, estimate, correctTaskCount); + else if (subName == "add"){ + heuristics[i] = new hhRC2(htn, i, estimate, correctTaskCount); + ((hhRC2*)heuristics[i])->sasH->heuristic = sasAdd; + } else if (subName == "ff"){ + heuristics[i] = new hhRC2(htn, i, estimate, correctTaskCount); + ((hhRC2*)heuristics[i])->sasH->heuristic = sasFF; + } else if (subName == "filter") + heuristics[i] = new hhRC2(htn, i, estimate, correctTaskCount); + else { + cout << "No inner heuristic specified for RC. Using FF" << endl; + heuristics[i] = new hhRC2(htn, i, estimate, correctTaskCount); + ((hhRC2*)heuristics[i])->sasH->heuristic = sasFF; + } + } else if (hName == "dof"){ #ifndef CMAKE_NO_ILP - string type_string = (args.count("type"))?args["type"]:args["arg1"]; - IloNumVar::Type intType = IloNumVar::Int; - IloNumVar::Type boolType = IloNumVar::Bool; - if (type_string == "lp"){ - intType = IloNumVar::Float; - boolType = IloNumVar::Float; - } - - string mode_string = (args.count("mode"))?args["mode"]:args["arg2"]; - csSetting mode = cSatisficing; - if (mode_string == "optimal") - mode = cOptimal; - - string tdg_string = (args.count("tdg"))?args["tdg"]:args["arg3"]; - csTdg tdg = cTdgAllowUC; - if (tdg_string == "uc") - tdg = cTdgFull; - else if (tdg_string == "none") - tdg = cTdgNone; + string type_string = (args.count("type"))?args["type"]:args["arg1"]; + IloNumVar::Type intType = IloNumVar::Int; + IloNumVar::Type boolType = IloNumVar::Bool; + if (type_string == "lp"){ + intType = IloNumVar::Float; + boolType = IloNumVar::Float; + } + + string mode_string = (args.count("mode"))?args["mode"]:args["arg2"]; + csSetting mode = cSatisficing; + if (mode_string == "optimal") + mode = cOptimal; + + string tdg_string = (args.count("tdg"))?args["tdg"]:args["arg3"]; + csTdg tdg = cTdgAllowUC; + if (tdg_string == "uc") + tdg = cTdgFull; + else if (tdg_string == "none") + tdg = cTdgNone; - string pg_string = (args.count("pg"))?args["pg"]:args["arg4"]; - csPg pg = cPgNone; - if (pg_string == "full") - pg = cPgFull; - else if (tdg_string == "relaxed") - pg = cPgTimeRelaxed; - - string andorLM_string = (args.count("andOrLM"))?args["andOrLM"]:args["arg5"]; - csAndOrLms andOrLM = cAndOrLmsNone; - if (andorLM_string == "full") - andOrLM = cAndOrLmsFull; - else if (andorLM_string == "onlyTNi") - andOrLM = cAndOrLmsOnlyTnI; - - string externalLM_string = (args.count("externalLM"))?args["externalLM"]:args["arg6"]; - csAddExternalLms externalLM = cAddExternalLmsNo; - if (externalLM_string == "none") - externalLM = cAddExternalLmsYes; - - string lmclms_string = (args.count("lmclmc"))?args["lmclmc"]:args["arg7"]; - csLmcLms lmclms = cLmcLmsFull; - if (lmclms_string == "none") - lmclms = cLmcLmsNone; - - string netchange_string = (args.count("netchange"))?args["netchange"]:args["arg8"]; - csNetChange netchange = cNetChangeFull; - if (netchange_string == "none") - netchange = cNetChangeNone; - - - heuristics[i] = new hhDOfree(htn,tnI,i,intType,boolType,mode,tdg,pg,andOrLM,lmclms,netchange,externalLM); + string pg_string = (args.count("pg"))?args["pg"]:args["arg4"]; + csPg pg = cPgNone; + if (pg_string == "full") + pg = cPgFull; + else if (tdg_string == "relaxed") + pg = cPgTimeRelaxed; + + string andorLM_string = (args.count("andOrLM"))?args["andOrLM"]:args["arg5"]; + csAndOrLms andOrLM = cAndOrLmsNone; + if (andorLM_string == "full") + andOrLM = cAndOrLmsFull; + else if (andorLM_string == "onlyTNi") + andOrLM = cAndOrLmsOnlyTnI; + + string externalLM_string = (args.count("externalLM"))?args["externalLM"]:args["arg6"]; + csAddExternalLms externalLM = cAddExternalLmsNo; + if (externalLM_string == "none") + externalLM = cAddExternalLmsYes; + + string lmclms_string = (args.count("lmclmc"))?args["lmclmc"]:args["arg7"]; + csLmcLms lmclms = cLmcLmsFull; + if (lmclms_string == "none") + lmclms = cLmcLmsNone; + + string netchange_string = (args.count("netchange"))?args["netchange"]:args["arg8"]; + csNetChange netchange = cNetChangeFull; + if (netchange_string == "none") + netchange = cNetChangeNone; + + + heuristics[i] = new hhDOfree(htn,tnI,i,intType,boolType,mode,tdg,pg,andOrLM,lmclms,netchange,externalLM); #else - cout << "Planner compiled without CPLEX support" << endl; - return 1; + cout << "Planner compiled without CPLEX support" << endl; + return 1; #endif - } else { - cout << "Heuristic type \"" << hName << "\" is unknown." << endl; - return 1; - } + } else { + cout << "Heuristic type \"" << hName << "\" is unknown." << endl; + return 1; + } - cout << "Heuristic #" << i << " = " << heuristics[i]->getDescription() << endl; - } + cout << "Heuristic #" << i << " = " << heuristics[i]->getDescription() << endl; + } - int aStarWeight = args_info.astarweight_arg; - aStar aStarType = gValNone; - if (string(args_info.gValue_arg) == "path") aStarType = gValPathCosts; - if (string(args_info.gValue_arg) == "action") aStarType = gValActionCosts; - if (string(args_info.gValue_arg) == "mixed") aStarType = gValActionPathCosts; - if (string(args_info.gValue_arg) == "none") aStarType = gValNone; + int aStarWeight = args_info.astarweight_arg; + aStar aStarType = gValNone; + if (string(args_info.gValue_arg) == "path") aStarType = gValPathCosts; + if (string(args_info.gValue_arg) == "action") aStarType = gValActionCosts; + if (string(args_info.gValue_arg) == "mixed") aStarType = gValActionPathCosts; + if (string(args_info.gValue_arg) == "none") aStarType = gValNone; - bool suboptimalSearch = args_info.suboptimal_flag; - - cout << "Search config:" << endl; - cout << " - type: "; - switch (aStarType){ - case gValNone: cout << "greedy"; break; - case gValActionCosts: cout << "cost optimal"; break; - case gValPathCosts: cout << "path cost"; break; - case gValActionPathCosts: cout << "action cost + decomposition cost"; break; - } - cout << endl; - cout << " - weight: " << aStarWeight << endl; - cout << " - suboptimal: " << (suboptimalSearch?"true":"false") << endl; - - - bool noVisitedList = args_info.noVisitedList_flag; - bool allowGIcheck = args_info.noGIcheck_flag; - bool taskHash = args_info.noTaskHash_flag; - bool taskSequenceHash = args_info.noTaskSequenceHash_flag; - bool topologicalOrdering = args_info.noTopologicalOrdering_flag; - bool orderPairsHash = args_info.noOrderPairs_flag; - bool layerHash = args_info.noLayers_flag; - bool allowParalleSequencesMode = args_info.noParallelSequences_flag; + bool suboptimalSearch = args_info.suboptimal_flag; + + cout << "Search config:" << endl; + cout << " - type: "; + switch (aStarType){ + case gValNone: cout << "greedy"; break; + case gValActionCosts: cout << "cost optimal"; break; + case gValPathCosts: cout << "path cost"; break; + case gValActionPathCosts: cout << "action cost + decomposition cost"; break; + } + cout << endl; + cout << " - weight: " << aStarWeight << endl; + cout << " - suboptimal: " << (suboptimalSearch?"true":"false") << endl; + + + bool noVisitedList = args_info.noVisitedList_flag; + bool allowGIcheck = args_info.noGIcheck_flag; + bool taskHash = args_info.noTaskHash_flag; + bool taskSequenceHash = args_info.noTaskSequenceHash_flag; + bool topologicalOrdering = args_info.noTopologicalOrdering_flag; + bool orderPairsHash = args_info.noOrderPairs_flag; + bool layerHash = args_info.noLayers_flag; + bool allowParalleSequencesMode = args_info.noParallelSequences_flag; - VisitedList visi(htn,noVisitedList, suboptimalSearch, taskHash, taskSequenceHash, topologicalOrdering, orderPairsHash, layerHash, allowGIcheck, allowParalleSequencesMode); - PriorityQueueSearch search; - OneQueueWAStarFringe fringe(aStarType, aStarWeight, hLength); + VisitedList visi(htn,noVisitedList, suboptimalSearch, taskHash, taskSequenceHash, topologicalOrdering, orderPairsHash, layerHash, allowGIcheck, allowParalleSequencesMode); + PriorityQueueSearch search; + OneQueueWAStarFringe fringe(aStarType, aStarWeight, hLength); - bool printPlan = !args_info.noPlanOutput_flag; - search.search(htn, tnI, timeL, suboptimalSearch, printPlan, heuristics, hLength, visi, fringe); - } else if (algo == SAT){ + bool printPlan = !args_info.noPlanOutput_flag; + search.search(htn, tnI, timeL, suboptimalSearch, printPlan, heuristics, hLength, visi, fringe); + } else if (algo == SAT){ #ifndef CMAKE_NO_SAT - bool block_compression = args_info.blockcompression_flag; - bool sat_mutexes = args_info.satmutexes_flag; - bool effectLessActionsInSeparateLeaf = args_info.methodPreconditionsInSeparateLeafs_given; - bool optimisingMode = args_info.optimisation_given; + bool block_compression = args_info.blockcompression_flag; + bool sat_mutexes = args_info.satmutexes_flag; + bool effectLessActionsInSeparateLeaf = args_info.methodPreconditionsInSeparateLeafs_given; + bool optimisingMode = args_info.optimisation_given; - sat_pruning pruningMode = SAT_FF; - if (string(args_info.pruning_arg) == "none") pruningMode = SAT_NONE; - if (string(args_info.pruning_arg) == "ff") pruningMode = SAT_FF; - if (string(args_info.pruning_arg) == "h2") pruningMode = SAT_H2; + sat_pruning pruningMode = SAT_FF; + if (string(args_info.pruning_arg) == "none") pruningMode = SAT_NONE; + if (string(args_info.pruning_arg) == "ff") pruningMode = SAT_FF; + if (string(args_info.pruning_arg) == "h2") pruningMode = SAT_H2; - extract_invariants_from_parsed_model(htn); - if (sat_mutexes) compute_Rintanen_Invariants(htn); + extract_invariants_from_parsed_model(htn); + if (sat_mutexes) compute_Rintanen_Invariants(htn); - solve_with_sat_planner(htn, block_compression, sat_mutexes, pruningMode, effectLessActionsInSeparateLeaf, optimisingMode); + solve_with_sat_planner(htn, block_compression, sat_mutexes, pruningMode, effectLessActionsInSeparateLeaf, optimisingMode); #else - cout << "Planner compiled without SAT planner support" << endl; + cout << "Planner compiled without SAT planner support" << endl; #endif - } else if (algo == BDD){ + } else if (algo == BDD){ #ifndef CMAKE_NO_BDD - build_automaton(htn); + build_automaton(htn); #else - cout << "Planner compiled without symbolic planner support" << endl; + cout << "Planner compiled without symbolic planner support" << endl; #endif - } else if (algo == TRANSLATION){ - TranslationType type; - if (string(args_info.transtype_arg) == "push") type = Push; - if (string(args_info.transtype_arg) == "parallelseq") type = ParallelSeq; - if (string(args_info.transtype_arg) == "to") type = TO; - if (string(args_info.transtype_arg) == "postrips") type = BaseStrips; - if (string(args_info.transtype_arg) == "pocond") type = BaseCondEffects; - - runTranslationPlanner(htn,type, args_info.forceTransType_flag, args_info.pgb_arg, args_info.pgbsteps_arg, - string(args_info.downward_arg), string(args_info.downwardConf_arg), string(args_info.sasfile_arg), - args_info.iterate_flag, args_info.onlyGenerate_flag, - args_info.realCosts_flag); - } - - delete htn; + } else if (algo == TRANSLATION){ + TranslationType type; + if (string(args_info.transtype_arg) == "push") type = Push; + if (string(args_info.transtype_arg) == "parallelseq") type = ParallelSeq; + if (string(args_info.transtype_arg) == "to") type = TO; + if (string(args_info.transtype_arg) == "postrips") type = BaseStrips; + if (string(args_info.transtype_arg) == "pocond") type = BaseCondEffects; + + searchReas = runTranslationPlanner(htn,type, args_info.forceTransType_flag, args_info.pgb_arg, args_info.pgbsteps_arg, + string(args_info.downward_arg), string(args_info.downwardConf_arg), string(args_info.sasfile_arg), + args_info.iterate_flag, args_info.onlyGenerate_flag, + args_info.realCosts_flag); + if (searchRes != 0) { + searchRes = 2; // search failed + } + + delete htn; - - return 0; + return searchRes; } diff --git a/src/sat/sat_planner.cpp b/src/sat/sat_planner.cpp index 7e537421..eb1075ae 100644 --- a/src/sat/sat_planner.cpp +++ b/src/sat/sat_planner.cpp @@ -8,7 +8,7 @@ #include "../Util.h" #include "../Invariants.h" #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ pair printSolution(void * solver, Model * htn, PDT* pdt, MatchingData & // for (int v = 0; v < htn->numVars; v++){ // if (htn->firstIndex[v] == htn->lastIndex[v]) continue; // STRIPS - // + // // std::set tru; // for (int f = htn->firstIndex[v]; f <= htn->lastIndex[v]; f++) // if (ipasir_val(solver,timeBase + f) > 0) @@ -54,21 +54,21 @@ pair printSolution(void * solver, Model * htn, PDT* pdt, MatchingData & // for (int f : tru) // cout << " " << f << " " << htn->factStrs[f]; // cout << endl; - // + // // exit(0); // } // } //} - + int currentID = 0; int solutionCost = 0; int trueSolutionCost = 0; - + cout << "==>" << endl; /// extract the primitive plan - + if (htn->isTotallyOrdered){ for (PDT* & leaf : leafs){ for (size_t pIndex = 0; pIndex < leaf->possiblePrimitives.size(); pIndex++){ @@ -90,7 +90,7 @@ pair printSolution(void * solver, Model * htn, PDT* pdt, MatchingData & // assign numbers to decompositions pdt->assignOutputNumbers(solver,currentID, htn); - + // if po output the primitive plan now if (!htn->isTotallyOrdered){ for (int p = 0; p < matching.matchingPerPosition.size(); p++){ @@ -106,13 +106,13 @@ pair printSolution(void * solver, Model * htn, PDT* pdt, MatchingData & cout << "PUP" << endl; } } - + } } } } - - + + cout << "root " << pdt->outputID << endl; // out decompositions @@ -125,7 +125,7 @@ pair printSolution(void * solver, Model * htn, PDT* pdt, MatchingData & void printVariableTruth(void* solver, Model * htn, sat_capsule & capsule){ for (int v = 1; v <= capsule.number_of_variables; v++){ int val = ipasir_val(solver,v); - + std::string s = std::to_string(v); int x = 4 - s.size(); while (x-- && x > 0) std::cout << " "; @@ -133,7 +133,7 @@ void printVariableTruth(void* solver, Model * htn, sat_capsule & capsule){ if (val > 0) std::cout << " "; else std::cout << "not "; #ifndef NDEBUG - std::cout << capsule.variableNames[v] << endl; + std::cout << capsule.variableNames[v] << endl; #else std::cout << v << endl; #endif @@ -198,15 +198,15 @@ void insert_invariant(Model * htn, unordered_set * invariants, int a, int b bool filter_leafs_Rintanen(vector & leafs, Model * htn, unordered_set* & after_leaf_invariants, int & additionalInvariants){ //std::clock_t invariant_start = std::clock(); //cout << endl << "Computing invariants [Rintanen]" << endl; - + vector> v0; bool * toDelete; vector> posInvarsPerPredicate; vector> negInvarsPerPredicate; compute_Rintanen_initial_invariants(htn,v0,toDelete,posInvarsPerPredicate,negInvarsPerPredicate); - - + + int executablePrimitives = 0; int prunedPrimitives = 0; for (unsigned int l = 0; l < leafs.size(); l++){ @@ -221,7 +221,7 @@ bool filter_leafs_Rintanen(vector & leafs, Model * htn, unordered_set bool * posInferredPreconditions = new bool[htn->numStateBits]; bool * negInferredPreconditions = new bool[htn->numStateBits]; - bool isExecutable = + bool isExecutable = compute_Rintanten_action_applicable(htn,prim,v0,toDelete, posInvarsPerPredicate, negInvarsPerPredicate, posInferredPreconditions, negInferredPreconditions); @@ -247,10 +247,10 @@ bool filter_leafs_Rintanen(vector & leafs, Model * htn, unordered_set compute_Rintanten_action_effect(htn,prim,v0,toDelete, posInvarsPerPredicate, negInvarsPerPredicate, posInferredPreconditions, negInferredPreconditions); } - // reduce data structures + // reduce data structures compute_Rintanen_reduce_invariants(htn, v0, toDelete, posInvarsPerPredicate, negInvarsPerPredicate); } - + // old invariants are always ok, so don't clear, just add for (auto [a,b] : v0) insert_invariant(htn,after_leaf_invariants,a,b); @@ -282,7 +282,7 @@ bool createFormulaForDepth(void* solver, PDT* pdt, Model * htn, sat_capsule & ca leafsog = pdt->getLeafSOG(); cout << "done" << endl; } - + /* ofstream dfile; dfile.open ("leafsog.dot"); @@ -299,8 +299,8 @@ bool createFormulaForDepth(void* solver, PDT* pdt, Model * htn, sat_capsule & ca pdt->printDot(htn,dfile); dfile << "}" << endl; dfile.close();*/ - - + + //printMemory(); cout << "Clear pruning tables ..."; pdt->resetPruning(htn); // clear tables in whole tree @@ -316,7 +316,7 @@ bool createFormulaForDepth(void* solver, PDT* pdt, Model * htn, sat_capsule & ca for (PDT* l : leafs) for (size_t a = 0; a < l->prunedAbstracts.size(); a++) l->prunedAbstracts[a] = true; - + for (PDT* leaf : leafs) leaf->propagatePruning(htn); @@ -348,10 +348,10 @@ bool createFormulaForDepth(void* solver, PDT* pdt, Model * htn, sat_capsule & ca leaf->countPruning(overallAssignments, prunedAssignments, true); cout << "Leaf Primitive Pruning: " << prunedAssignments << " of " << overallAssignments << endl; - // if we have pruned the initial abstract task, return ... + // if we have pruned the initial abstract task, return ... if (pdt->prunedAbstracts[0]) return false; - - cout << "Pruning gave " << additionalInvariants << " new invariants" << endl; + + cout << "Pruning gave " << additionalInvariants << " new invariants" << endl; //printMemory(); } @@ -365,7 +365,7 @@ bool createFormulaForDepth(void* solver, PDT* pdt, Model * htn, sat_capsule & ca cout << " done. " << (capsule.number_of_variables - numVarsBefore) << " new variables." << endl; //printMemory(); DEBUG(capsule.printVariables()); - + //exit(0); int beforeDecomp = get_number_of_clauses(); @@ -375,11 +375,11 @@ bool createFormulaForDepth(void* solver, PDT* pdt, Model * htn, sat_capsule & ca assertYes(solver,pdt->abstractVariable[0]); if (!htn->isTotallyOrdered) no_abstract_in_leaf(solver,leafs,htn); - cout << "Decomposition Clauses generated." << endl; - + cout << "Decomposition Clauses generated." << endl; + pdt->addPrunedClauses(solver); //for (PDT* leaf : leafs) leaf->addPrunedClauses(solver); // add assertNo for pruned things - cout << "Pruned clauses." << endl; + cout << "Pruned clauses." << endl; //printMemory(); vector> blocks; @@ -402,20 +402,20 @@ bool createFormulaForDepth(void* solver, PDT* pdt, Model * htn, sat_capsule & ca } #endif } - + cout << "Decomp formula generated" << endl; //printMemory(); // generate primitive executability formula vector>> vars; - - + + if (htn->isTotallyOrdered){ get_linear_state_atoms(capsule, leafs, vars); } else { get_partial_state_atoms(capsule, htn, leafsog, vars, effectLessActionsInSeparateLeaf); } - + cout << "State atoms" << endl; vector block_base_variables; @@ -424,7 +424,7 @@ bool createFormulaForDepth(void* solver, PDT* pdt, Model * htn, sat_capsule & ca generate_state_transition_formula(solver, capsule, vars, block_base_variables, blocks, htn); else generate_state_transition_formula(solver, capsule, vars, block_base_variables, htn); - + int afterState = get_number_of_clauses(); cout << "State formula" << endl; @@ -442,7 +442,7 @@ bool createFormulaForDepth(void* solver, PDT* pdt, Model * htn, sat_capsule & ca else generate_mutex_formula(solver, capsule, block_base_variables, after_leaf_invariants, htn); } - + int afterMutex = get_number_of_clauses(); cout << color(Color::BLUE,"Formula: ") << (afterDecomp - beforeDecomp) << " decomposition " << (afterState - afterDecomp) << " state " << (afterMutex - afterState) << " mutex" << endl; @@ -486,7 +486,7 @@ bool createFormulaForDepth(void* solver, PDT* pdt, Model * htn, sat_capsule & ca //for (int i = 0; i < htn->numActions; i++) // names[i] = htn->taskNames[i]; -/* +/* map style; for (int prim : leafs[0]->possiblePrimitives) style[prim] = "style=filled,fillcolor=green"; @@ -497,7 +497,7 @@ bool createFormulaForDepth(void* solver, PDT* pdt, Model * htn, sat_capsule & ca else style[prim] = "style=filled,fillcolor=blue"; } - + for (int prim : leafs[2]->possiblePrimitives){ if (style.count(prim)) style[prim] = "style=filled,fillcolor=red"; @@ -510,28 +510,28 @@ bool createFormulaForDepth(void* solver, PDT* pdt, Model * htn, sat_capsule & ca else style[prim] = "style=filled,fillcolor=orange"; } - + for (int prim : leafs[4]->possiblePrimitives){ if (style.count(prim)) style[prim] = "style=filled,fillcolor=red"; else style[prim] = "style=filled,fillcolor=brown"; } - + for (int prim : leafs[5]->possiblePrimitives){ if (style.count(prim)) style[prim] = "style=filled,fillcolor=red"; else style[prim] = "style=filled,fillcolor=gray"; }*/ - + /*ofstream out("dg.dot"); out << dg->dot_string(names); //out << dg->dot_string(names,style); out.close(); system("dot -Tpdf dg.dot > dg.pdf");*/ - return true; + return true; } namespace std { @@ -556,7 +556,7 @@ void bdfs(Model * htn, PDT * cur, PDT * source, vector> possibleAs if (cur->expanded){ // we know that for cur the possibleAssignments are possible // the assignments are pairs of present task and applied method - + // determine what this can imply for all the children vector>> childrenPossibleAssignments (cur->children.size()); @@ -570,7 +570,7 @@ void bdfs(Model * htn, PDT * cur, PDT * source, vector> possibleAs if (!cur->getListIndexOfChildrenForMethods(tIndex,mIndex,child)->present) continue; bool isPrimitive = cur->getListIndexOfChildrenForMethods(tIndex,mIndex,child)->isPrimitive; int subIndex = cur->getListIndexOfChildrenForMethods(tIndex,mIndex,child)->taskIndex; - + if (isPrimitive) childrenPossibleAssignments[child].insert(make_pair(-1, subIndex)); else{ @@ -608,7 +608,7 @@ void bdfs(Model * htn, PDT * cur, PDT * source, vector> possibleAs pair pp; pp.first = cur->getCauseForAbstract(tIndex,c)->taskIndex; pp.second = cur->getCauseForAbstract(tIndex,c)->methodIndex; - + possibleMotherAssignments.insert(pp); } } else { @@ -616,12 +616,12 @@ void bdfs(Model * htn, PDT * cur, PDT * source, vector> possibleAs pair pp; pp.first = cur->getCauseForAbstract(mIndex,c)->taskIndex; pp.second = cur->getCauseForAbstract(mIndex,c)->methodIndex; - + possibleMotherAssignments.insert(pp); } } } - + // push to mother vector> vec; for (auto & p : possibleMotherAssignments) @@ -641,13 +641,13 @@ void temp(Model * htn, PDT * pdt){ int p = l->possiblePrimitives[pI]; cout << "Leaf " << l << " " << p << endl; map>> overallAssignments; - - + + vector> possibleAssignments; for (int c = 0; c < l->numberOfCausesPerPrimitive[pI]; c++){ pair pp; - pp.first = l->getCauseForPrimitive(pI,c)->taskIndex; - pp.second = l->getCauseForPrimitive(pI,c)->methodIndex; + pp.first = l->getCauseForPrimitive(pI,c)->taskIndex; + pp.second = l->getCauseForPrimitive(pI,c)->methodIndex; } @@ -697,8 +697,8 @@ void optimise_with_sat_planner_linear_bound_increase(Model * htn, bool block_com double formula_time_in_ms = 1000.0 * (formula_end-formula_start) / CLOCKS_PER_SEC; cout << "Formula has " << capsule.number_of_variables << " vars and " << get_number_of_clauses() << " clauses." << endl; cout << "Formula time: " << fixed << formula_time_in_ms << "ms" << endl; - - + + cout << "Starting solver" << endl; std::clock_t solver_start = std::clock(); state = ipasir_solve(solver); @@ -747,13 +747,14 @@ void optimise_with_sat_planner_linear_bound_increase(Model * htn, bool block_com -void solve_with_sat_planner_linear_bound_increase(Model * htn, bool block_compression, bool sat_mutexes, sat_pruning pruningMode, bool effectLessActionsInSeparateLeaf){ +int solve_with_sat_planner_linear_bound_increase(Model * htn, bool block_compression, bool sat_mutexes, sat_pruning pruningMode, bool effectLessActionsInSeparateLeaf){ PDT* pdt = new PDT(htn); //graph * dg = compute_disabling_graph(htn, true); sat_capsule capsule; reset_number_of_clauses(); int depth = 1; + int retval = 0; while (true){ void* solver = ipasir_init(); cout << endl << endl << color(Color::YELLOW, "Generating formula for depth " + to_string(depth)) << endl; @@ -766,8 +767,8 @@ void solve_with_sat_planner_linear_bound_increase(Model * htn, bool block_compre double formula_time_in_ms = 1000.0 * (formula_end-formula_start) / CLOCKS_PER_SEC; cout << "Formula has " << capsule.number_of_variables << " vars and " << get_number_of_clauses() << " clauses." << endl; cout << "Formula time: " << fixed << formula_time_in_ms << "ms" << endl; - - + + cout << "Starting solver" << endl; std::clock_t solver_start = std::clock(); state = ipasir_solve(solver); @@ -786,7 +787,7 @@ void solve_with_sat_planner_linear_bound_increase(Model * htn, bool block_compre cout << "Initial abstract task is pruned: " << color(Color::RED,"UNSAT") << endl; } //temp(htn,pdt); - + if (state == 10){ #ifndef NDEBUG printVariableTruth(solver, htn, capsule); @@ -795,14 +796,15 @@ void solve_with_sat_planner_linear_bound_increase(Model * htn, bool block_compre ipasir_release(solver); if (optimisePlan) optimise_with_sat_planner_linear_bound_increase(htn, block_compression, sat_mutexes, pruningMode, effectLessActionsInSeparateLeaf, capsule, pdt, depth, apparentCost); - return; + return 0; // success } else { - depth++; + depth++; // repeat //return; } - // release the solver + // release the solver ipasir_release(solver); } + return 1; // failed } #define THREAD_PREFIX "\t\t\t\t\t\t\t\t\t" @@ -819,10 +821,10 @@ struct thread_returns{ //graph * dg; void* solver; int state; - + bool done; -// threading +// threading int signal; pthread_t tid; }; @@ -833,11 +835,11 @@ bool current_done; void* run_sat_planner_for_depth(void * param){ thread_returns * ret = (thread_returns*) param; cout << THREAD_PREFIX << "Starting Thread for depth " << ret->depth << " @ signal " << ret->signal << endl; - - // set this thread to handle the + + // set this thread to handle the sigset_t sigmask; sigemptyset(&sigmask); - sigaddset(&sigmask, signalBase + ret->signal); + sigaddset(&sigmask, signalBase + ret->signal); pthread_sigmask(SIG_UNBLOCK, &sigmask, (sigset_t *)0); cout << THREAD_PREFIX << "I am handled by " << signalBase + ret->signal << endl; @@ -851,7 +853,7 @@ void* run_sat_planner_for_depth(void * param){ MatchingData matching; createFormulaForDepth(ret->solver,ret->pdt,ret->htn,capsule,matching,ret->depth,ret->block_compression,ret->sat_mutexes, ret->pruningMode, ret->effectLessActionsInSeparateLeaf); cout << "Formula has " << capsule.number_of_variables << " vars and " << get_number_of_clauses() << " clauses." << endl; - + cout << "Starting solver" << endl; std::clock_t solver_start = std::clock(); ret->state = ipasir_solve(ret->solver); @@ -914,7 +916,7 @@ void solve_with_sat_planner_time_interleave(Model * htn, bool block_compression, /* Alle Bits auf null setzen */ sigemptyset(&sigmask); /* Signal SIGUSR1 nicht blockieren ... */ - sigaddset(&sigmask, SIGINT); + sigaddset(&sigmask, SIGINT); pthread_sigmask(SIG_UNBLOCK, &sigmask, (sigset_t *)0); /* Setup Signal-Handler für SIGINT & SIGUSR1 */ @@ -939,7 +941,7 @@ void solve_with_sat_planner_time_interleave(Model * htn, bool block_compression, std::this_thread::sleep_for(1ms); pthread_kill(runs[positionOnRuns]->tid, signalBase + runningSingal); std::this_thread::sleep_for(10ms); - } + } cout << THREAD_PREFIX << "Switching to next task " << endl; do { @@ -963,7 +965,7 @@ void solve_with_sat_planner_time_interleave(Model * htn, bool block_compression, firstFreeSignal = i; break; } - + thread_returns* ret = new thread_returns(); ret->htn = htn; ret->depth = depth++; @@ -974,13 +976,13 @@ void solve_with_sat_planner_time_interleave(Model * htn, bool block_compression, ret->pruningMode = pruningMode; ret->effectLessActionsInSeparateLeaf = effectLessActionsInSeparateLeaf; runs.push_back(ret); - + //void *t1(void *); - pthread_attr_t attr_obj; + pthread_attr_t attr_obj; pthread_attr_init(&attr_obj); pthread_create(&ret->tid, &attr_obj, run_sat_planner_for_depth, (void *)ret); cout << THREAD_PREFIX << "Starting worker: " << ret->tid << " @ " << firstFreeSignal << endl; - + // get this thread started sleep_until_solver_finished(1000ms); runningSingal = firstFreeSignal; @@ -997,7 +999,7 @@ void solve_with_sat_planner_time_interleave(Model * htn, bool block_compression, cout << THREAD_PREFIX << "Not possible to start a new run, next non-finished task is " << positionOnRuns << endl; } } - + runningSingal = runs[positionOnRuns]->signal; cout << THREAD_PREFIX << "Letting " << positionOnRuns << " work @ " << runningSingal << endl; signal_to_release = signalBase + runningSingal; @@ -1013,15 +1015,15 @@ void solve_with_sat_planner(Model * htn, bool block_compression, bool sat_mutexe htn->calcSCCs(); htn->constructSCCGraph(); htn->analyseSCCcyclicity(); - + optimisePlan = optimise; - + // start actual planner cout << endl << endl; // start by determining whether this model is totally ordered cout << "Instance is totally ordered: " << (htn->isTotallyOrdered?"yes":"no") << endl; //htn->writeToPDDL("foo-d.hddl", "foo-p.hddl"); - + cout << color(Color::YELLOW,"Starting SAT-based planner") << endl; cout << "Using SAT solver: " << ipasir_signature() << endl; cout << "Encode Mutexes: " << (sat_mutexes?"yes":"no") << endl; @@ -1035,12 +1037,12 @@ void solve_with_sat_planner(Model * htn, bool block_compression, bool sat_mutexe cout << "Optimise Plan Cost: " << (optimisePlan?"yes":"no") << endl; cout << endl << endl; - + // compute transitive closures of all methods htn->computeTransitiveClosureOfMethodOrderings(); htn->buildOrderingDatastructures(); - + originalActionCosts = new int[htn->numActions]; for (int i = 0; i < htn->numActions; i++) originalActionCosts[i] = htn->actionCosts[i]; @@ -1063,11 +1065,11 @@ void sat_solver_call(){ ipasir_add(solver,-1); ipasir_add(solver,-2); ipasir_add(solver,0); - + ipasir_add(solver,-3); ipasir_add(solver,2); ipasir_add(solver,0); - + ipasir_add(solver,3); ipasir_add(solver,0); @@ -1075,6 +1077,6 @@ void sat_solver_call(){ cout << state << endl; if (state == 10){ for (int v = 1; v <= 3; v++) - cout << "V " << v << ": " << ipasir_val(solver,v) << endl; + cout << "V " << v << ": " << ipasir_val(solver,v) << endl; } } diff --git a/src/sat/sat_planner.h b/src/sat/sat_planner.h index d7092184..12c96c02 100644 --- a/src/sat/sat_planner.h +++ b/src/sat/sat_planner.h @@ -13,6 +13,6 @@ enum sat_pruning{ SAT_NONE=0, SAT_FF=1, SAT_H2=2 }; -void solve_with_sat_planner(Model * htn, bool block_compression, bool sat_mutexes, sat_pruning pruningMode, bool effectLessActionsInSeparateLeaf, bool optimise); +int solve_with_sat_planner(Model * htn, bool block_compression, bool sat_mutexes, sat_pruning pruningMode, bool effectLessActionsInSeparateLeaf, bool optimise); #endif From a6e24ebe98ba67542c9296b35169af0d54f0941e Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Tue, 21 Nov 2023 15:35:22 -0600 Subject: [PATCH 2/4] Ignore gengetopt and cmake outputs. --- .gitignore | 1 + src/.gitignore | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 .gitignore create mode 100644 src/.gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..567609b1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 00000000..200f1a36 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1,2 @@ +cmdline.c +cmdline.h \ No newline at end of file From b30cfeb2267a5a4dadc156bfe245e8cd13b3b22a Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Tue, 21 Nov 2023 15:35:54 -0600 Subject: [PATCH 3/4] Return output status values. --- src/SearchEngine.cpp | 3 ++- src/translation/translationController.cpp | 12 +++++++----- src/translation/translationController.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/SearchEngine.cpp b/src/SearchEngine.cpp index 074f36a1..3273732e 100644 --- a/src/SearchEngine.cpp +++ b/src/SearchEngine.cpp @@ -483,12 +483,13 @@ int main(int argc, char *argv[]) { if (string(args_info.transtype_arg) == "postrips") type = BaseStrips; if (string(args_info.transtype_arg) == "pocond") type = BaseCondEffects; - searchReas = runTranslationPlanner(htn,type, args_info.forceTransType_flag, args_info.pgb_arg, args_info.pgbsteps_arg, + searchRes = runTranslationPlanner(htn,type, args_info.forceTransType_flag, args_info.pgb_arg, args_info.pgbsteps_arg, string(args_info.downward_arg), string(args_info.downwardConf_arg), string(args_info.sasfile_arg), args_info.iterate_flag, args_info.onlyGenerate_flag, args_info.realCosts_flag); if (searchRes != 0) { searchRes = 2; // search failed + } } delete htn; diff --git a/src/translation/translationController.cpp b/src/translation/translationController.cpp index aa36173c..a46f02ba 100644 --- a/src/translation/translationController.cpp +++ b/src/translation/translationController.cpp @@ -117,7 +117,7 @@ int runFD(string sasfile, string solver, string downwardConf, string & planFileN return error_code; } -void runTranslationPlanner(Model* htn, TranslationType transtype, bool forceTransType, +int runTranslationPlanner(Model* htn, TranslationType transtype, bool forceTransType, int pgb, int pgbsteps, string downward, string downwardConf, string sasfile, bool iterate, bool onlyGenerate, @@ -238,14 +238,14 @@ void runTranslationPlanner(Model* htn, TranslationType transtype, bool forceTran if (error_code == 3072 || error_code == 2816 || error_code == 512 || error_code == 1280 || error_code > 10){ if (!iterate){ cout << "- Configuration states not to iterate. Stopping. In order to iterate over the bound use --iterate" << endl; - exit(1); + return 1; //exit(1); } for (int i = 0; i < parallel; i++){ pgbList[i] += pgbsteps; if (pgbList[i] > maxpgb){ cout << "Reached max PGB. Aborting."; - exit(-1); + return 2; //exit(-1); } } @@ -255,13 +255,15 @@ void runTranslationPlanner(Model* htn, TranslationType transtype, bool forceTran cout << endl; } else { cout << "- FD produced unknown error code: " << error_code << endl; - exit(-1); + return 3; + // exit(-1); } } translation->planToHddl(planFileName, "stdout"); // we don't correctly clean up after ourselves -- yet - exit(0); + return 0; + // exit(0); } diff --git a/src/translation/translationController.h b/src/translation/translationController.h index f032f95e..9aad03c1 100644 --- a/src/translation/translationController.h +++ b/src/translation/translationController.h @@ -9,7 +9,7 @@ enum TranslationType{ }; -void runTranslationPlanner(Model* htn, TranslationType transtype, bool forceTransType, +int runTranslationPlanner(Model* htn, TranslationType transtype, bool forceTransType, int pgb, int pgbsteps, string downward, string downwardConf, string sasfile, bool iterate, bool onlyGenerate, From 304048392e2b3ee53aca7f93d88b5a35230f638b Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Thu, 28 Dec 2023 16:50:55 -0600 Subject: [PATCH 4/4] initialize searchRes variable. --- src/SearchEngine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SearchEngine.cpp b/src/SearchEngine.cpp index 3273732e..2aa6c93a 100644 --- a/src/SearchEngine.cpp +++ b/src/SearchEngine.cpp @@ -220,7 +220,7 @@ int main(int argc, char *argv[]) { // bool useTaskHash = true; - int searchRes; // collect the result of runTranslationPlanner + int searchRes = 0; // collect the result of runTranslationPlanner @@ -504,6 +504,7 @@ int main(int argc, char *argv[]) { + /* long initO, initN; long genO, genN;