public double[] Find(double phi, double theta, double radius) { double[] x = new double[3]; x[0] = phi; x[1] = theta; x[2] = radius; DotNumerics.Optimization.Simplex simplex = new DotNumerics.Optimization.Simplex(); x = simplex.ComputeMin(this.Khi2, x); this.lcComp = new double[2][]; lcComp[0] = new double[100]; lcComp[1] = new double[100]; for (int p = 0; p < 100; p++) { lcComp[0][p] = p * 0.01; } this.lcm.StarM.circSpots[0] = new UniformCircSpot(x[1], x[0], x[2], 4000, 30, 30 * 3); this.lcComp[1] = this.lcm.GetLightCurve(this.lcComp[0], 0.725, 0.725, 1e-5); return(x); }
void RunOpt() { var indvars = mycase.variables.Values.Where(x => x.type == DWSIM.SharedClasses.Flowsheet.Optimization.OPTVariableType.Independent).ToList(); List <DotNumerics.Optimization.OptVariable> unboundvars = new List <DotNumerics.Optimization.OptVariable>(); List <DotNumerics.Optimization.OptBoundVariable> boundvars = new List <DotNumerics.Optimization.OptBoundVariable>(); foreach (var item in indvars) { unboundvars.Add(new DotNumerics.Optimization.OptVariable(item.initialvalue)); boundvars.Add(new DotNumerics.Optimization.OptBoundVariable(item.initialvalue, item.lowerlimit.GetValueOrDefault(), item.upperlimit.GetValueOrDefault())); } switch (mycase.solvm) { case OptimizationCase.SolvingMethod.DN_NELDERMEAD_SIMPLEX: case OptimizationCase.SolvingMethod.AL_BRENT: case OptimizationCase.SolvingMethod.IPOPT: var solver = new DotNumerics.Optimization.Simplex(); solver.Tolerance = mycase.tolerance; solver.MaxFunEvaluations = mycase.maxits; solver.ComputeMin(FunctionValue, unboundvars.ToArray()); break; case OptimizationCase.SolvingMethod.DN_LBFGS: case OptimizationCase.SolvingMethod.AL_LBFGS: var solver2 = new DotNumerics.Optimization.L_BFGS_B(); solver2.Tolerance = mycase.tolerance; solver2.MaxFunEvaluations = mycase.maxits; solver2.ComputeMin(FunctionValue, FunctionGradient, unboundvars.ToArray()); break; case OptimizationCase.SolvingMethod.DN_TRUNCATED_NEWTON: var solver3 = new DotNumerics.Optimization.TruncatedNewton(); solver3.Tolerance = mycase.tolerance; solver3.MaxFunEvaluations = mycase.maxits; solver3.ComputeMin(FunctionValue, FunctionGradient, unboundvars.ToArray()); break; case OptimizationCase.SolvingMethod.DN_NELDERMEAD_SIMPLEX_B: case OptimizationCase.SolvingMethod.AL_BRENT_B: var solver4 = new DotNumerics.Optimization.Simplex(); solver4.Tolerance = mycase.tolerance; solver4.MaxFunEvaluations = mycase.maxits; solver4.ComputeMin(FunctionValue, boundvars.ToArray()); break; case OptimizationCase.SolvingMethod.DN_LBFGS_B: case OptimizationCase.SolvingMethod.AL_LBFGS_B: var solver5 = new DotNumerics.Optimization.L_BFGS_B(); solver5.Tolerance = mycase.tolerance; solver5.MaxFunEvaluations = mycase.maxits; solver5.ComputeMin(FunctionValue, FunctionGradient, boundvars.ToArray()); break; case OptimizationCase.SolvingMethod.DN_TRUNCATED_NEWTON_B: var solver6 = new DotNumerics.Optimization.TruncatedNewton(); solver6.Tolerance = mycase.tolerance; solver6.MaxFunEvaluations = mycase.maxits; solver6.ComputeMin(FunctionValue, FunctionGradient, unboundvars.ToArray()); break; } }