commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Babak <baba...@gmail.com>
Subject Commons Math - Problem with deprecated OptimizationException using NelderMead.optimize
Date Mon, 08 Aug 2011 15:44:15 GMT
Hi,

I am new to this forum and this is actually the first time that I use
Apache Commons Math.
I would like use NelderMead class (in optimization.direct package) for
minimizing the parameters of the function that I wrote (which
implements MultivariateRealFunction).

As you know, a call to optimize method in NelderMead should be caught
for three different exceptions, namely FunctionEvaluationException,
IllegalArgumentException and OptimizationException.

However the last one (OptimizationException) has been apparently
deprecated in version 2.2 (to be removed in 3.0). I am using the last
version of Appache.Commons.Math which is apparently 2.2. (although I
see a Javadoc CommonsMath 3.0 snapshot on the website which is
confusing, as there is no sourcecode/jar for version 3.0) and since I
am using Eclipse, I can clearly see that OptimizationException is
visibly deprecated. However (as expected) the compiler does not
complain about it and the program compiles and only at run time the
following exception is thrown:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError:
org/apache/commons/math/optimization/OptimizationException

It seems that OptimizationException class cannot be found! Usually,
when a class is deprecated, it is still possible to use it (although
not recommended). Beside, I have no choice but to use it (call to
NelderMead.optimise requires to catch this exception). I greatly
appreciate if you can please provide me with your feedbacks.
Alternatively, I assume having the version 3.0 (if available) can
solve my problem as well.

Thank you,

Babak
----------------------------------
My code is simple and pretty straightforward as in the following:

        NelderMead apacheNelderMead = new NelderMead();

        MyMultivariateRealFunction minFunct = new MyMultivariateRealFunction();

         double[] start = new double[48];
        Arrays.fill(start, 0.1);

        try {
	 minValue = apacheNelderMead.optimize(minFunct, GoalType.MINIMIZE,  start);

             }
	catch ( FunctionEvaluationException e) {
	              System.out.println(e);
	}
	catch (IllegalArgumentException e) {
		System.out.println(e);
	}
	catch (OptimizationException e) {
		System.out.println(e);
	}

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message