<commit_before>package fape;

import com.martiansoftware.jsap.*;
import fape.core.planning.Plan;
import fape.core.planning.Planner;
import fape.core.planning.planner.APlanner;
import fape.core.planning.planner.BaseDTG;
import fape.core.planning.planner.PGExtPlanner;
import fape.core.planning.planner.TaskConditionPlanner;
import fape.core.planning.planninggraph.PGPlanner;
import fape.core.planning.states.Printer;
import fape.core.planning.states.State;
import fape.exceptions.FAPEException;
import fape.util.Utils;
import planstack.anml.parser.ANMLFactory;
import planstack.constraints.stnu.Controllability;

import java.io.*;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

public class Planning {

    public static String currentPlanner = "";

    /**
     * Tries to infer which file contains the domain definition of this problem.
     * If the problem takes a form "domainName.xxxx.pb.anml", then the
     * corresponding domain file would be "domainName.dom.anml"
     */
    public static String domainFile(String problemFile) {
        File f = new File(problemFile);
        String name = f.getName();
        if (name.endsWith(".pb.anml")) {
            String[] nameParts = name.split("\\.");

            if (nameParts.length != 4) {
                throw new FAPEException("File name " + name + " is not correctly formatted. It should be in the form "
                        + " domainName.xxx.pb.anml and have an associated domainName.dom.anml file.");
            }

            File domain = new File(f.getParentFile(), nameParts[0] + ".dom.anml");
            if (!domain.exists()) {
                throw new FAPEException("File " + domain + " does not exists (name derived from " + problemFile + ")");
            }

            return domain.getPath();
        } else {
            return null;
        }
    }

    public static void main(String[] args) throws Exception {
        SimpleJSAP jsap = new SimpleJSAP(
                "FAPE planners",
                "Solves ANML problems",
                new Parameter[]{
                        new Switch("verbose", 'v', "verbose", "Requests verbose output. Every search node will be displayed."),
                        new Switch("quiet", 'q', "quiet", "Planner won't print the final plan."),
                        new Switch("debug", 'd', "debug", "Set the planner in debugging mode. "
                                + "Mainly consists in time consuming checks."),
                        new Switch("actions-chart", JSAP.NO_SHORTFLAG, "gui", "Planner will show the actions on a time chart."),
                        new Switch("dispatchable", JSAP.NO_SHORTFLAG, "dispatchable", "FAPE will build a dispatchable Plan. "+
                                "This is step mainly involves building a dynamically controllable STNU that is used to check " +
                                "which actions can be dispatched."),
                        new FlaggedOption("plannerID")
                                .setStringParser(JSAP.STRING_PARSER)
                                .setShortFlag('p')
                                .setLongFlag("planner")
                                .setDefault("base")
                                .setList(true)
                                .setListSeparator(',')
                                .setHelp("Defines which planner implementation to use. Possible values are:\n"
                                        + "   - base: Main FAPE planner that supports any domain. Uses a fully lifted representation.\n"
                                        + "   - base+dtg: Same as base but uses DTG to select action resolvers.\n"
                                        + "   - rpg:  Planner that uses relaxed planning graphs for domain analysis. "
                                        + "Be aware that it does not handle all anml problems.\n"<commit_msg>Make base+dtg the default planner.<commit_after>package fape;

import com.martiansoftware.jsap.*;
import fape.core.planning.Plan;
import fape.core.planning.Planner;
import fape.core.planning.planner.APlanner;
import fape.core.planning.planner.BaseDTG;
import fape.core.planning.planner.PGExtPlanner;
import fape.core.planning.planner.TaskConditionPlanner;
import fape.core.planning.planninggraph.PGPlanner;
import fape.core.planning.states.Printer;
import fape.core.planning.states.State;
import fape.exceptions.FAPEException;
import fape.util.Utils;
import planstack.anml.parser.ANMLFactory;
import planstack.constraints.stnu.Controllability;

import java.io.*;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

public class Planning {

    public static String currentPlanner = "";

    /**
     * Tries to infer which file contains the domain definition of this problem.
     * If the problem takes a form "domainName.xxxx.pb.anml", then the
     * corresponding domain file would be "domainName.dom.anml"
     */
    public static String domainFile(String problemFile) {
        File f = new File(problemFile);
        String name = f.getName();
        if (name.endsWith(".pb.anml")) {
            String[] nameParts = name.split("\\.");

            if (nameParts.length != 4) {
                throw new FAPEException("File name " + name + " is not correctly formatted. It should be in the form "
                        + " domainName.xxx.pb.anml and have an associated domainName.dom.anml file.");
            }

            File domain = new File(f.getParentFile(), nameParts[0] + ".dom.anml");
            if (!domain.exists()) {
                throw new FAPEException("File " + domain + " does not exists (name derived from " + problemFile + ")");
            }

            return domain.getPath();
        } else {
            return null;
        }
    }

    public static void main(String[] args) throws Exception {
        SimpleJSAP jsap = new SimpleJSAP(
                "FAPE planners",
                "Solves ANML problems",
                new Parameter[]{
                        new Switch("verbose", 'v', "verbose", "Requests verbose output. Every search node will be displayed."),
                        new Switch("quiet", 'q', "quiet", "Planner won't print the final plan."),
                        new Switch("debug", 'd', "debug", "Set the planner in debugging mode. "
                                + "Mainly consists in time consuming checks."),
                        new Switch("actions-chart", JSAP.NO_SHORTFLAG, "gui", "Planner will show the actions on a time chart."),
                        new Switch("dispatchable", JSAP.NO_SHORTFLAG, "dispatchable", "FAPE will build a dispatchable Plan. "+
                                "This is step mainly involves building a dynamically controllable STNU that is used to check " +
                                "which actions can be dispatched."),
                        new FlaggedOption("plannerID")
                                .setStringParser(JSAP.STRING_PARSER)
                                .setShortFlag('p')
                                .setLongFlag("planner")
                                .setDefault("base+dtg")
                                .setList(true)
                                .setListSeparator(',')
                                .setHelp("Defines which planner implementation to use. Possible values are:\n"
                                        + "   - base: Main FAPE planner that supports any domain. Uses a fully lifted representation.\n"
                                        + "   - base+dtg: Same as base but uses DTG to select action resolvers.\n"
                                        + "   - rpg:  Planner that uses relaxed planning graphs for domain analysis. "
                                        + "Be aware that it does not handle all anml problems.\n"
{'fraction_non_alphanumeric': 0.09707631945323376, 'fraction_numerical': 0.0005062650297430705, 'mean_word_length': 1.810099573257468, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5814811', 'n_tokens_mistral': 2056, 'n_tokens_neox': 1969, 'n_words': 605}