equilibrate Subroutine

subroutine equilibrate(d, x)

Equilibrate the continuity Jacobian at x for the optimization (eclipse_opt_equilibrate): alternately normalize its rows (weights w) and its columns (the variables' factors r, the optimization's variables being x/r), a few times, so that the rows and the columns all have 2-norms near 1. This lowers the condition number of the KKT systems of sqpopt's QP subproblems (for 100 revolutions, J's condition number goes from 8e4 to 7e2). The objective, |x/r - x0/r|^2/2, is then measured in these units.

Arguments

Type IntentOptional Attributes Name
type(eclipse_opt_data), intent(inout) :: d
real(kind=wp), intent(in), dimension(:) :: x

Calls

proc~~equilibrate~~CallsGraph proc~equilibrate equilibrate proc~compute_jacobian_stm mission_type%compute_jacobian_stm proc~equilibrate->proc~compute_jacobian_stm proc~define_problem_size mission_type%define_problem_size proc~compute_jacobian_stm->proc~define_problem_size proc~earth_moon_frame_matrices earth_moon_frame_matrices proc~compute_jacobian_stm->proc~earth_moon_frame_matrices proc~get_sparsity_pattern mission_type%get_sparsity_pattern proc~compute_jacobian_stm->proc~get_sparsity_pattern proc~propagate_segment_stm segment%propagate_segment_stm proc~compute_jacobian_stm->proc~propagate_segment_stm proc~put_x_in_segments mission_type%put_x_in_segments proc~compute_jacobian_stm->proc~put_x_in_segments proc~removed_columns mission_type%removed_columns proc~compute_jacobian_stm->proc~removed_columns get_rv get_rv proc~earth_moon_frame_matrices->get_rv get_rv_derivative get_rv_derivative proc~earth_moon_frame_matrices->get_rv_derivative proc~two_body_rotating_frame_matrices two_body_rotating_frame_matrices proc~earth_moon_frame_matrices->proc~two_body_rotating_frame_matrices proc~get_sparsity_pattern->proc~define_problem_size proc~get_sparsity_pattern->proc~removed_columns proc~propagate_segment_stm->proc~earth_moon_frame_matrices first_call first_call proc~propagate_segment_stm->first_call icrf_frame icrf_frame proc~propagate_segment_stm->icrf_frame integrate integrate proc~propagate_segment_stm->integrate proc~ballistic_derivs ballistic_derivs proc~propagate_segment_stm->proc~ballistic_derivs proc~identity_stm identity_stm proc~propagate_segment_stm->proc~identity_stm proc~set_segment_outputs segment%set_segment_outputs proc~propagate_segment_stm->proc~set_segment_outputs transform transform proc~propagate_segment_stm->transform two_body_rotating_frame two_body_rotating_frame proc~propagate_segment_stm->two_body_rotating_frame proc~put_x_in_segments->proc~define_problem_size extract_vector extract_vector proc~put_x_in_segments->extract_vector proc~set_segment_inputs segment%set_segment_inputs proc~put_x_in_segments->proc~set_segment_inputs proc~removed_columns->proc~define_problem_size get_acc get_acc proc~ballistic_derivs->get_acc get_r get_r proc~ballistic_derivs->get_r icrf_to_iau_moon icrf_to_iau_moon proc~ballistic_derivs->icrf_to_iau_moon j2000_to_frame j2000_to_frame proc~ballistic_derivs->j2000_to_frame proc~pines_gravity pines_gravity proc~ballistic_derivs->proc~pines_gravity proc~pointmass_gravity_gradient pointmass_gravity_gradient proc~ballistic_derivs->proc~pointmass_gravity_gradient proc~third_body_gravity_gradient third_body_gravity_gradient proc~ballistic_derivs->proc~third_body_gravity_gradient third_body_gravity third_body_gravity proc~ballistic_derivs->third_body_gravity proc~set_segment_inputs->icrf_frame proc~set_segment_inputs->transform proc~set_segment_inputs->two_body_rotating_frame proc~cross cross proc~two_body_rotating_frame_matrices->proc~cross proc~cross_matrix cross_matrix proc~two_body_rotating_frame_matrices->proc~cross_matrix proc~outer outer proc~pines_gravity->proc~outer proc~point_gradient point_gradient proc~pointmass_gravity_gradient->proc~point_gradient proc~third_body_gravity_gradient->proc~point_gradient proc~point_gradient->proc~outer

Called by

proc~~equilibrate~~CalledByGraph proc~equilibrate equilibrate proc~eclipse_optimize eclipse_optimize proc~eclipse_optimize->proc~equilibrate interface~eclipse_optimize my_solver_type%eclipse_optimize interface~eclipse_optimize->proc~eclipse_optimize proc~halo_solver_main halo_solver_main proc~halo_solver_main->interface~eclipse_optimize

Source Code

    subroutine equilibrate(d, x)

    type(eclipse_opt_data),intent(inout) :: d
    real(wp),dimension(:),intent(in) :: x

    real(wp),dimension(:),allocatable :: jac, a, norms
    integer :: it, k

    call d%mission%compute_jacobian_stm(x, jac)
    allocate(a(size(jac)), norms(max(size(d%r), size(d%w))))
    d%r = one
    d%w = one
    do it = 1, 10
        a = jac * d%r(d%icol) * d%w(d%irow)
        norms = zero
        do k = 1, size(a)
            norms(d%irow(k)) = norms(d%irow(k)) + a(k)**2
        end do
        where (norms(1:size(d%w)) > zero) d%w = d%w / sqrt(norms(1:size(d%w)))
        a = jac * d%r(d%icol) * d%w(d%irow)
        norms = zero
        do k = 1, size(a)
            norms(d%icol(k)) = norms(d%icol(k)) + a(k)**2
        end do
        where (norms(1:size(d%r)) > zero) d%r = d%r / sqrt(norms(1:size(d%r)))
    end do
    write(*,'(A,2ES10.2,A,2ES10.2)') '   equilibrated: column factors ', minval(d%r), maxval(d%r), &
                                     ', row weights ', minval(d%w), maxval(d%w)

    end subroutine equilibrate