C# Класс SwarmOps.Tools

Показать файл Открыть проект

Открытые методы

Метод Описание
ArrayToString ( double x ) : string

Convert an array of System.double values to a string.

ArrayToString ( double x, int digits ) : string

Convert an array of System.double values to a string.

ArrayToStringRaw ( double x ) : string

Convert an array of System.double values to a string. Not formatted like a C# array.

ArrayToStringRaw ( double x, int digits ) : string

Convert an array of System.double values to a string. Not formattet like a C# array.

BetterFeasible ( bool oldFeasible, bool newFeasible ) : bool

Return whether feasibility (constraint satisfaction) of new candidate solution is same as or better than feasibility of old candidate solution.

BetterFeasibleFitness ( bool oldFeasible, bool newFeasible, double oldFitness, double newFitness ) : bool

Return whether the new candidate solution is better than the old, depending on their feasibility (constraint satisfaction) and fitness.

BetweenBounds ( double x, double lower, double upper ) : bool

Return whether array of values is between lower and upper boundaries.

Bound ( double x, double lower, double upper ) : double

Bound a value between lower and upper boundaries.

Bound ( double &x, double lower, double upper ) : void

Bound array of values between lower and upper boundaries.

Denormalize ( double x ) : double

Return denormalized version of x. This is useful for avoiding expensive CPU usage when x underflows.

Denormalize ( double &x ) : void

Denormalize an array.

DenormalizeTruncate ( double x ) : double

If Abs(x) is below a limit then it is set to zero.

FormatNumber ( double d ) : string

Convert numeric value d to a string with convenient formatting.

FormatPercent ( double d ) : string

Convert numeric value d to a percentage string, e.g. d==0.253212 returns string "25.32%"

Initialize ( double &x, double value ) : void

Initialize array with value.

InitializeRange ( double &x, double lower, double upper ) : void

Initialize array with the range between the boundaries. That is, x[i] = upper[i]-lower[i].

InitializeUniform ( double &x, double lower, double upper ) : void

Initialize array with uniform random values between given boundaries.

NewMatrix ( int dim1, int dim2 ) : double[][]

Allocate and return a new matrix double[dim1][dim2].

Norm ( double x ) : double

Euclidian norm (or length) of a numeric vector.

NumberToString ( double x, int digits ) : string

Convert a double-value to a string, formatted for array output.

PrintNewline ( ) : void

Print a newline to Console.

PrintParameters ( Problem problem, double parameters ) : void

Print parameters using names associated with an optimization problem.

PrintSolution ( double parameters, double fitness, double fitnessLimit, bool oldFeasible, bool newFeasible, bool formatAsArray ) : void

Print parameters, fitness and feasibility to Console, and print a marking if fitness was an improvement to fitnessLimit.

Sample ( double x, double range ) : double

Pick a uniform random sample from [x-range, x+range].

SampleBounded ( double x, double range, double lowerBound, double upperBound ) : double

First bound the sampling range [x-range, x+range] using lowerBound and upperBound respectively, and then pick a uniform random sample from the bounded range. This avoids samples being boundary points.

Описание методов

ArrayToString() публичный статический Метод

Convert an array of System.double values to a string.
public static ArrayToString ( double x ) : string
x double Array of values to be converted to string.
Результат string

ArrayToString() публичный статический Метод

Convert an array of System.double values to a string.
public static ArrayToString ( double x, int digits ) : string
x double Array of values to be converted to string.
digits int Number of digits for each value.
Результат string

ArrayToStringRaw() публичный статический Метод

Convert an array of System.double values to a string. Not formatted like a C# array.
public static ArrayToStringRaw ( double x ) : string
x double Array of values to be converted to string.
Результат string

ArrayToStringRaw() публичный статический Метод

Convert an array of System.double values to a string. Not formattet like a C# array.
public static ArrayToStringRaw ( double x, int digits ) : string
x double Array of values to be converted to string.
digits int Number of digits for each value.
Результат string

BetterFeasible() публичный статический Метод

Return whether feasibility (constraint satisfaction) of new candidate solution is same as or better than feasibility of old candidate solution.
public static BetterFeasible ( bool oldFeasible, bool newFeasible ) : bool
oldFeasible bool Feasibility of old candidate solution.
newFeasible bool Feasibility of new candidate solution.
Результат bool

BetterFeasibleFitness() публичный статический Метод

