Update solver
This commit is contained in:
@@ -667,15 +667,8 @@ public sealed class Settings : Window, IDisposable
|
|||||||
v => config = config with { Adversarial = v },
|
v => config = config with { Adversarial = v },
|
||||||
ref isDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
DrawOption(
|
|
||||||
"Minimize Steps",
|
|
||||||
"Minimizes the number of crafting steps.",
|
|
||||||
config.MinimizeSteps,
|
|
||||||
v => config = config with { MinimizeSteps = v },
|
|
||||||
ref isDirty
|
|
||||||
);
|
|
||||||
|
|
||||||
if (config.MinimizeSteps && config.Adversarial)
|
if (config.Adversarial)
|
||||||
{
|
{
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
using (var color = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudOrange))
|
using (var color = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudOrange))
|
||||||
@@ -684,7 +677,7 @@ public sealed class Settings : Window, IDisposable
|
|||||||
ImGui.TextUnformatted(FontAwesomeIcon.ExclamationCircle.ToIconString());
|
ImGui.TextUnformatted(FontAwesomeIcon.ExclamationCircle.ToIconString());
|
||||||
}
|
}
|
||||||
if (ImGui.IsItemHovered())
|
if (ImGui.IsItemHovered())
|
||||||
ImGuiUtils.TooltipWrapped("Combining \"Minimize Steps\" and \"Ensure Reliability\" will significantly increase solve times.");
|
ImGuiUtils.TooltipWrapped("\"Ensure Reliability\" uses a lot more memory and can significantly increase solve times.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
},
|
},
|
||||||
"Raphael.Net": {
|
"Raphael.Net": {
|
||||||
"type": "Transitive",
|
"type": "Transitive",
|
||||||
"resolved": "2.1.1",
|
"resolved": "3.0.0",
|
||||||
"contentHash": "4+7HyDa7lVokXObqv8ADeTgi74Cz7W99N07DYtzuOXEt6tJtMlJt8RxLGoPtakVf1mURDMuD5kDKw0oz3EaoDA=="
|
"contentHash": "9yY+jR2gddw52HtShBL/JikQ4gZa8lxFYSUIi2y510HLsaK86iqtuRgrv8/akrHR66QRWEPtmHXyehW1hrmP9Q=="
|
||||||
},
|
},
|
||||||
"System.IO.Hashing": {
|
"System.IO.Hashing": {
|
||||||
"type": "Transitive",
|
"type": "Transitive",
|
||||||
@@ -52,15 +52,15 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Craftimizer.Simulator": "[1.0.0, )",
|
"Craftimizer.Simulator": "[1.0.0, )",
|
||||||
"DotNext": "[5.21.0, )",
|
"DotNext": "[5.21.0, )",
|
||||||
"Raphael.Net": "[2.1.1, )"
|
"Raphael.Net": "[3.0.0, )"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"net9.0-windows7.0/win-x64": {
|
"net9.0-windows7.0/win-x64": {
|
||||||
"Raphael.Net": {
|
"Raphael.Net": {
|
||||||
"type": "Transitive",
|
"type": "Transitive",
|
||||||
"resolved": "2.1.1",
|
"resolved": "3.0.0",
|
||||||
"contentHash": "4+7HyDa7lVokXObqv8ADeTgi74Cz7W99N07DYtzuOXEt6tJtMlJt8RxLGoPtakVf1mURDMuD5kDKw0oz3EaoDA=="
|
"contentHash": "9yY+jR2gddw52HtShBL/JikQ4gZa8lxFYSUIi2y510HLsaK86iqtuRgrv8/akrHR66QRWEPtmHXyehW1hrmP9Q=="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Raphael.Net" Version="2.1.1" />
|
<PackageReference Include="Raphael.Net" Version="3.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
+16
-46
@@ -205,56 +205,26 @@ public sealed class Solver : IDisposable
|
|||||||
void Log(string s) =>
|
void Log(string s) =>
|
||||||
OnLog?.Invoke(s);
|
OnLog?.Invoke(s);
|
||||||
|
|
||||||
if (!Config.MinimizeSteps)
|
Raphael.SolverConfig config = new()
|
||||||
{
|
{
|
||||||
Raphael.SolverConfig config = new()
|
Adversarial = Config.Adversarial,
|
||||||
{
|
BackloadProgress = Config.BackloadProgress,
|
||||||
Adversarial = Config.Adversarial,
|
LogLevel = Raphael.LevelFilter.Debug,
|
||||||
BackloadProgress = true,
|
ThreadCount = (ushort)Config.MaxThreadCount,
|
||||||
UnsoundBranchPruning = true,
|
};
|
||||||
LogLevel = Raphael.LevelFilter.Debug,
|
|
||||||
ThreadCount = (ushort)Config.MaxThreadCount,
|
|
||||||
};
|
|
||||||
|
|
||||||
using var solver = new Raphael.Solver(in config, in input, pool);
|
using var solver = new Raphael.Solver(in config, in input, pool);
|
||||||
|
|
||||||
solver.OnFinish += OnFinish;
|
solver.OnFinish += OnFinish;
|
||||||
solver.OnSuggestSolution += OnSuggestSolution;
|
solver.OnSuggestSolution += OnSuggestSolution;
|
||||||
solver.OnProgress += OnProgress;
|
solver.OnProgress += OnProgress;
|
||||||
solver.OnLog += Log;
|
solver.OnLog += Log;
|
||||||
|
|
||||||
progressStage = 0;
|
progressStage = 0;
|
||||||
progress = 0;
|
progress = 0;
|
||||||
await using var registration = Token.Register(solver.Cancel).ConfigureAwait(true);
|
await using var registration = Token.Register(solver.Cancel).ConfigureAwait(true);
|
||||||
await Task.Run(solver.Solve, Token).ConfigureAwait(true);
|
await Task.Run(solver.Solve, Token).ConfigureAwait(true);
|
||||||
Token.ThrowIfCancellationRequested();
|
Token.ThrowIfCancellationRequested();
|
||||||
}
|
|
||||||
|
|
||||||
var state = solution != null ? (SimulationState?)ExecuteActions(solution) : null;
|
|
||||||
if (solution == null || state?.Quality != state?.Input.Recipe.MaxQuality)
|
|
||||||
{
|
|
||||||
Raphael.SolverConfig config = new()
|
|
||||||
{
|
|
||||||
Adversarial = Config.Adversarial,
|
|
||||||
BackloadProgress = Config.BackloadProgress,
|
|
||||||
UnsoundBranchPruning = false,
|
|
||||||
LogLevel = Raphael.LevelFilter.Debug,
|
|
||||||
ThreadCount = (ushort)Config.MaxThreadCount,
|
|
||||||
};
|
|
||||||
|
|
||||||
using var solver = new Raphael.Solver(in config, in input, pool);
|
|
||||||
|
|
||||||
solver.OnFinish += OnFinish;
|
|
||||||
solver.OnSuggestSolution += OnSuggestSolution;
|
|
||||||
solver.OnProgress += OnProgress;
|
|
||||||
solver.OnLog += Log;
|
|
||||||
|
|
||||||
progressStage = 0;
|
|
||||||
progress = 0;
|
|
||||||
await using var registration = Token.Register(solver.Cancel).ConfigureAwait(true);
|
|
||||||
await Task.Run(solver.Solve, Token).ConfigureAwait(true);
|
|
||||||
Token.ThrowIfCancellationRequested();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (solution == null)
|
if (solution == null)
|
||||||
return new([], State);
|
return new([], State);
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ public readonly record struct SolverConfig
|
|||||||
// Raphael/A* configuration
|
// Raphael/A* configuration
|
||||||
public bool Adversarial { get; init; }
|
public bool Adversarial { get; init; }
|
||||||
public bool BackloadProgress { get; init; }
|
public bool BackloadProgress { get; init; }
|
||||||
public bool MinimizeSteps { get; init; }
|
|
||||||
|
|
||||||
public int MaxThreadCount { get; init; }
|
public int MaxThreadCount { get; init; }
|
||||||
public ActionType[] ActionPool { get; init; }
|
public ActionType[] ActionPool { get; init; }
|
||||||
|
|||||||
Reference in New Issue
Block a user