Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicated selected locations in spjitter #13

Open
AlexandreWadoux opened this issue Apr 6, 2019 · 6 comments
Open

duplicated selected locations in spjitter #13

AlexandreWadoux opened this issue Apr 6, 2019 · 6 comments

Comments

@AlexandreWadoux
Copy link

AlexandreWadoux commented Apr 6, 2019

When I run the optimization with cellsize = 0, i.e. with a finite number of candidate locations, the algorithm selects same location several times. Below a reproducible example.

library(sp)
data(meuse.grid, package = "sp")

schedule <- scheduleSPSANN( chains = 10, initial.temperature = 10, temperature.decrease = 0.5, x.max = 1540, y.max = 2060, x.min = 0, y.min = 0, cellsize = 0)

set.seed(2001)
res <- optimCLHS( points = 400, candi = meuse.grid[,c('x', 'y')], covars = meuse.grid[, c(1,5)], use.coords = F, schedule = schedule, track=F, plotit = F)

res.pt <- res$points
coordinates(res.pt) <- ~x+y
zerodist(res.pt)

I understand that the algorithm selects a random location inside a pixel of size cellsize around the candidate location. But when I set cellsize=0, this should normally not happen I guess. This means that there is not check to ensure that the selected location is not already occupied.

@samuel-rosa
Copy link
Collaborator

You are right: there is no check because spsann assumes that you are using an infinite set of candidate locations. But I guess that spsann is making the wrong assumption.
Gonna work on that!

@AlexandreWadoux
Copy link
Author

I agree that this is very unlikely to select twice the exact same candidate location in an infinite set of candidate location. But it could...

I now realize that by implementing a check on whether the candidate location is already occupied, you would probably solve (we need to think this through) the other issue that I raised: optimizing based on a finite set of candidate locations. This is an important problem, for example when one wants to thin an existing network with known and finite number of candidate locations. No need to implement a new spJitter function then.

@samuel-rosa
Copy link
Collaborator

I have just implemented the check when using cellsize = 0. Now only "free" candidate locations are used.
I am not sure if this already solves the thinning issue!
I will likely make another modification: I think that finite candidate locations make more sense in the feature space than in the geographic space. So, finite candidates could be used by default behaviour, for instance, with CLHS, while for MSSD infinite candidates should be more appropriate.

@futureplant
Copy link

Hello! I'm still encountering this problem using SPSANN and optimUSER, even though I have set cellsize to 0!
Could it be that the solution was only implemented on optimCLHS or doesthat not make sense?

@samuel-rosa
Copy link
Collaborator

samuel-rosa commented Oct 2, 2020

I have limited time to work on this now. You are welcome to submit a pull request.

@samuel-rosa samuel-rosa reopened this Oct 2, 2020
@samuel-rosa
Copy link
Collaborator

Sorry, I do not remember what and where it was done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants