ktools icon indicating copy to clipboard operation
ktools copied to clipboard

With `alloc_rule=1` do not cap `STD_DEV` and `CHANCE_OF_LOSS` values

Open mtazzari opened this issue 3 years ago • 0 comments

Issue Description

splittiv is the function in ktools:gulcalc.cpp that caps the losses to the tiv, proportionally to the losses themselves (i.e., alloc_rule=1). splittiv is called in writemode1output on all sidx numbers, including the negative ones. You can see below that splittiv is applied to gilv[i], which is itself a list of itemID-loss pairs for sample i and a given coverage_id. Note that i ranges 0...5+sample_size+1, where 5 represents the 5 negative sidx. Therefore, i=0 corresponds to sidx=-5, i=1 to sidx=-4, etc. ktools code here:

void gulcalc::writemode1output(const int event_id, const OASIS_FLOAT tiv,
			       std::vector<std::vector<gulItemIDLoss>> &gilv,
			       const bool correlated=false) {

	// Set losses for alloc rule where
	// total peril loss = maximum subperil loss
	if (alloc_rule_ == 2) setmaxloss(gilv);

	std::map<int, std::vector<gulSampleslevelRec>> gxi;

	// Check whether the sum of losses per sample exceed TIV
	// If so, split TIV in proportion to losses
	for (size_t i = 0; i < gilv.size(); i++) {

		splittiv(gilv[i], tiv);
                [...]

Definition of splittiv (ktools code here):

void splittiv(std::vector<gulItemIDLoss> &gulitems, OASIS_FLOAT tiv)
{
// if the total loss exceeds the tiv 
// then split tiv in the same proportions to the losses
	if (tiv > 0) {
		OASIS_FLOAT total_loss = 0;
		auto iter = gulitems.begin();
		while (iter != gulitems.end()) {
			total_loss += iter->loss;
			iter++;
		}
		if (total_loss > tiv) {
			iter = gulitems.begin();
			while (iter != gulitems.end()) {
				double percentage = iter->loss / total_loss;
				iter->loss = percentage * tiv;
				iter++;
			}
		}
	}
}

Following internal discussion, splittiv:

  • should be applied to all positive sidx numbers, as it is right now;
  • should only be applied to negative sidx=-1, -3, -5 (MEAN, TIV, MAX_LOSS) and not to sidx=-2,-4 (STD_DEV, CHANCE_OF_LOSS). This is a change w.r.t. current implementation

Version / Environment information

oasis ktools 3.7.5

mtazzari avatar Mar 08 '22 09:03 mtazzari