Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kris701 committed May 13, 2024
1 parent cff00f2 commit 4e31981
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 46 deletions.
13 changes: 8 additions & 5 deletions FlashPlanner.CLI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using CommandLine;
using CommandLine.Text;
using FlashPlanner.Translators;
using PDDLSharp.CodeGenerators.FastDownward.Plans;
using PDDLSharp.ErrorListeners;
using PDDLSharp.Models.PDDL;
Expand All @@ -25,12 +24,16 @@ private static void Main(string[] args)
public static void Run(Options opts)
{
WriteLineColor("Initializing", ConsoleColor.Blue);
WriteLineColor($"\tSearch Arguments: {opts.SearchOption}");
WriteLineColor($"\tSearch Arguments: {opts.SearchOption}");
if (opts.SearchTimeLimit > 0)
WriteLineColor($"\tSearch Time limit: {opts.SearchTimeLimit}s");
WriteLineColor($"\tTranslation Arguments: {opts.TranslatorOption}");
WriteLineColor($"\tSearch Time limit: {opts.SearchTimeLimit}s");
if (opts.SearchMemoryLimit > 0)
WriteLineColor($"\tSearch Memory limit: {opts.SearchMemoryLimit}MB");
WriteLineColor($"\tTranslation Arguments: {opts.TranslatorOption}");
if (opts.TranslatorTimeLimit > 0)
WriteLineColor($"\tTranslation Time limit:{opts.TranslatorTimeLimit}s");
WriteLineColor($"\tTranslation Time limit: {opts.TranslatorTimeLimit}s");
if (opts.TranslatorMemoryLimit > 0)
WriteLineColor($"\tTranslation Memory limit:{opts.TranslatorMemoryLimit}MB");

WriteColor("\tChecking Files...");
opts.DomainPath = RootPath(opts.DomainPath);
Expand Down
2 changes: 1 addition & 1 deletion FlashPlanner.CLI/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"FlashPlanner.CLI": {
"commandName": "Project",
"commandLineArgs": "--domain ../../../../Dependencies/downward-benchmarks/pathways/domain_p05.pddl --problem ../../../../Dependencies/downward-benchmarks/pathways/p05.pddl --search \"greedy(hGoal())\" --search-time-limit 10"
"commandLineArgs": "--domain ../../../../Dependencies/downward-benchmarks/logistics98/domain.pddl --problem ../../../../Dependencies/downward-benchmarks/logistics98/prob10.pddl --search \"greedy(hGoal())\" --search-time-limit 10"
}
}
}
2 changes: 1 addition & 1 deletion FlashPlanner/FlashPlanner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PropertyGroup>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<Version>1.0.15</Version>
<Version>1.0.16</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
7 changes: 1 addition & 6 deletions FlashPlanner/Helpers/MemoryHelper.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace FlashPlanner.Helpers
{
Expand Down
9 changes: 1 addition & 8 deletions FlashPlanner/ILimitedComponent.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static FlashPlanner.LimitedComponent;

namespace FlashPlanner
namespace FlashPlanner
{
public interface ILimitedComponent
{
Expand Down
13 changes: 3 additions & 10 deletions FlashPlanner/LimitedComponent.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
using FlashPlanner.Helpers;
using FlashPlanner.Translators.Components;
using PDDLSharp.Translators.Grounders;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;

namespace FlashPlanner
Expand Down Expand Up @@ -38,9 +31,9 @@ public abstract class LimitedComponent : ILimitedComponent
/// </summary>
public bool Abort { get; set; }

private System.Timers.Timer _timeoutTimer = new System.Timers.Timer();
private System.Timers.Timer _memoryTimer = new System.Timers.Timer();
private Stopwatch _executionTime = new Stopwatch();
private readonly System.Timers.Timer _timeoutTimer = new System.Timers.Timer();
private readonly System.Timers.Timer _memoryTimer = new System.Timers.Timer();
private readonly Stopwatch _executionTime = new Stopwatch();

public void Start()
{
Expand Down
2 changes: 0 additions & 2 deletions FlashPlanner/Search/Classical/BaseClassicalSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using FlashPlanner.Tools;
using PDDLSharp.Models.FastDownward.Plans;
using PDDLSharp.Models.SAS;
using System.Diagnostics;
using System.Timers;

namespace FlashPlanner.Search.Classical
{
Expand Down
8 changes: 2 additions & 6 deletions FlashPlanner/Translators/PDDLToSASTranslator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FlashPlanner.Helpers;
using FlashPlanner.Translators.Components;
using FlashPlanner.Translators.Components;
using FlashPlanner.Translators.Exceptions;
using PDDLSharp.Contextualisers.PDDL;
using PDDLSharp.ErrorListeners;
Expand All @@ -10,9 +9,6 @@
using PDDLSharp.Models.PDDL.Problem;
using PDDLSharp.Models.SAS;
using PDDLSharp.Translators.Grounders;
using System.Diagnostics;
using System.Timers;
using static FlashPlanner.Translators.ITranslator;

namespace FlashPlanner.Translators
{
Expand Down Expand Up @@ -93,7 +89,7 @@ public SASDecl Translate(PDDLDecl from)

if (from.Domain.Predicates != null)
{
foreach(var pred in from.Domain.Predicates.Predicates)
foreach (var pred in from.Domain.Predicates.Predicates)
{
_factSet.Add(pred.Name, new List<Fact>());
_negativeFacts.Add(pred.Name, new List<Fact>());
Expand Down
8 changes: 1 addition & 7 deletions FlashPlanner/Translators/ReachabilityChecker.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using FlashPlanner.States;
using FlashPlanner.Tools;
using PDDLSharp.Models.SAS;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FlashPlanner.Translators
{
Expand All @@ -29,7 +23,7 @@ public List<Operator> GetPotentiallyReachableOperators(SASDecl decl)
{
any = false;
var applicableNow = new List<Operator>();
for(int i = 0; i < decl.Operators.Count; i++)
for (int i = 0; i < decl.Operators.Count; i++)
{
if (!covered[i] && state.IsApplicable(decl.Operators[i]))
{
Expand Down

0 comments on commit 4e31981

Please sign in to comment.