% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/803_hours_clause_apply_part2.R
\name{hours_clause_apply_part2}
\alias{hours_clause_apply_part2}
\title{Function that loops through events in one year and applies an hours clause}
\usage{
hours_clause_apply_part2(
  hcdays,
  hckm,
  byregion = FALSE,
  temploss,
  thisyearday,
  thisyearlon,
  thisyearlat,
  thisyearregion,
  nevents_in_year,
  k
)
}
\arguments{
\item{hcdays}{Hours clause parameter, number of days}

\item{hckm}{Hours clause parameter, distance in km}

\item{byregion}{Whether to use regions, or distances, to measure closeness}

\item{temploss}{Not sure. Part of the algorithm.}

\item{thisyearday}{For events in this year, the days}

\item{thisyearlon}{For events in this year, the lons}

\item{thisyearlat}{For events in this year, the lats}

\item{thisyearregion}{For events in this year, the regions}

\item{nevents_in_year}{Number of events in this year}

\item{k}{The index of the hours clause to apply, of all possible hours clauses}
}
\value{
A loss and a counter
}
\description{
Quite hard to understand.
Having previously found out which value of k gives the hours clause with the
largest loss, this routine applies the hours clause starting with that event.
It also registers which events have been moved, which part 1 does not do.
There are two separate, but very similar, routines, just to make the search
go faster, since in the initial search, there is no need to register which
events have been moved.
}
\details{
To be called from \code{hours_clause}, which loops thru the whole YLT,
and which itself is called from \code{hours_clause_wrapper}, which manages the file i/o.
}
\examples{
#
# 1 set the hours clause settings
#
hcdays=15
hckm=200
#
# 2 make a single year of a ylt
#
cat("1. make longylt:\n")
nyearsinylt=8
nevents_in_year1=10
thisyearloss	=seq(10,55,5)
thisyearday		=c(1	,2	,51	,101,151,201,251,300,350,360)
thisyearlat		=c(10	,11	,30	,30	,30	,30	,30	,30	,30	,50)
thisyearlon		=c(10	,11	,30	,30	,30	,30	,30	,30	,30	,50)
thisyearregion=rep("A",nevents_in_year1)
#
# 3 apply the hours clause routine to position 1
#
cat("1. apply the hours clause calculator:\n")
output=hours_clause_apply_part2(hcdays,hckm,byregion=FALSE,thisyearloss,
				thisyearday,thisyearlon,thisyearlat,thisyearregion,
				nevents_in_year1,k=1)
#
# 4 look at the output
#
cat("losses=",output$temploss,"\n")
cat("hccounter=",output$hccounter,"\n")
}
\references{
x
}
\author{
Stephen Jewson \email{stephen.jewson@gmail.com}
}
