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

Parallel computation #28

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Parallel computation #28

wants to merge 3 commits into from

Conversation

spiry34
Copy link

@spiry34 spiry34 commented Aug 27, 2021

Added optional parallel computation in cartogram_cont.R, relevant for large maps or grids
Added @param documentation line for parallel option
Contributor information added in DESCRIPTION.
New parallel feature added in NEWS.

Parallel computation is slower on small maps (~1-5 hundreds of objects) but really improves computation time on large grids (tested on 4 cores with 3500 objects -> computation time improved by a factor 3.6).

As I use your package for grids anamorphosis, the faster the better ;-)
S.

… large maps or grids

Added @param documentation line for parallel option
Contributor information added in DESCRIPTION. New parallel feature added in NEWS.
@sjewo
Copy link
Owner

sjewo commented Sep 6, 2021

Hi @spiry34 ! Thanks for your contribution and pull request!
I'm just back from holidays and quite busy at the moment, but I'll try to take a look into your code in the next days!

@spiry34
Copy link
Author

spiry34 commented Sep 6, 2021

Hello @sjewo,
Don't worry, I'm working on a C++ function for the core process; I'll post another pull-request when finished.
And I'm also going to enjoy 2 weeks of holidays, so ... see you soon!
S.

Improved parallel efficiency by using batches of polygons
'parallel' option can be set to a numeric value in order to set the number of cores used
@spiry34
Copy link
Author

spiry34 commented Sep 21, 2021

Hello @sjewo ,
I found some time to add my new functionalities in cartogram.
Big changes ahead :-)
Note: In order to build the package I used the following commands:

usethis::use_rcpp()
pkgbuild::check_build_tools(debug = TRUE)
devtools::document()
devtools::build()

If you find some weird stuff, I'll do my best to explain or correct.
Enjoy!
All the best,
S.

@sjewo
Copy link
Owner

sjewo commented Sep 21, 2021

Hey @spiry34,

thanks for the update!

I'll start to add some tests for the current implementation, so I can test your code thoroughly :)

@richardneilbelcher
Copy link

Just to say that using this update seems to shorten the run time for each iteration when using one core. However, I am getting the following error when I try I set parallel = TRUE

Error in data.frame(id = 1:length(x.sp@polygons)) :object 'x.sp' not found

I have tried using both sf and SpatialPolygonsDataFrame objects. It looks like x.sp isnt defined until line 252 but the data.frame is being made on line 192

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

Successfully merging this pull request may close these issues.

3 participants