⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hillclimbing.h

📁 C语言库函数的原型,有用的拿去
💻 H
📖 第 1 页 / 共 2 页
字号:
// ==++==
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--==
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
//
// HillClimbing.h
//
// Defines classes for the HillClimbing concurrency-optimization algorithm.
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

#pragma once

namespace Concurrency
{
namespace details
{

    /// <summary>
    ///     An enum representing all possible hill climbing transition moves.
    /// </summary>
    enum HillClimbingStateTransition 
    {
        Warmup, 
        ContinueInitializing,
        CompletedInitialization,
        DoClimbing,
        ChangePoint,
        ContinueLookingForClimb,
        Undefined,
    };

    /// <summary>
    ///     A class responsible for hill climbing.
    /// </summary>
    class HillClimbing
    {
    public:

        /// <summary>
        ///     Creates a new instance of hill climbing.
        /// </summary>
        /// <param name="id">
        ///     Scheduler id.
        /// </param>
        /// <param name="numberOfCores">
        ///     Number that represents the maximum resources available on the machine.
        /// </param>
        /// <param name="pSchedulerProxy">
        ///     The scheduler proxy that controls this hill climbing instance.
        /// </param>
        HillClimbing(unsigned int id, unsigned int numberOfCores, SchedulerProxy * pSchedulerProxy);

        /// <summary>
        ///     External call passing statistical information to hill climbing. Based on these
        ///     statistics, hill climbing will give a recommendation on the number of resources to be used.
        /// </summary>
        /// <param name="currentControlSetting">
        ///     The control setting used in this period of time.
        /// </param>
        /// <param name="completionRate">
        ///     The number of completed units or work in that period of time.
        /// </param>
        /// <param name="arrivalRate">
        ///     The number of incoming units or work in that period of time.
        /// </param>
        /// <param name="queueLength">
        ///     The total length of the work queue.
        /// </param>
        /// <returns>
        ///     The recommended number of resources to be used.
        /// </returns>
        unsigned int Update(unsigned int currentControlSetting, unsigned int completionRate, unsigned int arrivalRate, unsigned int queueLength);

    private:

        /// <summary>
        ///     A class responsible for keeping hill climbing history measurements.
        /// </summary>
        class MeasuredHistory
        {
        public:

            /// <summary>
            ///     Creates a new measurement history.
            /// </summary>
            MeasuredHistory();

            /// <summary>
            ///     Adds a new history data point.
            /// </summary>
            /// <param name="dataValue">
            ///     The value representing throughput in this invocation.
            /// </param>
            /// <param name="totalSampleCount">
            ///     The value representing the total number of samples for this history, including invalid samples and samples for previous settings.
            /// </param>
            void Add(const double data, unsigned int totalSampleCount);

            /// <summary>
            ///     Clears the history values for this control setting.
            /// </summary>
            /// <param name="controlSetting">
            ///     The control setting to reset.
            /// </param>
            void Clear(unsigned int controlSetting);

            /// <summary>
            ///     Gets the count for this history measurement.
            /// </summary>
            /// <returns>
            ///     The count.
            /// </returns>
            int Count();

            /// <summary>
            ///     Gets the count at the last data point for this history measurement.
            /// </summary>
            /// <returns>
            ///     The last data point count.
            /// </returns>
            unsigned int LastDataPointCount();

            /// <summary>
            ///     Gets the control setting for this history measurement.
            /// </summary>
            /// <returns>
            ///     The control setting.
            /// </returns>
            int ControlSetting();

            /// <summary>
            ///     Computes the mean for a given history.
            /// </summary>
            /// <returns>
            ///     The mean.
            /// </returns>
            double Mean();

            /// <summary>
            ///     Computes the coefficient of variation for a given history.
            /// </summary>
            /// <returns>
            ///     The coefficient of variation.
            /// </returns>
            double CoefficientOfVariation();

            /// <summary>
            ///     Computes the mean of coefficients of variation for a given history.
            /// </summary>
            /// <returns>
            ///     The mean of coefficients of variation.
            /// </returns>
            double CoefficientOfVariationMean();

            /// <summary>
            ///     Computes the variance for a given history.
            /// </summary>
            /// <returns>
            ///     The variance.
            /// </returns>
            double Variance();

            /// <summary>
            ///     Computes the mean of variances for a given history.
            /// </summary>
            /// <returns>
            ///     The mean of variances.
            /// </returns>
            double VarianceMean();

            /// <summary>
            ///     Computes the standard deviation for a given history.
            /// </summary>
            /// <returns>
            ///     The standard deviation.
            /// </returns>
            double StandardDeviation();

            /// <summary>
            ///     Computes the mean of standard deviations for a given history.
            /// </summary>
            /// <returns>
            ///     The mean of standard deviations.
            /// </returns>
            double StandardDeviationMean();

            /// <summary>
            ///     Tests if the difference between two measurement histories is statistically significant to
            ///     make a hill climbing decision.
            /// </summary>
            /// <remarks>
            ///     A two sided test is used.
            /// </remarks>
            /// <param name="value">
            ///     The value representing the second history.
            /// </param>
            /// <param name="significanceLevel">
            ///     The significance level in percent. Accepts 1 through 10.
            /// </param>
            /// <param name="totalSampleCount">
            ///     The value representing the total number of samples for this history, including invalid samples and samples for previous settings.
            /// </param>
            /// <returns>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -