|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
namespace SwarmOps
|
|
|
{
|
|
|
public static partial class Tools
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void PrintParameters(Problem problem, double[] parameters)
|
|
|
{
|
|
|
int NumParameters = problem.Dimensionality;
|
|
|
|
|
|
if (NumParameters > 0)
|
|
|
{
|
|
|
Debug.Assert(parameters.Length == NumParameters);
|
|
|
|
|
|
for (int i = 0; i < NumParameters; i++)
|
|
|
{
|
|
|
string parameterName = problem.ParameterName[i];
|
|
|
double p = parameters[i];
|
|
|
string pStr = p.ToString("0.####", _cultureInfo);
|
|
|
|
|
|
Console.WriteLine("\t{0} = {1}", parameterName, pStr);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Console.WriteLine("\tN/A");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void PrintSolution(double[] parameters, double fitness, double fitnessLimit, bool oldFeasible, bool newFeasible, bool formatAsArray)
|
|
|
{
|
|
|
|
|
|
string parametersStr = (formatAsArray) ? (Tools.ArrayToString(parameters)) : (Tools.ArrayToStringRaw(parameters));
|
|
|
|
|
|
Console.WriteLine("{0} \t{1} \t{2} {3}",
|
|
|
parametersStr,
|
|
|
Tools.FormatNumber(fitness),
|
|
|
(newFeasible) ? (1) : (0),
|
|
|
Tools.BetterFeasibleFitness(oldFeasible, newFeasible, fitnessLimit, fitness) ? ("***") : (""));
|
|
|
|
|
|
|
|
|
|
|
|
Console.Out.Flush();
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void PrintNewline()
|
|
|
{
|
|
|
Console.WriteLine();
|
|
|
Console.Out.Flush();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|