C# Class SwarmOps.Tools

Afficher le fichier Open project: DanWBR/dwsim3

Méthodes publiques

Méthode Description
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.

Method Details

ArrayToString() public static méthode

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.
Résultat string

ArrayToString() public static méthode

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.
Résultat string

ArrayToStringRaw() public static méthode

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.
Résultat string

ArrayToStringRaw() public static méthode

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.
Résultat string

BetterFeasible() public static méthode

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.
Résultat bool

BetterFeasibleFitness() public static méthode

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.
Résultat bool

BetweenBounds() public static méthode

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.
Résultat bool

Bound() public static méthode

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.
Résultat double

Bound() public static méthode

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.
Résultat void

Denormalize() public static méthode

Return denormalized version of x. This is useful for avoiding expensive CPU usage when x underflows.
public static Denormalize ( double x ) : double
x double
Résultat double

Denormalize() public static méthode

Denormalize an array.
public static Denormalize ( double &x ) : void
x double
Résultat void

DenormalizeTruncate() public static méthode

If Abs(x) is below a limit then it is set to zero.
public static DenormalizeTruncate ( double x ) : double
x double
Résultat double

FormatNumber() public static méthode

Convert numeric value d to a string with convenient formatting.
public static FormatNumber ( double d ) : string
d double
Résultat string

FormatPercent() public static méthode

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
Résultat string

Initialize() public static méthode

Initialize array with value.
public static Initialize ( double &x, double value ) : void
x double Array to be initialized.
value double Value.
Résultat void

InitializeRange() public static méthode

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.
Résultat void

InitializeUniform() public static méthode

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.
Résultat void

NewMatrix() public static méthode

Allocate and return a new matrix double[dim1][dim2].
public static NewMatrix ( int dim1, int dim2 ) : double[][]
dim1 int
dim2 int
Résultat double[][]

Norm() public static méthode

Euclidian norm (or length) of a numeric vector.
public static Norm ( double x ) : double
x double
Résultat double

NumberToString() public static méthode

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.
Résultat string

PrintNewline() public static méthode

Print a newline to Console.
public static PrintNewline ( ) : void
Résultat void

PrintParameters() public static méthode

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.
Résultat void

PrintSolution() public static méthode

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
Résultat void

Sample() public static méthode

Pick a uniform random sample from [x-range, x+range].
public static Sample ( double x, double range ) : double
x double
range double
Résultat double

SampleBounded() public static méthode

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
Résultat double