List of usage examples for org.apache.commons.math3.exception ZeroException ZeroException
public ZeroException()
From source file:com.wwidesigner.gui.StudyModel.java
/** * Optimize the currently-selected objective function * /*from ww w . ja v a 2 s. c o m*/ * @return XML string defining the optimized instrument, if optimization * succeeds, or {@code null} if optimization fails. */ public String optimizeInstrument() throws Exception { if (!validHoleCount()) { return null; } objective = getObjectiveFunction(BaseObjectiveFunction.OPTIMIZATION_INTENT); // Check to see whether there are 0 variables: an infinite loop // situation. if (objective.getNrDimensions() < 1) { throw new ZeroException(); } BaseObjectiveFunction.OptimizerType optimizerType = objective.getOptimizerType(); if (preferredOptimizerType != null && !optimizerType.equals(BaseObjectiveFunction.OptimizerType.BrentOptimizer)) { optimizerType = preferredOptimizerType; } if (!objective.isOptimizerMatch(optimizerType)) { throw new OptimizerMismatchException("Cannot run multi-start optimization with " + optimizerType); } initialNorm = 1.0; finalNorm = 1.0; if (ObjectiveFunctionOptimizer.optimizeObjectiveFunction(objective, optimizerType)) { Instrument instrument = objective.getInstrument(); // Convert back to the input unit-of-measure values instrument.convertToLengthType(); String xmlString = marshal(instrument); initialNorm = ObjectiveFunctionOptimizer.getInitialNorm(); finalNorm = ObjectiveFunctionOptimizer.getFinalNorm(); objective = null; return xmlString; } objective = null; return null; }