/// <summary>
        /// Starts optimization.
        /// </summary>
        private void Run()
        {
            // Compute best scratchpad
            var bestDuration = TimeSpan.Zero;

            AttributesOptimizer.RemappingResult        remapping     = null;
            List <AttributesOptimizer.RemappingResult> remappingList = null;

            switch (m_strategy)
            {
            case Strategy.ManualRemappingPointEdition:
                m_areRemappingPointsActive = true;
                if (m_update)
                {
                    remapping = m_remapping;
                    m_manuallyEditedRemappingPoint = remapping.Point.Clone();
                }
                else
                {
                    remapping = AttributesOptimizer.GetResultsFromRemappingPoints(m_plan).Single(x => x.Point == m_manuallyEditedRemappingPoint);
                    m_manuallyEditedRemappingPoint = m_manuallyEditedRemappingPoint.Clone();
                    m_remapping = remapping;
                }
                remapping.Optimize(TimeSpan.MaxValue);
                break;

            case Strategy.Character:
                m_areRemappingPointsActive = false;
                remapping = AttributesOptimizer.OptimizeFromCharacter(m_character, m_plan);
                break;

            case Strategy.OneYearPlan:
                m_areRemappingPointsActive = false;
                remapping = AttributesOptimizer.OptimizeFromFirstYearOfPlan(m_plan);
                break;

            case Strategy.RemappingPoints:
                m_areRemappingPointsActive = true;
                remappingList = AttributesOptimizer.OptimizeFromPlanAndRemappingPoints(m_plan);
                break;

            default:
                throw new NotImplementedException();
            }

            if (m_update)
            {
                // Update the controls for every attribute on the already shown form
                UpdateForm(remapping, remappingList);
            }
            else
            {
                // Update the controls for every attribute
                this.Invoke((MethodInvoker)(() => UpdateForm(remapping, remappingList)));
            }
        }
Example #2
0
        /// <summary>
        /// Starts optimization.
        /// </summary>
        /// <param name="update">if set to <c>true</c> [update].</param>
        /// <exception cref="System.NotImplementedException"></exception>
        private void Run(bool update = false)
        {
            // Compute best scratchpad
            RemappingResult remapping = null;
            ICollection <RemappingResult> remappingList = null;

            switch (m_strategy)
            {
            case AttributeOptimizationStrategy.ManualRemappingPointEdition:
                m_areRemappingPointsActive = true;
                if (update)
                {
                    remapping = m_remapping;
                    m_manuallyEditedRemappingPoint = remapping.Point.Clone();
                }
                else
                {
                    remapping = AttributesOptimizer.GetResultsFromRemappingPoints(m_plan).Single(
                        x => x.Point == m_manuallyEditedRemappingPoint);
                    m_manuallyEditedRemappingPoint = m_manuallyEditedRemappingPoint.Clone();
                    m_remapping = remapping;
                }
                remapping.Optimize(TimeSpan.MaxValue);
                break;

            case AttributeOptimizationStrategy.Character:
                m_areRemappingPointsActive = false;
                remapping = AttributesOptimizer.OptimizeFromCharacter(m_character, m_plan);
                break;

            case AttributeOptimizationStrategy.OneYearPlan:
                m_areRemappingPointsActive = false;
                remapping = AttributesOptimizer.OptimizeFromFirstYearOfPlan(m_plan);
                break;

            case AttributeOptimizationStrategy.RemappingPoints:
                m_areRemappingPointsActive = true;
                remappingList = AttributesOptimizer.OptimizeFromPlanAndRemappingPoints(m_plan);
                break;

            default:
                throw new NotImplementedException();
            }

            // Update the controls for every attribute
            Dispatcher.Invoke(() => UpdateForm(remapping, remappingList));
        }