iterate method
Performs the minimization iteratively
Implementation
List<double> iterate(List<double> params) {
//print("jsfit 4000=${params}");
List<List<double>> fjac = jacobian(params);
//print("jsfit 4001=${fjac}");
double cost = 0.5 * ssr(params);
//print("jsfit 4002=${cost}");
List<double> newParams = lmStep(params, fjac);
//print("jsfit 4003=${newParams}");
//fix the params that are fixed or limited
newParams = fixParameters(newParams);
//print("jsfit 4004=${newParams}");
double newCost = 0.5 * ssr(newParams);
//print("jsfit 4005=${newCost}");
// console.log(cost, newCost, params, newParams)
if (newCost < cost) {
lambda *= lambdaMinus;
}
// console.log(lambda, cost, newCost, params, newParams);
//this is the inner loop, where we keep increasing the damping parameter if
//the cost is greater
while (newCost > cost) {
lambda *= lambdaPlus;
newParams = lmStep(params, fjac);
newCost = 0.5 * ssr(newParams);
}
return newParams;
}