problem with Problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

problem with Problem

Simon Ibbotson-2
problem with Problem

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 communication and any attachments contains information which is confidential and may be subject to legal privilege. It is for intended recipients only. If you are not the intended recipient you must not copy, distribute, publish, rely on or otherwise use it without our consent. Some of our communications may contain confidential information which it could be a criminal offence for you to disclose or use without authority. If you have received this email in error please notify [hidden email] immediately and delete the email from your computer.

The FSA reserves the right to monitor all email communications for compliance with legal, regulatory and professional standards.

This email is not intended to nor should it be taken to create any legal relations or contractual relationships. This email has originated from

The Financial Services Authority (FSA)
25 The North Colonnade,
Canary Wharf,
London
E14 5HS
United Kingdom

Registered as a Limited Company in England and Wales No.1920623.
Registered Office as above

Switchboard: 020 7066 1000
Web Site: http://www.fsa.gov.uk
*****************************************************************


------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|

Re: problem with Problem

Luigi Ballabio
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