I cordially salute the participants of the conference. As for me one of the most important tools, in particular in calibration procedures, is an optimizer of a function. For example, my typical problem is: find a model parameter set such that some cost function is minimized. The available optimizers in QuantLib are LevenbergMarquardt methods. To setup up an optimizer, I need to define the end criteria which lead to a successful optimization. They are summarized in the EndCriteria class whose constructor os EndCriteria (StationaryStateIterations). I wrote a small piece of code to сonsider the Vasicek model for standard Brownian motion. With a little bit of bad advice, I find myself facing a much bigger challenge.
File "pandas1/vasicek_calib.py", line 74, in <module> model.calibrate(swaptions, optimization_method, end_criteria(10000, 100, 1e-6, 1e-8, 1e-8, 1.0e-8, 1.0e-8, 1.0e-8)) File "pandas1/lib/python3.10/site-packages/QuantLib/QuantLib.py", line 7508, in __call__ return _QuantLib.EndCriteria___call__(self, iteration, statState, positiveOptimization, fold, normgold, fnew, normgnewx, ecType)TypeError: in method 'EndCriteria___call__', argument 3 of type 'Size &'
I have read very interesting article about this topic: “The Levenberg-Marquardt Method and its Implementation in Python” submitted by Marius Kaltenbach (Konstanzer Online-Publikations-System (KOPS) URL: http://nbn-resolving.de/urn:nbn:de:bsz:352-2-1ofyba49ud2jr5). So far I have no complaints about this argument ‘statState’. I think the input parameters of this argument are:-maximum iterations: restrict the maximum number of solver iterations;-minimum stationary state iterations: give a minimum number of iterations at stationary point (for both, function value stationarity and root stationarity). I suppose that not all of the end criteria are needed in each optimizer. I haven’t found any argument 3 of type 'Size &' which checks for the optimization. Furthermore, the argument which leads to a stopping of the algorithm is returned. May be it should be checked that this criteria is not of type EndCriteria::None.Then I decided that I couldn't to call the method 'EndCriteria__call__'. That method is internal and shouldn't be exposed to Python. And I have already passed the input parameters to the EndCriteria constructor and built end_criteria. So I passed it to the calibrate method by sayingmodel.calibrate(swaptions, optimization_method, end_criteria).I corrected the error in the script, so it shouldn't happen again. Apparently there is another problem with the code.
File "pandas1/vasicek_calib.py", line 74, in <module> model.calibrate(swaptions, optimization_method, end_criteria) File "/home/anrdzimin72/pandas1/lib/python3.10/site-packages/QuantLib/QuantLib.py", line 16672, in calibrate return _QuantLib.CalibratedModel_calibrate(self, *args)RuntimeError: wrong argument type
I suppose in general there is now be another possibilities to find out where exactly in the code it goes wrong. I have read the instructions https://www.implementingquantlib.com/2013/08/chapter-5-part-4-of-5-models-and.html,https://rkapl123.github.io/QLAnnotatedSource/d7/db6/class_quant_lib_1_1_calibrated_model.html.I am new in this field, could you please guide me about this error. And how should I write this argument ‘statState’ of type 'Size &'? May be I am again a bit confused here.