commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <gil...@harfang.homelinux.org>
Subject Re: Commons Math - Problem with deprecated OptimizationException using NelderMead.optimize
Date Mon, 08 Aug 2011 17:15:22 GMT
On Mon, Aug 08, 2011 at 04:44:15PM +0100, Babak wrote:
> 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.

Are you sure that your classpath is the same for compilation and execution?

> 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);
> 	}

It would help if you could provide a minimal but functional example, one
with which we can try to reproduce the problem.


Thanks,
Gilles

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


Mime
View raw message