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

Allow colleges to have different numbers of slots #31

Merged
merged 17 commits into from Nov 28, 2015
Merged

Conversation

jtilly
Copy link
Owner

@jtilly jtilly commented Nov 28, 2015

Addresses #30

In galeShapley.collegeAdmissions, slots can now be either a scalar or a vector with length equal to the number of colleges. The function returns the usual list of results res. res$matched.colleges is the a matrix of dimension number of colleges by number of slots when all colleges have the same slot size. res$matched.colleges is a list when colleges can have different numbers of slots.

To-Do:

  • Testing (+ write unit tests)
  • Validate inputs
  • Documentation

@jtilly jtilly added the feature label Nov 28, 2015
@njanetos
Copy link
Collaborator

What do you mean when you put 'validate inputs' on your todo list? The existing function to validate inputs should work just as well.

@jtilly
Copy link
Owner Author

jtilly commented Nov 28, 2015

Just need to check that slots has the right size.

@p2004r
Copy link

p2004r commented Nov 28, 2015

There was only one error with unmatched.colleges

Example from vignets https://cran.r-project.org/web/packages/matchingR/vignettes/matchingR-intro.html

results <- galeShapley.collegeAdmissions(studentUtils = uStudents, collegeUtils = uColleges, slots = 1:400)
str(results)
List of 4
$ unmatched.students: num(0)
$ unmatched.colleges: int [1:79200] 4 4 5 5 6 6 6 6 6 6 ...
$ matched.colleges :List of 400

@jtilly
Copy link
Owner Author

jtilly commented Nov 28, 2015

I think I fixed that in 037fe0c. Current version seems to work (better).

@p2004r
Copy link

p2004r commented Nov 28, 2015

First of all, thank you very much!

I just reinstalled the package (Maybe I'm not taking correct release?), but this small error in the output still remains.
[pre]

install_github("jtilly/matchingR", ref="feature/slots")
Downloading github repo jtilly/matchingR@feature/slots
Installing matchingR
'/usr/lib/R/bin/R' --vanilla CMD INSTALL
'/tmp/Rtmp2hnQJ6/devtools72277ef1f4b9/jtilly-matchingR-afb929e'
--library='/usr/local/lib/R/site-library' --install-tests

  • installing source package ‘matchingR’ ...
    ** libs
    g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -I../inst/include -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
    g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -I../inst/include -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c galeshapley.cpp -o galeshapley.o
    g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -I../inst/include -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c roommate.cpp -o roommate.o
    g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -I../inst/include -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c toptradingcycle.cpp -o toptradingcycle.o
    g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -I../inst/include -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c utils.cpp -o utils.o
    g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o matchingR.so RcppExports.o galeshapley.o roommate.o toptradingcycle.o utils.o -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
    installing to /usr/local/lib/R/site-library/matchingR/libs
    ** R
    ** inst
    ** tests
    ** preparing package for lazy loading
    ** help
    *** installing help indices
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded
  • DONE (matchingR)
    Reloading installed matchingR
    results = galeShapley.collegeAdmissions(studentUtils = uStudents, collegeUtils = uColleges, slots = 1:400)
    str(results)
    List of 4
    $ unmatched.students: num(0)
    $ unmatched.colleges: int [1:79200] 4 4 5 5 6 6 6 6 6 6 ...
    $ matched.colleges :List of 400

It can be easy to get around

unique(results$unmatched.colleges)
[1] 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
[19] 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
[37] 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
[55] 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
[73] 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
[91] 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
[109] 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
[127] 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
[145] 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
[163] 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
[181] 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
[199] 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
[217] 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
[235] 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
[253] 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
[271] 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
[289] 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
[307] 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
[325] 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
[343] 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
[361] 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
[379] 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
[397] 400

@jtilly
Copy link
Owner Author

jtilly commented Nov 28, 2015

Okay, now I see what's going on. In your case, you have slots = 1:400. That means that the first college has 1 slot, the second college has 2 slots, ... That's a lot of slots. And there are only 1000 students.

From the documentation: unmatched.colleges is a vector that lists colleges with open slots. If a college has multiple open slots, it will show up multiple times.

@jtilly jtilly closed this Nov 28, 2015
@jtilly jtilly reopened this Nov 28, 2015
jtilly added a commit that referenced this pull request Nov 28, 2015
Allow colleges to have different numbers of slots
@jtilly jtilly merged commit d2e8093 into master Nov 28, 2015
@jtilly jtilly deleted the feature/slots branch June 20, 2021 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants