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
This email is not intended to nor should it be taken to create any legal relations or contractual relationships. This email has originated from ------------------------------------------------------------------------------ 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 |
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 |
Free forum by Nabble | Edit this page |