commons-user mailing list archives

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

Thank you for your reply. I added commons-math-2.2.jar (and even
commons-math-2.2-sources.jar) to the Java Build Path of the project in
Eclipse in the Libraries tab of the project (like I did for another
external jar that I use without occurring any problem). The fact that
the compilation is done properly and that there is no exception thrown
for previous classes or method calls (e.g. NelderMead, or even
FunctionEvaluationExcpetion and IllegalArgumentException) forced me to
believe that the problem is with deprecated OptimizationException. In
fact, in the example code, I changed the order of the catches so that
OptimizationException is not the last one to be thrown. However, the
run time exception error remains the same, that is,

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

Many thanks,
Babak


On Mon, Aug 8, 2011 at 6:15 PM, Gilles Sadowski
<gilles@harfang.homelinux.org> wrote:
> 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
>
>

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


Mime
View raw message