001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 package org.apache.commons.math; 019 020 import org.apache.commons.math.ConvergenceException; 021 022 /** 023 * Error thrown when a numerical computation exceeds its allowed 024 * number of functions evaluations. 025 * 026 * @version $Revision: 779273 $ $Date: 2009-05-27 14:54:48 -0400 (Wed, 27 May 2009) $ 027 * @since 2.0 028 */ 029 public class MaxEvaluationsExceededException extends ConvergenceException { 030 031 /** Serializable version identifier. */ 032 private static final long serialVersionUID = -5921271447220129118L; 033 034 /** Maximal number of evaluations allowed. */ 035 private final int maxEvaluations; 036 037 /** 038 * Constructs an exception with specified formatted detail message. 039 * Message formatting is delegated to {@link java.text.MessageFormat}. 040 * @param maxEvaluations maximal number of evaluations allowed 041 */ 042 public MaxEvaluationsExceededException(final int maxEvaluations) { 043 super("Maximal number of evaluations ({0}) exceeded", maxEvaluations); 044 this.maxEvaluations = maxEvaluations; 045 } 046 047 /** 048 * Constructs an exception with specified formatted detail message. 049 * Message formatting is delegated to {@link java.text.MessageFormat}. 050 * @param maxEvaluations the exceeded maximal number of evaluations 051 * @param pattern format specifier 052 * @param arguments format arguments 053 */ 054 public MaxEvaluationsExceededException(final int maxEvaluations, 055 final String pattern, final Object ... arguments) { 056 super(pattern, arguments); 057 this.maxEvaluations = maxEvaluations; 058 } 059 060 /** Get the maximal number of evaluations allowed. 061 * @return maximal number of evaluations allowed 062 */ 063 public int getMaxEvaluations() { 064 return maxEvaluations; 065 } 066 067 }