Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 47E9DD6E4 for ; Sun, 2 Dec 2012 21:02:05 +0000 (UTC) Received: (qmail 28327 invoked by uid 500); 2 Dec 2012 21:02:04 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 28181 invoked by uid 500); 2 Dec 2012 21:02:04 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 28171 invoked by uid 99); 2 Dec 2012 21:02:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Dec 2012 21:02:04 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [193.74.71.26] (HELO hel.is.scarlet.be) (193.74.71.26) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Dec 2012 21:01:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scarlet.be; s=scarlet; t=1354482095; bh=DqEsWy3IrwkHJYMItrlyVjjBK+WlIUn67l6bF0Gz10M=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=1/YOZnrwh6zOrcm0JHAu3tsI/BmYkYdaQsx79yeR1nTzMJK5ejX8qCD9i1nvfTDcu iwUoAv6UUXVDjMgahyULRTekDEnXfRwPMdcwTuo2dO/pIrO5E0nL9cT8Ib90VQFchw pMl2YKmkCP/TumkdrxaZyVXj0R7Y3bWrs6yGMo0o= Received: from mail.harfang.homelinux.org (ip-83-134-189-151.dsl.scarlet.be [83.134.189.151]) by hel.is.scarlet.be (8.14.5/8.14.5) with ESMTP id qB2L1Y8Q007423 for ; Sun, 2 Dec 2012 22:01:35 +0100 X-Scarlet: d=1354482095 c=83.134.189.151 Received: from localhost (mail.harfang.homelinux.org [192.168.20.11]) by mail.harfang.homelinux.org (Postfix) with ESMTP id C26A2617A5 for ; Sun, 2 Dec 2012 22:01:34 +0100 (CET) Received: from mail.harfang.homelinux.org ([192.168.20.11]) by localhost (mail.harfang.homelinux.org [192.168.20.11]) (amavisd-new, port 10024) with ESMTP id UXwKsOq8BDmr for ; Sun, 2 Dec 2012 22:01:30 +0100 (CET) Received: from dusk.harfang.homelinux.org (mail.harfang.homelinux.org [192.168.20.11]) by mail.harfang.homelinux.org (Postfix) with ESMTP id ED9E061CAE for ; Sun, 2 Dec 2012 22:01:26 +0100 (CET) Received: from eran by dusk.harfang.homelinux.org with local (Exim 4.77) (envelope-from ) id 1TfGfG-0007uu-OZ for dev@commons.apache.org; Sun, 02 Dec 2012 22:01:26 +0100 Date: Sun, 2 Dec 2012 22:01:26 +0100 From: Gilles Sadowski To: dev@commons.apache.org Subject: Re: [Math] Old to new API ("MultivariateDifferentiable(Vector)Function") Message-ID: <20121202210126.GP3397@dusk.harfang.homelinux.org> Mail-Followup-To: dev@commons.apache.org References: <50B8F24E.1060104@free.fr> <20121130190625.GB3397@dusk.harfang.homelinux.org> <50B91160.10708@free.fr> <20121130221558.GE3397@dusk.harfang.homelinux.org> <03BD0238-AC52-44C1-A88F-B55FDC3BE4C0@gmail.com> <20121201183148.GG3397@dusk.harfang.homelinux.org> <20121201223615.GL3397@dusk.harfang.homelinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121201223615.GL3397@dusk.harfang.homelinux.org> X-Operating-System: Tiny Tux X-PGP-Key-Fingerprint: 53B9 972E C2E6 B93C BEAD 7092 09E6 AF46 51D0 5641 User-Agent: Mutt/1.5.21 (2010-09-15) X-DCC-scarlet.be-Metrics: hel 20002; Body=1 Fuz1=1 Fuz2=1 X-Virus-Scanned: clamav-milter 0.97.1-exp at hel X-Virus-Status: Clean X-Virus-Checked: Checked by ClamAV on apache.org Hello. > > > > I would propose to simply revert my changes on the optimization package > > and prepare for a reorganization for 4.0. I understand I focused only on > > the type of problems Gilles and myself routinely use, i .e. small size problems > > where the cost of the evaluation is several orders of magnitude larger than the > > data copying. I forgot the dual case with very large data sets. I apologize for that. > > In the context of an FLOSS project, I don't think that you should apologize > for that. We all do our best (and sometimes beyond) and the lack of full > problem coverage should certainly not rest on the usual suspects (eh, > contributors, I mean. ;-) > > > > > When 3.1 will be out, we will have to solve this so both cases are handled efficiently, > > and this would probably be implemented in 4.0. > > > > Does this seems reasonable? > > At this point, no! > > I really want to understand what is wrong, and improve the API on all > accounts (the issues you had, the one I raised, and the feedback from > Konstantin, plus advice from others if possible). If I understood correctly, the main API problem is that the objective function and gradient or Jacobian are accessed separately. This forces users who have code to compute the value and Jacobian together to create an adapter that can return the two functions (objective and Jacobian) required by the API but would avoid the computation if the a call to the other was already made with the same parameter values. For example, instead of passing a "DifferentiableMultivariateVectorFunction" to the method "optimize" in "AbstractLeastSquareOptimizer", a type like the following would be required: ----- interface VectorFunctionWithJacobian { ValueAndGradient[] computeValueAndJacobian(double[] parameters); } ----- with ----- public class ValueAndGradient { /** Value of a function at a given point. */ private final double value; /** Gradient of the function at the same point. */ private final double[] gradient; /** * Creates an instance for the given value and gradient. * Note that no copy is performed: this instance will contain references * to the original data. * * @param value Value. * @param gradient Vector. */ public ValueAndGradient(double value, double[] gradient) { this.value = value; this.gradient = gradient; } /** * @eturn a reference to the value. */ public double getValue() { } /** * @eturn a reference to the gradient. */ public double[] getGradient() { return gradient; } } ----- Is that a better approach? IIUC, the "DerivativeStructure" can also be used if just as a storage layout equivalent to "ValueAndGradient". If so, then the new proposed API (where the objective function is a "MultivariateDifferentiableVectorFunction") is indeed better than the old, except for the (perhaps major) caveat that from the "optimization" package, it indeed looks over-engineered and quite unfamiliar. Regards, Gilles --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org