Initialize the mission.
This is the "forward-backward" formulation.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(my_solver_type), | intent(inout) | :: | me | |||
character(len=*), | intent(in) | :: | config_file_name |
the config file to read |
||
real(kind=wp), | intent(out), | optional, | dimension(:), allocatable | :: | x |
initial guess |
subroutine initialize_the_solver(me,config_file_name,x) implicit none class(my_solver_type),intent(inout) :: me character(len=*),intent(in) :: config_file_name !! the config file to read real(wp),dimension(:),allocatable,intent(out),optional :: x !! initial guess integer :: n !! number of opt vars for the solver integer :: m !! number of equality constraints for the solver logical :: status_ok !! status flag for solver initialization integer :: istat !! status code from solver integer,dimension(:),allocatable :: irow,icol !! sparsity pattern ! note: we don't know the problem size ! until we read the config file. ! first we have to read the config file: ! this will populate some of the mission variables call me%read_config_file(config_file_name) ! initialize the mission call me%mission%init(x) call me%mission%define_problem_size(n,m) ! initialize the solver: select case (me%mission%solver_mode) case(1) ! dense - uses lapack to solve the linear system call me%initialize( n = n, & m = m, & max_iter = 100, & ! maximum number of iteration func = halo_func, & grad = halo_grad, & tol = me%mission%nlesolver_tol, & ! tolerance step_mode = 4, & ! 3-point "line search" (2 intervals) n_intervals = 2, & ! number of intervals for step_mode=4 alpha_min = 0.2_wp, & alpha_max = 0.8_wp, & use_broyden = .false., & ! broyden update !use_broyden=.true.,broyden_update_n=10, & ! ... test ... export_iteration = halo_export ) case(5) ! this is using the qr_mumps solver as a user-defined solver to nlesolver-fortran. ! the solver is defined in qrm_solver. you must use the WITH_QRMUMPS preprocessor ! directive to use this method and link the code with the appropriate libraries. call me%mission%get_sparsity_pattern(irow,icol) ! it's already been computed, but for now, just compute it again for this call call me%initialize( n = n, & m = m, & max_iter = 100, & ! maximum number of iteration func = halo_func, & grad_sparse = halo_grad_sparse, & tol = me%mission%nlesolver_tol, & ! tolerance step_mode = 4, & ! 3-point "line search" (2 intervals) n_intervals = 2, & ! number of intervals for step_mode=4 alpha_min = 0.2_wp, & alpha_max = 0.8_wp, & use_broyden = .false., & ! broyden update sparsity_mode = me%mission%solver_mode, & ! use a sparse solver custom_solver_sparse = qrm_solver, & ! the qr_mumps solver wrapper irow = irow, & ! sparsity pattern icol = icol, & export_iteration = halo_export ) case (2:4) ! varions sparse options available in nlesolver-fortran call me%mission%get_sparsity_pattern(irow,icol) ! it's already been computed, but for now, just compute it again for this call call me%initialize( n = n, & m = m, & max_iter = 100, & ! maximum number of iteration func = halo_func, & grad_sparse = halo_grad_sparse, & tol = me%mission%nlesolver_tol, & ! tolerance ! step_mode = 1,& ! TEST TEST TEST ! alpha = 1.0_wp,& step_mode = 4, & ! 3-point "line search" (2 intervals) n_intervals = 2, & ! number of intervals for step_mode=4 use_broyden = .false., & ! broyden update !use_broyden=.true.,broyden_update_n=10, & ! ... test ... export_iteration = halo_export, & sparsity_mode = me%mission%solver_mode, & ! use a sparse solver atol = 1.0e-12_wp,& ! relative error in definition of `A` btol = 1.0e-12_wp,& ! relative error in definition of `b` ! damp = 0.00001_wp, & ! TEST: LSQR damp factor ! damp = 0.0_wp, & ! TEST: LSQR damp factor ! ! damp = 0.1_wp, & ! TEST: LSQR damp factor ! itnlim = 1000000, & ! max iterations irow = irow, & ! sparsity pattern icol = icol, & lusol_method = 0 ) ! test case default error stop 'invalid solver_mode' end select call me%status(istat=istat) status_ok = istat == 0 if (.not. status_ok) then write(*,*) 'istat = ', istat error stop 'error in initialize_the_solver' end if end subroutine initialize_the_solver