Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9E488709E for ; Tue, 9 Aug 2011 11:23:31 +0000 (UTC) Received: (qmail 31325 invoked by uid 500); 9 Aug 2011 11:23:29 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 30789 invoked by uid 500); 9 Aug 2011 11:23:22 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 30778 invoked by uid 99); 9 Aug 2011 11:23:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Aug 2011 11:23:15 +0000 X-ASF-Spam-Status: No, hits=-0.6 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of babak07@gmail.com designates 209.85.210.169 as permitted sender) Received: from [209.85.210.169] (HELO mail-iy0-f169.google.com) (209.85.210.169) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Aug 2011 11:23:09 +0000 Received: by iym1 with SMTP id 1so129097iym.0 for ; Tue, 09 Aug 2011 04:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=rxxlGieFumM63edIYHr8AzfMWl/YDT6tsE2wB7Def4k=; b=BTsziPoLN28ouxJ9xNICuTSwv+by0XGNEvF1R9fu+5EY/YBF51+bgfPskl9lnaX8xH tRO7P+H5iqDqb+CaZ7XhQWSl6FLz2hVzDWo9tTCxSoWHtDBiCSEO9fxjtYwYCv0ua1fq 1GaMUKidtGSIluMcr+xCoIZVWFXkU2MFsOs+U= MIME-Version: 1.0 Received: by 10.42.74.202 with SMTP id x10mr3940566icj.142.1312888968960; Tue, 09 Aug 2011 04:22:48 -0700 (PDT) Received: by 10.231.34.130 with HTTP; Tue, 9 Aug 2011 04:22:48 -0700 (PDT) In-Reply-To: References: <20110808171522.GP18819@dusk.harfang.homelinux.org> Date: Tue, 9 Aug 2011 12:22:48 +0100 Message-ID: Subject: Re: Commons Math - Problem with deprecated OptimizationException using NelderMead.optimize From: Babak To: Commons Users List Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable My sincere apologies to you Gilles and other members of this forum. Indeed, there was a problem with the =91runtime=92 classpath. Apparently, in addition to adding the jar in the Java Build Path pane, Libraries tab (invoked in the project properties in the Eclipse) [=91compile time path=92], one also has to add the jar in the Classpath tab of =91Run Configuration=92, which I forgot to it! Sorry about this unnecessary disturbance. 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) commons-math-2.2! 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. Regards, Babak 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 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 executi= on? >> >>> Thank you, >>> >>> Babak >>> ---------------------------------- >>> My code is simple and pretty straightforward as in the following: >>> >>> =A0 =A0 =A0 =A0 NelderMead apacheNelderMead =3D new NelderMead(); >>> >>> =A0 =A0 =A0 =A0 MyMultivariateRealFunction minFunct =3D new MyMultivari= ateRealFunction(); >>> >>> =A0 =A0 =A0 =A0 =A0double[] start =3D new double[48]; >>> =A0 =A0 =A0 =A0 Arrays.fill(start, 0.1); >>> >>> =A0 =A0 =A0 =A0 try { >>> =A0 =A0 =A0 =A0minValue =3D apacheNelderMead.optimize(minFunct, GoalTyp= e.MINIMIZE, =A0start); >>> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0} >>> =A0 =A0 =A0 catch ( FunctionEvaluationException e) { >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 System.out.println(e); >>> =A0 =A0 =A0 } >>> =A0 =A0 =A0 catch (IllegalArgumentException e) { >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 System.out.println(e); >>> =A0 =A0 =A0 } >>> =A0 =A0 =A0 catch (OptimizationException e) { >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 System.out.println(e); >>> =A0 =A0 =A0 } >> >> 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