commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Babak <>
Subject Re: Commons Math - Problem with deprecated OptimizationException using NelderMead.optimize
Date Tue, 09 Aug 2011 11:22:48 GMT
My sincere apologies to you Gilles and other members of this forum.
Indeed, there was a problem with the ‘runtime’ classpath. Apparently,
in addition to adding the jar in the Java Build Path pane, Libraries
tab (invoked in the project properties in the Eclipse) [‘compile time
path’], one also has to add the jar in the Classpath tab of ‘Run
Configuration’, which I forgot to it! Sorry about this unnecessary
Although this resolves my initial problem, I still have a more serious
problem, but I am afraid it is out of the interest and scope of this
forum. The problem is that I am using NelderMead (example below) in
the Repast Simphony Elipse environment. The commons-math-1.1 is
already integrated and is a part of Repast Simphony Development
Libraries. So, it does not like the fact that I want to use (import)
NelderMead unfortunalty does not seem to be included in the
commons-math-1.1 and trying to fool Reapst by replacing
commons-math-2.2 with commons-math-1.1 (after changing its name to
commons-math-1.1) did not helped!

I am not expecting to have an answer about this specific case problem
here, although I will surely appreciate if someone has an idea.

In any case, sorry and thank you again.


On Tue, Aug 9, 2011 at 9:43 AM, Babak <> wrote:
> 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
> <> 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 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,
>>>              }
>>>       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:
>> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message