Re: problem with Problem
Posted by
Luigi Ballabio on
Apr 17, 2012; 3:33pm
URL: http://quantlib.414.s1.nabble.com/problem-with-Problem-tp11790p11791.html
On Tue, Apr 17, 2012 at 10:28 AM, Simon Ibbotson
<
[hidden email]> wrote:
> Possibly this should be submitted as a bug-fix…
>
> Why does the class Problem store a reference to the CostFunction and a
> reference to the Constraint?
>
> This seems incredibly bad programming / commenting. A call to create a
> Problem class of the form:
>
> Problem prob(preCreatedCostFunction, PositiveConstraint(), initialValues);
>
> will fail unpredictably at optimisation time as the Constraint is no longer
> a valid reference.
>
> If you want to force the CostFunction and the Constraint to be pre-created
> at the very least this should be commented, better would be to pass a shared
> pointer (which could be tested).
Simon,
you're right, that's downright embarrassing. Strange that I never
bumped into this...
At this time replacing the references with a shared pointer would
break backward compatibility, but I agree that this should at least be
documented. I'll add a warning to the class.
Thanks for the heads-up.
Luigi
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev