Exemple #1
0
        internal ParameterValues(IEnumerable <Esmf.Parameter> parameters)
        {
            RunId = null;

            foreach (var p in parameters)
            {
                if (p is Esmf.ParameterNonDimensional <double> )
                {
                    var typedP = (Esmf.ParameterNonDimensional <double>)p;

                    var parameterValue = new ParameterValueNonDimensional <double>(p.Name, p.Id, typedP.GetBestGuessValue());

                    Add(parameterValue);
                }
                else if (p is Esmf.ParameterOneDimensional <double> )
                {
                    var typedP = (Esmf.ParameterOneDimensional <double>)p;

                    var parameterValue = new ParameterValue1Dimensional <double>(p.Name, p.Id, typedP.GetBestGuessValues());

                    Add(parameterValue);
                }
                else if (p is Esmf.ParameterOneDimensional <string> )
                {
                    var typedP = (Esmf.ParameterOneDimensional <string>)p;

                    var parameterValue = new ParameterValue1Dimensional <string>(p.Name, p.Id, typedP.GetBestGuessValues());

                    Add(parameterValue);
                }
                else if (p is Esmf.Parameter2Dimensional <double> )
                {
                    var typedP = (Esmf.Parameter2Dimensional <double>)p;

                    var parameterValue = new ParameterValue2Dimensional <double>(p.Name, p.Id, typedP.GetBestGuessValues());

                    Add(parameterValue);
                }
                else if (p is Esmf.ParameterNonDimensional <Timestep> )
                {
                    var typedP = (Esmf.ParameterNonDimensional <Timestep>)p;

                    var parameterValue = new ParameterValueNonDimensional <Timestep>(p.Name, p.Id, typedP.GetBestGuessValue());

                    Add(parameterValue);
                }
                else if (p is Esmf.ParameterNonDimensional <bool> )
                {
                    var typedP = (Esmf.ParameterNonDimensional <bool>)p;

                    var parameterValue = new ParameterValueNonDimensional <bool>(p.Name, p.Id, typedP.GetBestGuessValue());

                    Add(parameterValue);
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }
        }
Exemple #2
0
        internal ParameterValues(IEnumerable <Esmf.Parameter> parameters, Random rand, int?runId = null)
        {
            if (runId.HasValue && runId < 1)
            {
                throw new ArgumentException("runId cannot be <=0");
            }

            RunId = runId;

            foreach (var p in parameters)
            {
                if (p is Esmf.ParameterNonDimensional <double> )
                {
                    var typedP = (Esmf.ParameterNonDimensional <double>)p;

                    var parameterValue = new ParameterValueNonDimensional <double>(p.Name, p.Id, typedP.GetRandomValue(rand));

                    Add(parameterValue);
                }
                else if (p is Esmf.ParameterOneDimensional <double> )
                {
                    var typedP = (Esmf.ParameterOneDimensional <double>)p;

                    var parameterValue = new ParameterValue1Dimensional <double>(p.Name, p.Id, typedP.GetRandomValues(rand));

                    Add(parameterValue);
                }
                else if (p is Esmf.ParameterOneDimensional <string> )
                {
                    var typedP = (Esmf.ParameterOneDimensional <string>)p;

                    var parameterValue = new ParameterValue1Dimensional <string>(p.Name, p.Id, typedP.GetRandomValues(rand));

                    Add(parameterValue);
                }
                else if (p is Esmf.Parameter2Dimensional <double> )
                {
                    var typedP = (Esmf.Parameter2Dimensional <double>)p;

                    var parameterValue = new ParameterValue2Dimensional <double>(p.Name, p.Id, typedP.GetRandomValues(rand));

                    Add(parameterValue);
                }
                else if (p is Esmf.ParameterNonDimensional <Timestep> )
                {
                    var typedP = (Esmf.ParameterNonDimensional <Timestep>)p;

                    var parameterValue = new ParameterValueNonDimensional <Timestep>(p.Name, p.Id, typedP.GetRandomValue(rand));

                    Add(parameterValue);
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }
        }