///<summary> ///Transfert the value of vector X to fitness parameters in order to compute fitness and change it from a value between 0 and 1 ///</summary> ///<param name="X">Parameters for fitness compute</param> private bool XtoParamValue(Vector <double> X) { int i = 0; foreach (string subModel in OptProblem.fitnessFunctions.ParamValueDictio.Keys.ToList()) { foreach (string parameterName in OptProblem.fitnessFunctions.ParamValueDictio[subModel].Keys.ToList()) { //avoid going outside of the parameters boundaries which could cause the simulation to crash if (X[i] < 0) { X[i] = 0; } if (X[i] > 1) { X[i] = 1; } OptiParameter completeParam = OptProblem.Opt_Parameters.Find(ii => ii.Name == parameterName); OptProblem.fitnessFunctions.ParamValueDictio[subModel][parameterName] = completeParam.Min + X[i] * (completeParam.Max - completeParam.Min); i++; } } return(true); }
///<summary> ///Transfert the value of a component to fitness parameters in order to compute fitness ///</summary> private static void ComponenttoParamValue(double[] component) { int i = 0; foreach (string subModel in OptProblem.fitnessFunctions.ParamValueDictio.Keys.ToList()) { foreach (string parameterName in OptProblem.fitnessFunctions.ParamValueDictio[subModel].Keys.ToList()) { OptiParameter completeParam = OptProblem.Opt_Parameters.Find(ii => ii.Name == parameterName); OptProblem.fitnessFunctions.ParamValueDictio[subModel][parameterName] = component[i]; i++; } } }
public NelderMeadSimplex(OptimizationProblem optimizationProblem) { NelderMeadSimplex.OptProblem = optimizationProblem; constants = new SimplexConstant[OptProblem.fitnessFunctions.paramValueDictioSize]; int count = 0; foreach (string subModel in OptProblem.fitnessFunctions.ParamValueDictio.Keys.ToList()) { foreach (string parameterName in OptProblem.fitnessFunctions.ParamValueDictio[subModel].Keys.ToList()) { OptiParameter completeParam = OptProblem.Opt_Parameters.Find(ii => ii.Name == parameterName); constants[count] = new SimplexConstant((completeParam.Max + completeParam.Min) / 2, (completeParam.Max - completeParam.Min) / 2 / 10); count++; } } }