diff --git a/src/lpexec_src/FileConfig.cpp b/src/lpexec_src/FileConfig.cpp index f2652e7..04e81cd 100644 --- a/src/lpexec_src/FileConfig.cpp +++ b/src/lpexec_src/FileConfig.cpp @@ -37,7 +37,7 @@ FileConfig::FileConfig(){ // Set defaults //Default for lpmln: Solver is MLN, Input is MVSM loptions.insert(pair("input","mvsm")); - //Compile for Alchemy + //Compile for Clingo loptions.insert(pair("solver","clingo")); //max number of solutions for clingo coptions.insert(pair("solutions","0")); @@ -119,8 +119,13 @@ FileConfig::FileConfig(){ if(region == Region::LPMLN){ if(equalsIgnoreCase("solver",lhs)){ - if(equalsIgnoreCase("alchemy",rhs)) + if(equalsIgnoreCase("alchemy",rhs)){ aoptions.insert(pair("region","alch")); + execute_alch = true; + } + else if(equalsIgnoreCase("clingo",rhs)){ + execute_cli = true; + } loptions["solver"] = rhs; } @@ -179,6 +184,10 @@ FileConfig::FileConfig(){ } } + if(!execute_alch && !execute_cli){ + throw; + } + //Parsing done //Check validity diff --git a/src/lpexec_src/lpexec.cpp b/src/lpexec_src/lpexec.cpp index d05cef1..09d08f0 100644 --- a/src/lpexec_src/lpexec.cpp +++ b/src/lpexec_src/lpexec.cpp @@ -88,13 +88,9 @@ int main(int argc, char **argv) { Region region = NONE; - FileConfig cf; + bool pickUpFromCommandLine = false; + - map loptions; - loptions = cf.getloptions(); - map aoptions = cf.getaoptions(); - map coptions = cf.getcoptions(); - string lpmln = "lpmlncompiler "; string alchemy = "infer "; string clingo = "clingo "; @@ -107,15 +103,37 @@ int main(int argc, char **argv) string cli = "-clingo"; string tuf = "-tuffy"; - // Execute cli is true by default - bool execute_alch = cf.getExecuteAlch(); - bool execute_cli = cf.getExecuteCli(); - bool execute_tuf = false; + + map loptions ; + map aoptions ; + map coptions ; + + bool execute_alch ; + bool execute_cli ; + bool execute_tuf ; set lpset; set alchset; set clingoset; + try{ + FileConfig cf; + + loptions = cf.getloptions(); + aoptions = cf.getaoptions(); + coptions = cf.getcoptions(); + + + // Execute cli is true by default + execute_alch = cf.getExecuteAlch(); + execute_cli = cf.getExecuteCli(); + execute_tuf = false; + } + catch(...){ + // No solver is specified in the config file. Need to pick it up from command line. + pickUpFromCommandLine = true; + } + uuid_t uuid; uuid_generate_random ( uuid ); char s[37]; @@ -160,12 +178,18 @@ int main(int argc, char **argv) if(arg.compare(alch) == 0){ region = ALCH; execute_alch = true; + execute_cli = false; + // loptions + loptions["solver"] = "alchemy"; continue; } if(arg.compare(cli) == 0){ region = CLINGO; execute_cli = true; + execute_alch = false; + // loptions.insert(pair("solver","clingo")); + loptions["solver"] = "clingo"; continue; } @@ -182,6 +206,14 @@ int main(int argc, char **argv) if(arg.compare("-A") == 0 || arg.compare("-M") == 0){ lpset.insert("solver"); lpmln += SPACE + string(argv[i]) + SPACE; + if(arg.compare("-A") == 0){ + execute_cli = true; + execute_alch = false; + } + else{ + execute_alch = true; + execute_cli = false; + } } else if(arg.compare("-a") == 0 || arg.compare("-m") == 0 || arg.compare("-p") == 0){ @@ -289,16 +321,18 @@ int main(int argc, char **argv) for (auto it=coptions.begin(); it!=coptions.end(); ++it){ string str = it->first; - auto itr = lpset.find(str); - if(itr == lpset.end()){ + auto itr = clingoset.find(str); + if(itr == clingoset.end()){ clingo += SPACE + it->second + SPACE; } } lpmln += SPACE + string(">") + SPACE + string("/tmp/") + fileName; - std::cout<