public IHyperCube <double> GenerateRandomWithinHypercube(IHyperCube <double>[] points)
        {
            if (points.Length == 0)
            {
                return(this.GenerateRandom(points[0]));
            }
            else
            {
                IHyperCube <double> p        = points[0].Clone() as IHyperCube <double>;
                string[]            varNames = p.GetVariableNames();
                for (int i = 0; i < varNames.Length; i++)
                {
                    string v = varNames[i];
                    double minimum;
                    double maximum;
                    GetSmallestIntervalForValues(points, v, out minimum, out maximum);
                    minimum = Math.Max(minimum, p.GetMinValue(v));
                    maximum = Math.Min(maximum, p.GetMaxValue(v));
                    checkFeasibleInterval(minimum, maximum, v);
                    p.SetValue(varNames[i], GetRandomisedValue(minimum, maximum));
                }

                return(p);
            }
        }
        public IHyperCube <double> GetCentroid(IHyperCube <double>[] points)
        {
            if (points == null)
            {
                return(null);
            }
            if (points.Length == 1)
            {
                return(points[0].Clone( ) as IHyperCube <double>);
            }

            IHyperCube <double> p = points[0].Clone( ) as IHyperCube <double>;

            string[] varNames = p.GetVariableNames();
            foreach (string varName in varNames)
            {
                double val = 0.0;
                for (int i = 0; i < points.Length; i++)
                {
                    val += points[i].GetValue(varName);
                }
                p.SetValue(varName, val / ((double)points.Length));
            }
            return(p);
        }
            private void apply(IHyperCube <double> systemConfiguration, IModelSimulation <double[], double, int> simulation)
            {
                var varNames = systemConfiguration.GetVariableNames();

                foreach (var varName in varNames)
                {
                    simulation.SetVariable(varName, systemConfiguration.GetValue(varName));
                }
            }
        public static double CalculateParaboloid(IHyperCube <double> sysConfig, double bestParam)
        {
            var    names  = sysConfig.GetVariableNames();
            double result = 0;

            for (int i = 0; i < names.Length; i++)
            {
                var    name = names[i];
                double v    = (sysConfig.GetValue(name) - bestParam);
                result += v * v;
            }
            return(result);
        }
 public static bool CheckInBounds <T>(IHyperCube <T> point) where T : IComparable
 {
     foreach (var varName in point.GetVariableNames())
     {
         var min = point.GetMinValue(varName);
         var max = point.GetMaxValue(varName);
         var val = point.GetValue(varName);
         if (!MetaheuristicsHelper.CheckInBounds(val, min, max, throwIfFalse: false))
         {
             return(false);
         }
     }
     return(true);
 }
 public IHyperCube<double> GenerateRandom( IHyperCube<double> point )
 {
     string[] varNames = point.GetVariableNames( );
     IHyperCube<double> result = point.Clone( ) as IHyperCube<double> ;
     for( int i = 0; i < varNames.Length; i++ )
     {
         string v = varNames[i];
         // We take the bounds of the result point, to cater for cascading parameter constraints.
         double min = result.GetMinValue(v);
         double max = result.GetMaxValue(v);
         checkFeasibleInterval(min, max, v);
         result.SetValue( varNames[i], GetRandomisedValue(min, max) );
     }
     return result;
 }
        public IHyperCube <double> GenerateRandom(IHyperCube <double> point)
        {
            string[]            varNames = point.GetVariableNames( );
            IHyperCube <double> result   = point.Clone( ) as IHyperCube <double>;

            for (int i = 0; i < varNames.Length; i++)
            {
                string v = varNames[i];
                // We take the bounds of the result point, to cater for cascading parameter constraints.
                double min = result.GetMinValue(v);
                double max = result.GetMaxValue(v);
                checkFeasibleInterval(min, max, v);
                result.SetValue(varNames[i], GetRandomisedValue(min, max));
            }
            return(result);
        }
Beispiel #8
0
        public static HyperCubeInterop ToDataFrame(IHyperCube <double> paramSet)
        {
            var names = paramSet.GetVariableNames();
            var r     = new HyperCubeInterop(names.Length);

            for (int i = 0; i < names.Length; i++)
            {
                var name = names[i];
                r.Name[i]        = name;
                r.Description[i] = "";
                r.Value[i]       = paramSet.GetValue(name);
                r.Min[i]         = paramSet.GetMinValue(name);
                r.Max[i]         = paramSet.GetMaxValue(name);
            }
            return(r);
        }
Beispiel #9
0
        /// <summary>
        /// populates the internal array of parameters with the relavant pest values. In the
        /// current version, it considers all parameters to be of the same group (not sure
        /// if this functionality is required for TIME models)
        /// </summary>
        /// <param name="parameters">starting point and range of input parameters </param>
        public void AddParameterSet(IHyperCube <double> parameters)
        {
            List <PESTParameterData> parameterList = new List <PESTParameterData>();

            foreach (String paramName in parameters.GetVariableNames())
            {
                PESTParameterData tmpParameter = new PESTParameterData();
                tmpParameter.Scale             = 1.0;
                tmpParameter.MaxValue          = parameters.GetMaxValue(paramName);
                tmpParameter.MinValue          = parameters.GetMinValue(paramName);
                tmpParameter.InitialValue      = parameters.GetValue(paramName);
                tmpParameter.ParameterName     = paramName;
                tmpParameter.TransformType     = PestConstants.ParameterDataConstants.ParameterTransformationType.noneType;
                tmpParameter.ChangeLimitedType = PestConstants.ParameterDataConstants.ParameterChangeLimitedType.relativeChange;
                tmpParameter.ParameterGroup    = "param";
                parameterList.Add(tmpParameter);
            }
            this.Parameters = parameterList.ToArray();
        }
Beispiel #10
0
        public override string ToString()
        {
            StringBuilder output = new StringBuilder();

            output.Append("\n--------------------------------------------------------------\n");
            for (int i = 0; i < ObjectiveScores.Length; i++)
            {
                for (int k = 0; k < ObjectiveScores[i].ObjectiveCount; k++)
                {
                    output.Append(ObjectiveScores[i].GetObjective(k).GetText() + "\t");
                }

                IHyperCube <double> pSet     = (IHyperCube <double>)ObjectiveScores[i].GetSystemConfiguration();
                string[]            keyNames = pSet.GetVariableNames();
                foreach (string key in keyNames)
                {
                    output.Append("\n" + key + "\t\t" + pSet.GetValue(key));
                }
                output.Append("\n\n");
            }

            return(output.ToString());
        }
Beispiel #11
0
 public static HyperCubeInterop ToDataFrame(IHyperCube<double> paramSet)
 {
     var names = paramSet.GetVariableNames();
     var r = new HyperCubeInterop(names.Length);
     for (int i = 0; i < names.Length; i++)
     {
         var name = names[i];
         r.Name[i] = name;
         r.Description[i] = "";
         r.Value[i] = paramSet.GetValue(name);
         r.Min[i] = paramSet.GetMinValue(name);
         r.Max[i] = paramSet.GetMaxValue(name);
     }
     return r;
 }