The gradient of the objective and the Jacobian values for sqpopt: halo's analytic Jacobian, then the eclipse rows (central differences).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in), | dimension(:) | :: | x | ||
| real(kind=wp), | intent(out), | dimension(:) | :: | g | ||
| real(kind=wp), | intent(out), | dimension(:) | :: | jac_val | ||
| integer, | intent(in) | :: | accuracy | |||
| integer, | intent(inout) | :: | status | |||
| class(*), | intent(inout), | optional | :: | data |
subroutine eclipse_gjac(x, g, jac_val, accuracy, status, data) real(wp),dimension(:),intent(in) :: x real(wp),dimension(:),intent(out) :: g real(wp),dimension(:),intent(out) :: jac_val integer,intent(in) :: accuracy integer,intent(inout) :: status class(*),optional,intent(inout) :: data real(wp),dimension(:),allocatable :: jac, ks, jr, w real(wp) :: rho, kmin integer :: k, j, o logical :: ok if (.not. present(data)) error stop 'eclipse_gjac: no data' select type (data) type is (eclipse_opt_data) ! (x here is the optimization's variable y = x/r: the columns are multiplied by r) if (data%mission%eclipse_opt_objective == 0) then g = zero else g = x - data%x0/data%r end if if (.not. epochs_in_range(data, x*data%r)) then jac_val = zero status = 1 return end if call data%mission%compute_jacobian_stm(x*data%r, jac) ! (also puts x in the segments) jac_val(1:data%nnz_halo) = jac * data%r(data%icol) * data%w(data%irow) allocate(ks(size(data%rows)), jr(sum(data%rows%ncol))) call eval_rows(data, ks, jr, ok=ok) if (.not. ok .or. any(data%mission%segs%failed)) status = 1 call scale_row_columns(data, jr) if (data%single) then ! the aggregate's partials: the segment rows' partials, weighted by d(KS)/d(ks_k) rho = data%mission%eclipse_opt_ks_rho kmin = minval(ks) w = exp(-rho*(ks - kmin)) w = w / sum(w) jac_val(data%nnz_halo+1:) = zero o = 0 do k = 1, size(data%rows) do j = 1, data%rows(k)%ncol jac_val(data%nnz_halo + data%upos(o+j)) = jac_val(data%nnz_halo + data%upos(o+j)) + w(k)*jr(o+j) end do o = o + data%rows(k)%ncol end do else jac_val(data%nnz_halo+1:) = jr end if class default error stop 'eclipse_gjac: invalid data' end select end subroutine eclipse_gjac