consts.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. '''
  2. This is a module defining some constants.
  3. Translated from Zaikun Zhang's modern-Fortran reference implementation in PRIMA.
  4. Dedicated to late Professor M. J. D. Powell FRS (1936--2015).
  5. Python translation by Nickolai Belakovski.
  6. '''
  7. import numpy as np
  8. import os
  9. DEBUGGING = bool(os.getenv('PRIMA_DEBUGGING'))
  10. REALMIN = np.finfo(float).tiny
  11. REALMAX = np.finfo(float).max
  12. FUNCMAX = 10.0**30
  13. CONSTRMAX = FUNCMAX
  14. EPS = np.finfo(float).eps
  15. # Any bound with an absolute value at least BOUNDMAX is considered as no bound.
  16. BOUNDMAX = REALMAX/4
  17. # Some default values
  18. RHOBEG_DEFAULT = 1
  19. RHOEND_DEFAULT = 1e-6
  20. FTARGET_DEFAULT = -REALMAX
  21. CTOL_DEFAULT = np.sqrt(EPS)
  22. CWEIGHT_DEFAULT = 1e8
  23. ETA1_DEFAULT = 0.1
  24. ETA2_DEFAULT = 0.7
  25. GAMMA1_DEFAULT = 0.5
  26. GAMMA2_DEFAULT = 2
  27. IPRINT_DEFAULT = 0
  28. MAXFUN_DIM_DEFAULT = 500
  29. PRIMA_MAX_HIST_MEM_MB = 300 # 1MB > 10^5*REAL64. 100 can be too small.
  30. # Maximal amount of memory (Byte) allowed for XHIST, FHIST, CONHIST, CHIST, and the filters.
  31. MHM = PRIMA_MAX_HIST_MEM_MB * 10**6
  32. # Make sure that MAXHISTMEM does not exceed HUGE(0) to avoid overflow and memory errors.
  33. MAXHISTMEM = min(MHM, np.iinfo(np.int32).max)
  34. # Maximal length of the filter used in constrained solvers.
  35. MIN_MAXFILT = 200 # Should be positive; < 200 is not recommended.
  36. MAXFILT_DEFAULT = 10 * MIN_MAXFILT