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 54C5317BE8 for ; Mon, 21 Sep 2015 21:15:32 +0000 (UTC) Received: (qmail 51745 invoked by uid 500); 21 Sep 2015 21:15:32 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 51616 invoked by uid 500); 21 Sep 2015 21:15:31 -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 51604 invoked by uid 99); 21 Sep 2015 21:15:31 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Sep 2015 21:15:31 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 08A5F1A5204 for ; Mon, 21 Sep 2015 21:15:31 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.001 X-Spam-Level: X-Spam-Status: No, score=0.001 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=scarlet.be Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id jz_7p070s0WT for ; Mon, 21 Sep 2015 21:15:21 +0000 (UTC) Received: from eir.is.scarlet.be (eir.is.scarlet.be [193.74.71.27]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 9D42F42B42 for ; Mon, 21 Sep 2015 21:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scarlet.be; s=scarlet; t=1442870112; bh=eus74X7YVubhjBwlIoWz7a2kMJkDgaiiFjnHZllP558=; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:To: Subject:In-Reply-To:References:Message-ID; b=fGSCMiQ3+JUW7ascuVsECzTg2717YYB6I7C5LWcPxENfYmBW46fR8OtuWSOHGPKHc uqqDqexoXpIzKh3r7TXgollmIi8whSiK1Mh45V2EcFs5ds5Xt8/osf3sZVYw2Zs7yh eum3HJ78A25M4hOqO6ZFIe0NrM31q1b/8Zqg5wx8= Received: from webmail.scarlet.be (meigs.is.scarlet.be [193.74.71.216]) by eir.is.scarlet.be (8.14.9/8.14.9) with ESMTP id t8LLFBu8023804 for ; Mon, 21 Sep 2015 23:15:12 +0200 X-Scarlet: d=1442870112 c=193.74.71.216 Received: from ip-83-134-188-97.dsl.scarlet.be ([83.134.188.97]) via ip-83-134-188-97.dsl.scarlet.be ([83.134.188.97]) by webmail.scarlet.be with HTTP (HTTP/1.1 POST); Mon, 21 Sep 2015 23:15:11 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 21 Sep 2015 23:15:11 +0200 From: Gilles To: Subject: Re: [Math] LeastSquaresOptimizer Design In-Reply-To: <55FF1138.1010003@gmail.com> References: <55FE4E61.3020203@gmail.com> <0fb697bf08561e0b0d1cdf9a74cb36e4@scarlet.be> <55FF1138.1010003@gmail.com> Message-ID: <211c61392f6933ede2ae596b03f53db6@scarlet.be> X-Sender: gilles@harfang.homelinux.org User-Agent: Scarlet Webmail X-DCC-scarlet.be-Metrics: eir; whitelist X-Virus-Scanned: clamav-milter 0.98.1-exp at eir X-Virus-Status: Clean Hi. On Sun, 20 Sep 2015 15:04:08 -0500, Ole Ersoy wrote: > On 09/20/2015 05:51 AM, Gilles wrote: >> On Sun, 20 Sep 2015 01:12:49 -0500, Ole Ersoy wrote: >>> Wanted to float some ideas for the LeastSquaresOptimizer (Possibly >>> General Optimizer) design. For example with the >>> LevenbergMarquardtOptimizer we would do: >>> `LevenbergMarquardtOptimizer.optimize(OptimizationContext c);` >>> >>> Rough optimize() outline: >>> public static void optimise() { >>> //perform the optimization >>> //If successful >>> c.notify(LevenberMarquardtResultsEnum.SUCCESS, solution); >>> //If not successful >>> >>> >>> c.notify(LevenberMarquardtResultsEnum.TOO_SMALL_COST_RELATIVE_TOLERANCE, >>> diagnostic); >>> //or >>> >>> >>> c.notify(LevenberMarquardtResultsEnum.TOO_SMALL_PARAMETERS_RELATIVE_TOLERANCE, >>> diagnostic) >>> //etc >>> } >>> >>> The diagnostic, when turned on, will contain a trace of the last N >>> iterations leading up to the failure. When turned off, the >>> Diagnostic >>> instance only contains the parameters used to detect failure. The >>> diagnostic could be viewed as an indirect way to log optimizer >>> iterations. >>> >>> WDYT? >> >> I'm wary of having several different ways to convey information to >> the >> caller. > It would just be one way. One way for optimizer, one way for solvers, one way for ... > But the caller may not be the receiver > (It could be). The receiver would be an observer attached to the > OptimizationContext that implements an interface allowing it to > observe > the optimization. I'm afraid that it will add to the questions of what to put in the code and how. [We already had sometimes heated discussions just for the IMHO obvious (e.g. code formatting, documentation, exception...).] >> It seems that the reporting interfaces could quickly overwhelm >> the "actual" code (one type of context per algorithm). > There would one type of Observer interface per algorithm. It would > act on the solution and what are currently exceptions, although these > would be translated into enums. Unless I'm mistaken, the most common use-case for codes implemented in a library such as CM is to provide a correct answer or bail out in a non-equivocal way. It would make the code more involved to handle a minority of (undefined) cases. [Actual examples would be welcome in order to focus the discussion.] >> The current reporting is based on exceptions, and assumes that if no >> exception was thrown, then the user's request completed >> successfully. > Sure - personally I'd much rather deal with something similar to an > HTTP status code in a callback, than an exception . I think the code > is cleaner and the calback makes it more elegant to apply an adaptive > approach to handling the response, like slightly relaxing > constraints, > convergence parameters, etc. Also by getting rid of the exceptions, > we no longer depend on the I18N layer that they are tied to and now > the messages can be more informative, since they target the root > cause. The observer can also run in the 'main' thread' while the > optimization can run asynchronously. Also WRT JDK9 and modules, > loosing the exceptions would mean one less dependency when the > library > is up into JDK9 modules...which would be more in line with this > philosophy: > https://github.com/substack/browserify-handbook#module-philosophy I'm not sure I fully understood the philosophy from the text in this short paragraph. But I do not agree with the idea that the possibility to quickly find some code is more important than standards and best practices. >> I totally agree that in some circumstances, more information on the >> inner working of an algorithm would be quite useful. > ... Algorithm iterations become unit testable. >> >> But I don't see the point in devoting resources to reinvent the >> wheel: > You mean pimping the wheel? Big pimpin. I think that logging statements are easy to add, not disruptive at all, and come in handy to understand a code's unexpected behaviour. Assuming that a "logging" feature is useful, it can be added *now* using a dependency towards a weight-less (!) framework such as "slf4j". IMO, it would be a waste of time to implement a new communication layer that can do that, and more, if it would be used for logging only in 99% of the cases. >> >> I longed several times for the use of a logging library. >> The only show-stopper has been the informal "no-dependency" >> policy... > JDK9 Jigsaw should solve dependency hell, so the less coupling > between commons math classes the better. I wouldn't call "coupling" the dependency towards exception classes: they are little utilities that can make sense in various parts of the library. [Unless one wants to embark on yet another discussion about exceptions; whether there should be one class for each of the "messages" that exist in "LocalizedFormats"; whether localization should be done in CM; etc.] > Anyways I'm obviously > interested in playing with this stuff, so when I get something up > into > a repository I'll to do a callback :). If you are interested in big overhauls, there is one that gathered relative consensus: rewrite the algorithms in a "multithread-friendly" way. Some ideas were floated (cf. ML archive) but no implementation or experiment... Perhaps with a well-defined goal such as performance improvement, your design suggestions will become clearer to more people. AFAIK, only the classes in the "o.a.c.m.neuralnet" package are currently ready to be used with the "java.util.concurrent" framework. Best regards, Gilles > > Cheers, > Ole > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org