/// <summary> /// <see cref="IBaseOptimizer{TParams, TProblem}.Minimize(TParams, TProblem, IProgress{Progress}, CancellationToken)"/> /// </summary> /// <param name="Parameters"> General parameters.</param> /// <param name="Problem">Multiobjective problem</param> /// <param name="Reporter"> /// Object which implement interface <see cref="IProgress{T}"/>, where T is /// <see cref="Progress"/>./> /// </param> /// <param name="CancelToken"> <see cref="CancellationToken"/> </param> /// <exception cref="InvalidOperationException"> If parameters do not set. </exception> /// <exception cref="ArgumentNullException"> /// If <paramref name="Problem"/> or <paramref name="Reporter"/> is null. /// </exception> /// <exception cref="ArithmeticException"> /// If the function has value is NaN, PositiveInfinity or NegativeInfinity. /// </exception> /// <exception cref="OperationCanceledException"></exception> public override void Minimize(FWParams Parameters, IMOOptProblem Problem, IProgress <Progress> Reporter, CancellationToken CancelToken) { if (Reporter == null) { throw new ArgumentNullException(nameof(Reporter)); } if (Problem == null) { throw new ArgumentNullException(nameof(Problem)); } Init(Parameters, Problem.LowerBounds.Count, Problem.CountObjs); FirstStep(Problem); Progress progress = new Progress(this, 0, this._parameters.Imax - 1, 0); Reporter.Report(progress); for (int i = 1; i < this._parameters.Imax; i++) { CancelToken.ThrowIfCancellationRequested(); NextStep(Problem); progress.Current = i; Reporter.Report(progress); } Clear(); }
protected override void NextStep(IMOOptProblem Problem) { int[] fronts = null; if (_isUseChachedFronts) { fronts = _currentFronts; } else { fronts = _nds.NonDominSort(_chargePoints.Select(item => item.Objs)); _isUseChachedFronts = true; } var countFronts = fronts.GroupBy(frontIndex => frontIndex).ToDictionary(item => item.Key, item => item.Count()); int maxFront = countFronts.Keys.Max() + 1; FindAmountDebris(fronts, countFronts, maxFront); GenerateDebris(Problem.LowerBounds, Problem.UpperBounds, fronts, countFronts, maxFront); EvalFunctionForDebris(Problem.TargetFunction); var allAgents = _chargePoints.Concat(_debris.SelectMany(coll => coll.Select(agent => agent))); int[] allFronts = _nds.NonDominSort(allAgents.Select(agent => agent.Objs)); GenerateNextAgents(allAgents, allFronts); EvalFunctionForCharges(Problem.TargetFunction); }
protected override void FirstStep(IMOOptProblem Problem) { if (Problem == null) { throw new ArgumentNullException(nameof(Problem)); } InitAgents(Problem.LowerBounds, Problem.UpperBounds, Problem.CountObjs); EvalFunctionForCharges(Problem.TargetFunction); }
/// <summary> /// <see cref="IBaseOptimizer{TParams, TProblem}.Minimize(TParams, TProblem, IProgress{Progress}, CancellationToken)"/> /// </summary> /// <param name="Parameters"> General parameters.</param> /// <param name="Problem">Multiobjective problem</param> /// <param name="CancelToken"> <see cref="CancellationToken"/> </param> /// <exception cref="InvalidOperationException"> If parameters do not set. </exception> /// <exception cref="ArgumentNullException"> If <paramref name="Problem"/> is null. </exception> /// <exception cref="ArithmeticException"> /// If the function has value is NaN, PositiveInfinity or NegativeInfinity. /// </exception> /// <exception cref="OperationCanceledException"></exception> public override void Minimize(FWParams Parameters, IMOOptProblem Problem, CancellationToken CancelToken) { if (Problem == null) { throw new ArgumentNullException(nameof(Problem)); } Init(Parameters, Problem.LowerBounds.Count, Problem.CountObjs); FirstStep(Problem); for (int i = 1; i < this._parameters.Imax; i++) { CancelToken.ThrowIfCancellationRequested(); NextStep(Problem); } Clear(); }
/// <summary> /// <see cref="IBaseOptimizer{TParams, TProblem}.Minimize(TParams, TProblem)"/> /// </summary> /// <param name="Parameters"> General parameters. <see cref="FWParams"/>. </param> /// <param name="Problem">Multiobjective problem</param> /// <exception cref="InvalidOperationException"> If parameters do not set. </exception> /// <exception cref="ArgumentNullException"> If <paramref name="Problem"/> is null. </exception> /// <exception cref="ArithmeticException"> /// If the function has value is NaN, PositiveInfinity or NegativeInfinity. /// </exception> public override void Minimize(FWParams Parameters, IMOOptProblem Problem) { if (Problem == null) { throw new ArgumentNullException(nameof(Problem)); } Init(Parameters, Problem.LowerBounds.Count, Problem.CountObjs); FirstStep(Problem); for (int i = 1; i < _parameters.Imax; i++) { _iter = i; NextStep(Problem); } Clear(); }