Skip to content

Commit

Permalink
limit the maximum length of a solution string representation.
Browse files Browse the repository at this point in the history
  • Loading branch information
J-morag committed Apr 4, 2023
1 parent da35481 commit 1fdc244
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/BasicMAPF/Solvers/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* If the collection contains more than one plan, it is a solution to a Multi Agent Path Finding problem.
*/
public class Solution implements Iterable<SingleAgentPlan>{
private static final int looseMaxSolutionStringChars = 10000 /*lines*/ * 20 /*chars (roughly)*/;
/**
* A {@link Map}, mapping {@link Agent agents} to their {@link SingleAgentPlan plans}.
*/
Expand Down Expand Up @@ -259,6 +260,10 @@ public StringBuilder readableToString(){
Collections.sort(agents, Comparator.comparing(agent -> agent.iD));
for(Agent agent : agents){
sb.append(this.agentPlans.get(agent));
if (sb.length() > looseMaxSolutionStringChars){
sb.append("... (truncated)");
break;
}
}
sb.append('\n');
return sb;
Expand Down

0 comments on commit 1fdc244

Please sign in to comment.