Bug #3072

Min-Max logic is inverted in GOptimizerPar for negative scale factors

Added by Knödlseder Jürgen over 4 years ago. Updated almost 4 years ago.

Status:ClosedStart date:11/26/2019
Priority:NormalDue date:
Assigned To:Knödlseder Jürgen% Done:

100%

Category:-
Target version:1.7.0
Duration:

Description

The logic of minimum and maximum is inverted in GOptimizerPar for negative scale factors. The reason behind this is that the minimum and maximum is actually applied on the factor value, hence a minimum becomes a maximum and vice versa for a negative scale factor.

This should be corrected since it is confusing.


Recurrence

No recurrence.

History

#1 Updated by Knödlseder Jürgen about 4 years ago

  • Target version set to 1.7.0

#2 Updated by Knödlseder Jürgen almost 4 years ago

  • Status changed from New to In Progress
  • Assigned To set to Knödlseder Jürgen

The following code

#!/usr/bin/env python
import gammalib

par = gammalib.GModelPar('Test', 3.0, -1.0)
par.range(-10.0, 10.0)
leads to the following error
Traceback (most recent call last):
  File "./test.py", line 5, in <module>
    par.range(-10.0, 10.0)
  File "/usr/local/gamma/lib/python2.7/site-packages/gammalib/opt.py", line 500, in range
    return _opt.GOptimizerPar_range(self, min, max)
ValueError: *** ERROR in GOptimizerPar::factor_value(double&): Invalid argument. Specified minimum factor 10 is larger than the value factor 3.

#3 Updated by Knödlseder Jürgen almost 4 years ago

I implemented the correct handling of the minima and maxima.

The boundaries are now stored as values, and for the factor_min() and factor_max() now return the corresponding boundary based on the sign of the scale factor. The above test code now works, and adding a print function gives:

  Test .....................: -3 +/- 0 [-10,10]  (free,scale=-1)
as expected.

All GammaLib tests are okay. I still need to check ctools now.

#4 Updated by Knödlseder Jürgen almost 4 years ago

  • Status changed from In Progress to Pull request
  • % Done changed from 0 to 100

Also the ctools unit check is ok.

#5 Updated by Knödlseder Jürgen almost 4 years ago

  • Status changed from Pull request to Closed

Merged into devel.

#6 Updated by Knödlseder Jürgen almost 4 years ago

  • Status changed from Closed to In Progress
  • % Done changed from 100 to 90

There is an integration error with the ctools unit test on OpenSolaris. 9 ctools unit tests to fail. Here some examples of the error messages that occur:

ctools unit testing.Test cterror on command line
*** ERROR in GPythonTestSuite::test: <type 'exceptions.RuntimeError'> *** ERROR in GXml::load(std::string&): Unable to open file "cterror_cmd1.xml" 

ctools unit testing.Test cterror from Python
*** ERROR in GPythonTestSuite::test: <type 'exceptions.ValueError'> *** ERROR in GOptimizerPar::factor_value(double&): Invalid argument. Specified value factor 1e-07 is smaller than the minimum boundary 1e-07.

cscripts unit testing.Test csbkgmodel from Python
*** ERROR in GPythonTestSuite::test: <type 'exceptions.ValueError'> *** ERROR in GOptimizerPar::factor_value(double&): Invalid argument. Specified value factor 1e-10 is smaller than the minimum boundary 1e-10.

cscripts unit testing.Test csbkgmodel pickeling
*** ERROR in GPythonTestSuite::test: <type 'exceptions.ValueError'> *** ERROR in GOptimizerPar::factor_value(double&): Invalid argument. Specified value factor 1e-10 is smaller than the minimum boundary 1e-10.

cscripts unit testing.Test csphasecrv from Python
*** ERROR in GPythonTestSuite::test: <type 'exceptions.ValueError'> *** ERROR in GOptimizerPar::factor_value(double&): Invalid argument. Specified value factor 1e-07 is smaller than the minimum boundary 1e-07.

#7 Updated by Knödlseder Jürgen almost 4 years ago

I reimplemented the parameter boundary code, storing now the factor boundaries so that no accuracy problems should occur.

#8 Updated by Knödlseder Jürgen almost 4 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 90 to 100

The new code works on OpenSolaris. Merged into devel.

Also available in: Atom PDF