define_problem_size Subroutine

public pure subroutine define_problem_size(me, n, m, n_segs, n_nonzero, full_problem)

Returns the size variables for the "forward-backward" formulation of the problem.

Note

All the outputs are functions of n_revs, the number of orbits we want to solve.

History

  • JW : 8/1/2022 : added option to fix initial time

Type Bound

mission_type

Arguments

Type IntentOptional Attributes Name
class(mission_type), intent(in) :: me
integer, intent(out), optional :: n

number of opt vars for the solver

integer, intent(out), optional :: m

number of equality constraints for the solver

integer, intent(out), optional :: n_segs

number of segments

integer, intent(out), optional :: n_nonzero

number of nonzero elements in the Jacobian

logical, intent(in), optional :: full_problem

if true (default) always return the results for the full problem (i.e., without fixing any of the variables)


Called by

proc~~define_problem_size~~CalledByGraph proc~define_problem_size mission_type%define_problem_size proc~get_scales_from_segs mission_type%get_scales_from_segs proc~get_scales_from_segs->proc~define_problem_size proc~get_sparsity_pattern mission_type%get_sparsity_pattern proc~get_sparsity_pattern->proc~define_problem_size proc~halo_solver_main halo_solver_main proc~halo_solver_main->proc~define_problem_size proc~initialize_the_solver my_solver_type%initialize_the_solver proc~halo_solver_main->proc~initialize_the_solver proc~print_constraint_defects mission_type%print_constraint_defects proc~halo_solver_main->proc~print_constraint_defects proc~put_x_in_segments mission_type%put_x_in_segments proc~halo_solver_main->proc~put_x_in_segments proc~constraint_violations mission_type%constraint_violations proc~halo_solver_main->proc~constraint_violations proc~initialize_the_mission mission_type%initialize_the_mission proc~initialize_the_mission->proc~define_problem_size proc~initialize_the_mission->proc~get_scales_from_segs proc~initialize_the_mission->proc~get_sparsity_pattern proc~initialize_the_solver->proc~define_problem_size proc~initialize_the_solver->proc~get_sparsity_pattern proc~initialize_the_solver->proc~initialize_the_mission proc~print_constraint_defects->proc~define_problem_size proc~put_x_in_segments->proc~define_problem_size proc~constraint_violations->proc~put_x_in_segments

Source Code

    pure subroutine define_problem_size(me,n,m,n_segs,n_nonzero,full_problem)

    implicit none

    class(mission_type),intent(in) :: me
    integer,intent(out),optional :: n          !! number of opt vars for the solver
    integer,intent(out),optional :: m          !! number of equality constraints for the solver
    integer,intent(out),optional :: n_segs     !! number of segments
    integer,intent(out),optional :: n_nonzero  !! number of nonzero elements in the Jacobian
    logical,intent(in),optional :: full_problem !! if true (default) always return the results for the full problem
                                                !! (i.e., without fixing any of the variables)

    if (present(n))      n      = 28 * me%n_revs + 7
    if (present(m))      m      = 24 * me%n_revs
    if (present(n_segs)) n_segs = 8 * me%n_revs

    ! there are 4 blocks of nonzeros per rev
    ! (each block contains 84 elements)
    if (present(n_nonzero)) n_nonzero = me%n_revs * (84*4)

    if (present(full_problem)) then
        if (full_problem) return ! don't do the stuff below
    end if

    if (me%fix_initial_time) then
        if (present(n)) n = n - 1  ! remove the t0 optimization variable
        if (present(n_nonzero)) n_nonzero = n_nonzero - 6 ! remove the first column of the jacobian
    end if

    if (me%fix_initial_r) then
        if (present(n)) n = n - 3  ! remove the three optimization variables
        if (present(n_nonzero)) n_nonzero = n_nonzero - 3*6 ! remove columns 2,3,4 of the jacobian
    end if

    ! note: assuming there are more than 2 revs for these
    if (me%fix_ry_at_end_of_rev > 0) then
        if (me%n_revs<3) error stop 'at least 3 revs are required for fix_ry_at_end_of_rev'
        if (me%fix_ry_at_end_of_rev >= me%n_revs) &
            error stop 'fix_ry_at_end_of_rev must be < number of revs'
        if (present(n)) n = n - 1 ! remove the optimization variable
        if (present(n_nonzero)) n_nonzero = n_nonzero - 12
    end if

    if (me%fix_final_ry_and_vx) then
        if (me%n_revs<3) error stop 'at least 3 revs are required for fix_final_ry_and_vx'
        if (present(n)) n = n - 2 ! remove the two optimization variable
        if (present(n_nonzero)) n_nonzero = n_nonzero - 2*6
    end if

    end subroutine define_problem_size