Hello, I'm facing a problem of optimization, I've already solved but I'm trying to find other answers to this problem to improve the solution. Well, to make it short: I have to set/install a number of devices in a building, and I have to give service to a number of "customers", or better say, to give a good quality of the signal. The more devices I place, the higher the signal. The signal is measured in a (coverage) percentage, the higher the percentage, the better the service. The max percentage is (obviously) 100%. As an example: Example 1: ---------- devices<-1:49 percentages<-c(15.8,29.3,43.1,52.9,61.8,70.4,77.6,84.4,88.6,90.9,92.7,93.2,9 4.1,94.6,95.4,96.1,96.5,97,97.3,97.8,98.1,98.7,99,99.4,99.5,99.6,99.7,99.9,1 00,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,1 00,100) matplot(devices,percentages,type="l") cbind(devices,percentages) In this example, I can place up to 49 devices, though it does not make any sense to place more than 29 since 29 devices gives a quality of 100%, the maximum. My problem is that I want to minimize the number of devices maximizing the percentage. I think the key is "I don't want to add a new device if there is no significance change in the final percentage", so looking at the graph 11 devices seems logical. Notice that my objective is not the final percentage, it can be 90%... or 50%. The service is ok with both numbers. Although I've solved the problem calculating the slope and making an axis change, I'd like to make something "statistically" stronger, because in the end what I'm doing is making some trigonometrics. If you think on other solutions i'd appreciate your help. Thanks, J. Lozano Other examples: Example 2: ---------- devices<-1:45 percentages<-c(19.6,38.3,53.2,65,72.9,78.5,82.8,87,89,90.1,91.7,92.6,93.7,94 .6,95.4,96,96.5,96.9,97.2,97.7,97.9,98.3,98.6,98.8,99,99.3,99.6,99.8,100,100 ,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100) matplot(devices,percentages,type="l") cbind(devices,percentages) 45 total devices, 9-10 devices seem logical. Example 3: ---------- devices<-1:37 percentages<-c(12.4,24.6,35.8,44.9,53.4,61.6,70,76.9,82.3,84.7,87.5,89.1,90. 7,91.8,92.9,94.3,95.6,95.9,97,97.2,97.4,97.8,98,98.2,98.4,98.7,99,99.2,99.4, 99.6,99.8,100,100,100,100,100,100) matplot(devices,percentages,type="l") cbind(devices,percentages) 37 total devices, 9 devices seem logical. Example 4: ---------- devices<-1:52 percentages<-c(12.2,22.4,32,41.3,50.1,56.2,61,64.3,66.9,69.2,73.7,76,78.6,81 .7,85.4,87.8,91.1,92.8,94.2,95,95.6,96.3,96.6,97.3,97.7,98.2,98.5,98.7,99.2, 99.6,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100 ,100,100,100,100) matplot(devices,percentages,type="l") cbind(devices,percentages) 52 total devices, hard to chose, 9? 19?
How about smoothing the percentages, and then take the second derrivative to find the inflection point? which.max(diff(diff((lowess(percentages)$y)))) Bart -- View this message in context: http://r.789695.n4.nabble.com/Optimization-problem-tp2258654p2258828.html Sent from the R help mailing list archive at Nabble.com.
min(devices[percentages==max(percentages)]) Bill
Here is a general approach using smoothing using the Gasser-Mueller kernel, which is implemented in the "lokern" package. The optimal bandwidth for derivative estimation is automatically chosen using a plug-in approximation. The code and the results are attached here. Let me know if you have any questions. Ravi. -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Jos? E. Lozano Sent: Thursday, June 17, 2010 7:48 AM To: r-help at r-project.org Subject: [R] Optimization problem Hello, I'm facing a problem of optimization, I've already solved but I'm trying to find other answers to this problem to improve the solution. Well, to make it short: I have to set/install a number of devices in a building, and I have to give service to a number of "customers", or better say, to give a good quality of the signal. The more devices I place, the higher the signal. The signal is measured in a (coverage) percentage, the higher the percentage, the better the service. The max percentage is (obviously) 100%. As an example: Example 1: ---------- devices<-1:49 percentages<-c(15.8,29.3,43.1,52.9,61.8,70.4,77.6,84.4,88.6,90.9,92.7,93.2,9 4.1,94.6,95.4,96.1,96.5,97,97.3,97.8,98.1,98.7,99,99.4,99.5,99.6,99.7,99.9,1 00,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,1 00,100) matplot(devices,percentages,type="l") cbind(devices,percentages) In this example, I can place up to 49 devices, though it does not make any sense to place more than 29 since 29 devices gives a quality of 100%, the maximum. My problem is that I want to minimize the number of devices maximizing the percentage. I think the key is "I don't want to add a new device if there is no significance change in the final percentage", so looking at the graph 11 devices seems logical. Notice that my objective is not the final percentage, it can be 90%... or 50%. The service is ok with both numbers. Although I've solved the problem calculating the slope and making an axis change, I'd like to make something "statistically" stronger, because in the end what I'm doing is making some trigonometrics. If you think on other solutions i'd appreciate your help. Thanks, J. Lozano Other examples: Example 2: ---------- devices<-1:45 percentages<-c(19.6,38.3,53.2,65,72.9,78.5,82.8,87,89,90.1,91.7,92.6,93.7,94 .6,95.4,96,96.5,96.9,97.2,97.7,97.9,98.3,98.6,98.8,99,99.3,99.6,99.8,100,100 ,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100) matplot(devices,percentages,type="l") cbind(devices,percentages) 45 total devices, 9-10 devices seem logical. Example 3: ---------- devices<-1:37 percentages<-c(12.4,24.6,35.8,44.9,53.4,61.6,70,76.9,82.3,84.7,87.5,89.1,90. 7,91.8,92.9,94.3,95.6,95.9,97,97.2,97.4,97.8,98,98.2,98.4,98.7,99,99.2,99.4, 99.6,99.8,100,100,100,100,100,100) matplot(devices,percentages,type="l") cbind(devices,percentages) 37 total devices, 9 devices seem logical. Example 4: ---------- devices<-1:52 percentages<-c(12.2,22.4,32,41.3,50.1,56.2,61,64.3,66.9,69.2,73.7,76,78.6,81 .7,85.4,87.8,91.1,92.8,94.2,95,95.6,96.3,96.6,97.3,97.7,98.2,98.5,98.7,99.2, 99.6,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100 ,100,100,100,100) matplot(devices,percentages,type="l") cbind(devices,percentages) 52 total devices, hard to chose, 9? 19? ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -------------- next part -------------- A non-text attachment was scrubbed... Name: optimal_devices_smooth_plots.pdf Type: application/pdf Size: 26461 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100617/20998d53/attachment.pdf>
Sorry, thought you wanted to find lowest value of x that produced maximum value of y. I see now that is not the case. I think you have to decide on what amount of improvement per device you judge to be 'minimal'. Then the algorithm uses the value of y that occurs at the point where this criterion is reached. I think this will do it min(devices[diff(percentages)<criterion]) Bill
Hello:> Here is a general approach using smoothing using the Gasser-Muellerkernel,> which is implemented in the "lokern" package. The optimal bandwidth for > derivative estimation is automatically chosen using a plug-inapproximation.> The code and the results are attached here.Maybe am I missing the "features.mat" function? Probably the function is inside the file "features.txt", that is not included.> source("features.txt")Thanks a lot, Jose Lozano