Skip to content

Commit

Permalink
Changed agent limit parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-lam committed Mar 31, 2022
1 parent 94414ff commit a5ea42b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Please cite these articles if you use this code for the multi-agent path finding
License
-------

BCP is released under the GPL version 3. See LICENSE.txt for further details.
BCP is released under the GPL version 3. See LICENSE.txt for further details.

Dependencies
------------
Expand Down Expand Up @@ -78,7 +78,7 @@ Benchmark instances can be found in the `movingai_2018` and `movingai_2019` dire

The 2019 instances are organised differently. There is (usually) a total of 1000 agents in each instance file, and the user can specify how many of the first N agents to run. For example, you can run an instance with only the first 50 agents:
```
./bcp-mapf --time-limit=30 --agents-limit=50 ../instances/movingai_2019/den520d-random-1.scen
./bcp-mapf --time-limit=30 --agent-limit=50 ../instances/movingai_2019/den520d-random-1.scen
```

The optimal solution (or feasible solution if a time limit or gap limit is reached) will be saved into the `outputs` directory.
Expand Down
14 changes: 7 additions & 7 deletions bcp/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SCIP_RETCODE start_solver(
{
// Parse program options.
String instance_file;
Agent agents_limit = std::numeric_limits<Agent>::max();
Agent agent_limit = std::numeric_limits<Agent>::max();
SCIP_Real time_limit = 0;
SCIP_Longint node_limit = 0;
SCIP_Real gap_limit = 0;
Expand All @@ -47,7 +47,7 @@ SCIP_RETCODE start_solver(
options.add_options()
("help", "Print help")
("f,file", "Path to instance file", cxxopts::value<Vector<String>>())
("a,agents-limit", "Read first N agents only", cxxopts::value<Agent>())
("a,agent-limit", "Read the first several agents only", cxxopts::value<Agent>())
("t,time-limit", "Time limit in seconds", cxxopts::value<SCIP_Real>())
("n,node-limit", "Maximum number of branch-and-bound nodes", cxxopts::value<SCIP_Longint>())
("g,gap-limit", "Solve to an optimality gap", cxxopts::value<SCIP_Real>())
Expand All @@ -70,10 +70,10 @@ SCIP_RETCODE start_solver(
instance_file = result["file"].as<Vector<String>>().at(0);
}

// Get agents limit.
if (result.count("agents-limit"))
// Get agent limit.
if (result.count("agent-limit"))
{
agents_limit = result["agents-limit"].as<Agent>();
agent_limit = result["agent-limit"].as<Agent>();
}

// Get time limit.
Expand Down Expand Up @@ -349,8 +349,8 @@ SCIP_RETCODE start_solver(
}

// Read instance.
release_assert(agents_limit > 0, "Cannot limit to {} number of agents", agents_limit);
SCIP_CALL(read_instance(scip, instance_file.c_str(), agents_limit));
release_assert(agent_limit > 0, "Cannot limit to {} number of agents", agent_limit);
SCIP_CALL(read_instance(scip, instance_file.c_str(), agent_limit));

// Set time limit.
if (time_limit > 0)
Expand Down
8 changes: 4 additions & 4 deletions trufflehog/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void read_map(const std::filesystem::path& map_path, Map& map)
map_file.close();
}

Instance::Instance(const std::filesystem::path& scenario_path, const Agent nb_agents) :
Instance::Instance(const std::filesystem::path& scenario_path, const Agent agent_limit) :
scenario_path(scenario_path),
map_path(),
map(),
Expand Down Expand Up @@ -155,7 +155,7 @@ Instance::Instance(const std::filesystem::path& scenario_path, const Agent nb_ag
Position goal_y;
Float tmp;
AgentMapData agent_map_data;
while (agents.size() < nb_agents &&
while (agents.size() < agent_limit &&
(scen_file >> tmp >>
agent_map_data.map_path >>
agent_map_data.map_width >> agent_map_data.map_height >>
Expand Down Expand Up @@ -185,9 +185,9 @@ Instance::Instance(const std::filesystem::path& scenario_path, const Agent nb_ag
agents_map_data.push_back(agent_map_data);
}
}
release_assert(nb_agents == std::numeric_limits<Int>::max() || agents.size() == nb_agents,
release_assert(agent_limit == std::numeric_limits<Int>::max() || agents.size() == agent_limit,
"Scenario file contained {} agents. Not enough to read {} agents",
agents.size(), nb_agents);
agents.size(), agent_limit);
release_assert(!agents.empty(), "No agents in scenario file {}", scenario_path.string());

// Close file.
Expand Down
2 changes: 1 addition & 1 deletion trufflehog/Instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct Instance
public:
// Constructors
Instance() = default;
Instance(const std::filesystem::path& scenario_path, const Agent nb_agents = std::numeric_limits<Agent>::max());
Instance(const std::filesystem::path& scenario_path, const Agent agent_limit = std::numeric_limits<Agent>::max());
Instance(const Instance&) = default;
Instance(Instance&&) = default;
Instance& operator=(const Instance&) = default;
Expand Down

0 comments on commit a5ea42b

Please sign in to comment.