/** {@inheritDoc} */ public boolean converged(final int iteration, final RealPointValuePair previous, final RealPointValuePair current) { final double[] p = previous.getPoint(); final double[] c = current.getPoint(); for (int i = 0; i < p.length; ++i) { final double difference = Math.abs(p[i] - c[i]); final double size = Math.max(Math.abs(p[i]), Math.abs(c[i])); if ((difference > (size * relativeThreshold)) && (difference > absoluteThreshold)) { return false; } } return true; }
final double[] x = simplex[i].getPoint(); for (int j = 0; j < n; ++j) { x[j] = xSmallest[j] + sigma * (x[j] - xSmallest[j]);
/** {@inheritDoc} */ public boolean converged(final int iteration, final RealPointValuePair previous, final RealPointValuePair current) { final double[] p = previous.getPoint(); final double[] c = current.getPoint(); for (int i = 0; i < p.length; ++i) { final double difference = FastMath.abs(p[i] - c[i]); final double size = FastMath.max(FastMath.abs(p[i]), FastMath.abs(c[i])); if ((difference > (size * relativeThreshold)) && (difference > absoluteThreshold)) { return false; } } return true; }
final double[] x = simplex[i].getPoint(); for (int j = 0; j < n; ++j) { x[j] = xSmallest[j] + sigma * (x[j] - xSmallest[j]);
nelderMead.setConvergenceChecker(new SimpleRealPointChecker(0.0001, -1)); ret = nelderMead.optimize(func, GoalType.MINIMIZE, t); return ret.getPoint()[0]; } catch (Exception e) { e.printStackTrace();
nelderMead.setConvergenceChecker(new SimpleRealPointChecker(0.0001, -1)); ret = nelderMead.optimize(func, GoalType.MINIMIZE, t); return ret.getPoint()[0]; } catch (Exception e) { e.printStackTrace();
result.put(v, new FloatConstant(r.getPoint()[origVars2Idx.get(v)])); return result; }catch(OptimizationException e){
public IValue llOptimize(IBool minimize, IBool nonNegative, ISet constraints, IConstructor f) { SimplexSolver solver = new SimplexSolver(); ArrayList<LinearConstraint> constraintsJ = new ArrayList<LinearConstraint>(constraints.size()); for(IValue v : constraints ){ constraintsJ.add(convertConstraint((IConstructor)v)); } LinearObjectiveFunction fJ = convertLinObjFun(f); GoalType goal = minimize.getValue() ? GoalType.MINIMIZE : GoalType.MAXIMIZE; IValueFactory vf = values; boolean nonNegativeJ = nonNegative.getValue(); try { RealPointValuePair res = solver.optimize(fJ, constraintsJ, goal,nonNegativeJ); return vf.constructor(Maybe_just, vf.constructor( LLSolution_llSolution, convertToRealList(res.getPoint(), vf), vf.real(res.getValue()) ) ); } catch (Exception e) { return vf.constructor(Maybe_nothing); } } }