SCM

[#6824] Error in frontierPoints when frontier is "upper"

Date:
2023-10-25 15:55
Priority:
3
State:
Open
Submitted by:
Ty Seddon (tyseddon)
Assigned to:
Nobody (None)
Hardware:
PC
Product:
None
Operating System:
None
Component:
None
Version:
None
Severity:
normal
Resolution:
None
URL:
Summary:
Error in frontierPoints when frontier is "upper"

Detailed description
In frontierPoints current code is:

if(frontier == "upper"){
index = 1:length(ans[, 1])
test = c(-1, diff(ans[, 1]))
index = index[test > 0]
ans = ans[index, ]
} else if(frontier == "lower"){
index = 1:length(ans[, 1])
test = c(-1, diff(ans[, 1]))
index = index[test < 0]
if (length(index) == 1) {
ans = matrix(ans[index, ], ncol = 2)
} else {
ans = ans[index, ]
}
}

This throws an error when there there are no upper points of the frontier

I believe the correct code should be:

if(frontier == "upper"){
index = 1:length(ans[, 1])
test = c(1, diff(ans[, 1]))
index = index[test > 0]
if (length(index) == 1) {
ans = matrix(ans[index, ], ncol = 2)
} else {
ans = ans[index, ]
}
} else if(frontier == "lower"){
index = 1:length(ans[, 1])
test = c(-1, diff(ans[, 1]))
index = index[test < 0]
if (length(index) == 1) {
ans = matrix(ans[index, ], ncol = 2)
} else {
ans = ans[index, ]
}
}

Two problems were fixed.
1) When assigning the test various you had c(-1, diff(ans[, 1])) I changed to c(1, diff(ans[, 1])) (i.e. -1 was wrong)
2) when length == 1 there needed to be logic similar to the lower frontier code

Comments:

No Comments Have Been Posted

Attached Files:

Changes

No Changes Have Been Made to This Item

Thanks to:
Vienna University of Economics and Business Powered By FusionForge