Return whether the new candidate solution is better than the old, depending on their feasibility (constraint satisfaction) and fitness.
public static BetterFeasibleFitness ( bool oldFeasible, bool newFeasible, double oldFitness, double newFitness ) : bool
oldFeasible bool Feasibility of old candidate solution.
newFeasible bool Feasibility of new candidate solution.
oldFitness double Fitness of old candidate solution.
newFitness double Fitness of new candidate solution.
Результат bool

BetweenBounds() публичный статический Метод

Return whether array of values is between lower and upper boundaries.
public static BetweenBounds ( double x, double lower, double upper ) : bool
x double Array of values to be bounded.
lower double Lower boundaries.
upper double Upper boundaries.
Результат bool

Bound() публичный статический Метод

Bound a value between lower and upper boundaries.
public static Bound ( double x, double lower, double upper ) : double
x double Parameter to be bounded.
lower double Lower boundary.
upper double Upper boundary.
Результат double

Bound() публичный статический Метод

Bound array of values between lower and upper boundaries.
public static Bound ( double &x, double lower, double upper ) : void
x double Array of values to be bounded.
lower double Lower boundaries.
upper double Upper boundaries.
Результат void

Denormalize() публичный статический Метод

Return denormalized version of x. This is useful for avoiding expensive CPU usage when x underflows.
public static Denormalize ( double x ) : double
x double
Результат double

Denormalize() публичный статический Метод

Denormalize an array.
public static Denormalize ( double &x ) : void
x double
Результат void

DenormalizeTruncate() публичный статический Метод

If Abs(x) is below a limit then it is set to zero.
public static DenormalizeTruncate ( double x ) : double
x double
Результат double

FormatNumber() публичный статический Метод

Convert numeric value d to a string with convenient formatting.
public static FormatNumber ( double d ) : string
d double
Результат string

FormatPercent() публичный статический Метод

Convert numeric value d to a percentage string, e.g. d==0.253212 returns string "25.32%"
public static FormatPercent ( double d ) : string
d double
Результат string

Initialize() публичный статический Метод

Initialize array with value.
public static Initialize ( double &x, double value ) : void
x double Array to be initialized.
value double Value.
Результат void

InitializeRange() публичный статический Метод

Initialize array with the range between the boundaries. That is, x[i] = upper[i]-lower[i].
public static InitializeRange ( double &x, double lower, double upper ) : void
x double Array to be initialized.
lower double Lower boundary.
upper double Upper boundary.
Результат void

InitializeUniform() публичный статический Метод

Initialize array with uniform random values between given boundaries.
public static InitializeUniform ( double &x, double lower, double upper ) : void
x double Array to be initialized.
lower double Lower boundary.
upper double Upper boundary.
Результат void

NewMatrix() публичный статический Метод

Allocate and return a new matrix double[dim1][dim2].
public static NewMatrix ( int dim1, int dim2 ) : double[][]
dim1 int
dim2 int
Результат double[][]

Norm() публичный статический Метод

Euclidian norm (or length) of a numeric vector.
public static Norm ( double x ) : double
x double
Результат double

NumberToString() публичный статический Метод

Convert a double-value to a string, formatted for array output.
public static NumberToString ( double x, int digits ) : string
x double Value to convert.
digits int Number of digits.
Результат string

PrintNewline() публичный статический Метод

Print a newline to Console.
public static PrintNewline ( ) : void
Результат void

PrintParameters() публичный статический Метод

Print parameters using names associated with an optimization problem.
public static PrintParameters ( Problem problem, double parameters ) : void
problem Problem Optimization problem with associated parameter-names.
parameters double Parameters to be printed.
Результат void

PrintSolution() публичный статический Метод

Print parameters, fitness and feasibility to Console, and print a marking if fitness was an improvement to fitnessLimit.
public static PrintSolution ( double parameters, double fitness, double fitnessLimit, bool oldFeasible, bool newFeasible, bool formatAsArray ) : void
parameters double
fitness double
fitnessLimit double
oldFeasible bool
newFeasible bool
formatAsArray bool
Результат void

Sample() публичный статический Метод

Pick a uniform random sample from [x-range, x+range].
public static Sample ( double x, double range ) : double
x double
range double
Результат double

SampleBounded() публичный статический Метод

First bound the sampling range [x-range, x+range] using lowerBound and upperBound respectively, and then pick a uniform random sample from the bounded range. This avoids samples being boundary points.
public static SampleBounded ( double x, double range, double lowerBound, double upperBound ) : double
x double
range double
lowerBound double
upperBound double
Результат double