/
GeekNerd
/
ServerModelingProject
Обзор
Документация
Войти
/
GeekNerd
/
ServerModelingProject
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Assets/Scripts/OptimizationLogic/App/OptimizationOrchestrator.cs
67 строк
2 KB
Gorney-Alex
Init
30 май 2026, 19:05
30 май 2026, 19:05
3cdcc49
Код
Авторство
О чём код?
using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using DataClasses; using DataClasses.Algorithm; using OptimizationLogic.Core; using UnityEngine; namespace OptimizationLogic.App { /// <summary> /// Orchestrates the full optimization pipeline (TZ §6) without owning any scene state. /// Integrate this from a MonoBehaviour/UI by providing RoomConfig + rack catalog + settings. /// </summary> public sealed class OptimizationOrchestrator { private readonly ZonePartitioner _partitioner = new(); private readonly GreedyPlacer _greedy = new(); private readonly GeneticAlgorithm _ga = new(); private readonly ZonalThermalModel _thermal = new(); public async Task<OptimizationResult> RunAsync( RoomConfig room, IReadOnlyList<RackData> rackCatalog, GaSettings settings, IProgress<GaProgress> progress, CancellationToken ct) { if (room == null) throw new ArgumentNullException(nameof(room)); if (rackCatalog == null) throw new ArgumentNullException(nameof(rackCatalog)); List<PlacementZone> zones = _partitioner.Partition(room, rackCatalog); Chromosome greedy = _greedy.Place(room, zones, rackCatalog); Chromosome best = await _ga.OptimizeAsync(room, zones, rackCatalog, settings, progress, ct); var temps = _thermal.ComputeZoneTemperatures(room, zones, best.Genes, rackCatalog); return new OptimizationResult(zones, greedy, best, temps, _thermal.MaxTemperature); } } public readonly struct OptimizationResult { public readonly IReadOnlyList<PlacementZone> Zones; public readonly Chromosome Greedy; public readonly Chromosome Best; public readonly IReadOnlyDictionary<int, float> ZoneTemperatures; public readonly float MaxTemperature; public OptimizationResult( IReadOnlyList<PlacementZone> zones, Chromosome greedy, Chromosome best, IReadOnlyDictionary<int, float> zoneTemperatures, float maxTemperature) { Zones = zones; Greedy = greedy; Best = best; ZoneTemperatures = zoneTemperatures; MaxTemperature = maxTemperature; } } }