|
13 | 13 | ! * http://projecteuclid.org/download/pdf_1/euclid.pjm/1102995080 |
14 | 14 | ! * http://help.agi.com/stk/index.htm#gator/eq-diffcorr.htm |
15 | 15 | ! * http://gmat.sourceforge.net/doc/R2015a/html/DifferentialCorrector.html |
| 16 | +! * https://openmdao.org/newdocs/versions/latest/features/building_blocks/solvers/bounds_enforce.html |
16 | 17 | ! |
17 | 18 | !### Author |
18 | 19 | ! * Jacob Williams |
@@ -67,19 +68,19 @@ module nlesolver_module |
67 | 68 | real(wp),parameter :: big = huge(one) |
68 | 69 |
|
69 | 70 | ! options for sparsity_mode |
70 | | - integer,parameter,public :: NLESOLVER_SPARSITY_DENSE = 1 !! assume dense (use dense solver). |
71 | | - integer,parameter,public :: NLESOLVER_SPARSITY_LSQR = 2 !! assume sparse (use LSQR sparse solver). |
72 | | - integer,parameter,public :: NLESOLVER_SPARSITY_LUSOL = 3 !! assume sparse (use LUSOL sparse solver). |
73 | | - integer,parameter,public :: NLESOLVER_SPARSITY_LSMR = 4 !! assume sparse (use LSMR sparse solver). |
74 | | - integer,parameter,public :: NLESOLVER_SPARSITY_CUSTOM_SPARSE = 5 !! assume sparse (use a user provided sparse solver). |
75 | | - !integer,parameter,public :: NLESOLVER_SPARSITY_CUSTOM_DENSE = 6 !! assume dense (use a user provided dense solver). |
| 71 | + integer,parameter,public :: NLESOLVER_SPARSITY_DENSE = 1 !! [[nlesolver_type:sparsity_mode]] : assume dense (use dense solver). |
| 72 | + integer,parameter,public :: NLESOLVER_SPARSITY_LSQR = 2 !! [[nlesolver_type:sparsity_mode]] : assume sparse (use LSQR sparse solver). |
| 73 | + integer,parameter,public :: NLESOLVER_SPARSITY_LUSOL = 3 !! [[nlesolver_type:sparsity_mode]] : assume sparse (use LUSOL sparse solver). |
| 74 | + integer,parameter,public :: NLESOLVER_SPARSITY_LSMR = 4 !! [[nlesolver_type:sparsity_mode]] : assume sparse (use LSMR sparse solver). |
| 75 | + integer,parameter,public :: NLESOLVER_SPARSITY_CUSTOM_SPARSE = 5 !! [[nlesolver_type:sparsity_mode]] : assume sparse (use a user provided sparse solver). |
| 76 | + !integer,parameter,public :: NLESOLVER_SPARSITY_CUSTOM_DENSE = 6 !! [[nlesolver_type:sparsity_mode]] : assume dense (use a user provided dense solver). [not available] |
76 | 77 | ! if add will have to update code below where sparsity_modes /= 1 is assumed sparse |
77 | 78 |
|
78 | | - ! bounds model parameters: |
79 | | - integer,parameter,public :: NLESOLVER_IGNORE_BOUNDS = 0 |
80 | | - integer,parameter,public :: NLESOLVER_SCALAR_BOUNDS = 1 |
81 | | - integer,parameter,public :: NLESOLVER_VECTOR_BOUNDS = 2 |
82 | | - integer,parameter,public :: NLESOLVER_WALL_BOUNDS = 3 |
| 79 | + ! bounds model options: |
| 80 | + integer,parameter,public :: NLESOLVER_IGNORE_BOUNDS = 0 !! [[nlesolver_type:bounds_mode]] : ignore bounds |
| 81 | + integer,parameter,public :: NLESOLVER_SCALAR_BOUNDS = 1 !! [[nlesolver_type:bounds_mode]] : scalar mode |
| 82 | + integer,parameter,public :: NLESOLVER_VECTOR_BOUNDS = 2 !! [[nlesolver_type:bounds_mode]] : vector mode |
| 83 | + integer,parameter,public :: NLESOLVER_WALL_BOUNDS = 3 !! [[nlesolver_type:bounds_mode]] : wall mode |
83 | 84 |
|
84 | 85 | !********************************************************* |
85 | 86 | type,public :: nlesolver_type |
@@ -495,6 +496,8 @@ subroutine initialize_nlesolver_variables(me,& |
495 | 496 | !! * 1 = scalar mode |
496 | 497 | !! * 2 = vector mode |
497 | 498 | !! * 3 = wall mode |
| 499 | + !! |
| 500 | + !! See [[nlesolver_type:bounds_mode]] for full descriptions. |
498 | 501 | real(wp),dimension(n),intent(in),optional :: xlow !! lower bounds for `x` (size is `n`). only used if `bounds_mode>0` and |
499 | 502 | !! both `xlow` and `xupp` are specified. |
500 | 503 | real(wp),dimension(n),intent(in),optional :: xupp !! upper bounds for `x` (size is `n`). only used if `bounds_mode>0` and |
@@ -1032,24 +1035,20 @@ end subroutine adjust_x_for_bounds |
1032 | 1035 |
|
1033 | 1036 | !***************************************************************************************** |
1034 | 1037 | !> |
1035 | | -! if necessary, adjust the search direction vector so that bounds are not violated. |
| 1038 | +! if necessary, adjust the search direction vector `p` so that bounds are not violated. |
1036 | 1039 | ! |
1037 | 1040 | !### Reference |
1038 | 1041 | ! * https://openmdao.org/newdocs/versions/latest/features/building_blocks/solvers/bounds_enforce.html |
1039 | 1042 |
|
1040 | | - ! TODO: for the 'wall' mode, flag the ones that were violated, and use |
1041 | | - ! that to set the alpha=0 for those vars during the line search. |
1042 | | - ! --> where (adjusted) xnew = x |
1043 | | - |
1044 | 1043 | subroutine adjust_search_direction(me,x,p,pnew,modified) |
1045 | 1044 |
|
1046 | 1045 | implicit none |
1047 | 1046 |
|
1048 | 1047 | class(nlesolver_type),intent(inout) :: me |
1049 | | - real(wp),dimension(me%n),intent(in) :: x !! initial `x` |
| 1048 | + real(wp),dimension(me%n),intent(in) :: x !! initial `x`. it is assumed that this does not violate any bounds. |
1050 | 1049 | real(wp),dimension(me%n),intent(in) :: p !! search direction `p = xnew - x` |
1051 | 1050 | real(wp),dimension(me%n),intent(out) :: pnew !! new search direction |
1052 | | - logical,dimension(me%n),intent(out) :: modified !! indicates the elements of p that were modified |
| 1051 | + logical,dimension(me%n),intent(out) :: modified !! indicates the elements of `p` that were modified |
1053 | 1052 |
|
1054 | 1053 | integer :: i !! counter |
1055 | 1054 | real(wp),dimension(:),allocatable :: xnew !! `x + pnew` |
|
0 commit comments