using System;
using MultiWheelC.TrajectoryPlanning.Utils;

namespace MultiWheelC.TrajectoryPlanning.EMPlanner;

public sealed class QpSolverSettings
{
    public QpSolverSettings(
        int maximumIterations,
        double absoluteTolerance,
        double relativeTolerance,
        TimeSpan timeLimit,
        bool enableWarmStart,
        bool enablePolishing,
        bool enableNativeVerboseOutput)
    {
        if (maximumIterations <= 0)
            throw new ArgumentOutOfRangeException(nameof(maximumIterations));
        if (!NumericGuard.IsPositiveFinite(absoluteTolerance))
            throw new ArgumentOutOfRangeException(nameof(absoluteTolerance));
        if (!NumericGuard.IsPositiveFinite(relativeTolerance))
            throw new ArgumentOutOfRangeException(nameof(relativeTolerance));
        if (timeLimit <= TimeSpan.Zero)
            throw new ArgumentOutOfRangeException(nameof(timeLimit));

        MaximumIterations = maximumIterations;
        AbsoluteTolerance = absoluteTolerance;
        RelativeTolerance = relativeTolerance;
        TimeLimit = timeLimit;
        EnableWarmStart = enableWarmStart;
        EnablePolishing = enablePolishing;
        EnableNativeVerboseOutput = enableNativeVerboseOutput;
    }

    public int MaximumIterations { get; }

    public double AbsoluteTolerance { get; }

    public double RelativeTolerance { get; }

    public TimeSpan TimeLimit { get; }

    public bool EnableWarmStart { get; }

    public bool EnablePolishing { get; }

    public bool EnableNativeVerboseOutput { get; }
}
