samthiriot / gosp.dpp

the direct probabilistic pairing method for generation of synthetic populations
GNU General Public License v2.0
1 stars 0 forks source link

solving fails on some system with a "subscript error" #32

Closed samthiriot closed 6 years ago

samthiriot commented 6 years ago

When testing on Debian Linux, R-release, an error is raised

* checking tests ...
  Running ‘testthat.R’
 ERROR
Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
         gamma = 0, delta.B = 1, phi.B = 1, nu.B = 1, verbose = FALSE) at testthat/test_basic1.R:389
  2: resolve(sol, case, nA, nB, nu.A, phi.A, delta.A, nu.B, phi.B, delta.B, gamma, verbose = verbose)
  3: resolve.missing.chain(sol.tmp, chain, case, nA, nB, nu.A, phi.A, delta.A, nu.B, phi.B, 
         delta.B, gamma, verbose = verbose)

  ══ testthat results  ═══════════════════════════════════════════════════════════
  OK: 632 SKIPPED: 2 FAILED: 5
  1. Error: constraints: nA, phi.A, phi.B (@test_basic1.R#85) 
  2. Error: constraints: phi.A, delta.A (free on matching and B) (@test_basic1.R#167) 
  3. Error: constraints: phi.A, gamma (free on A and B) (@test_basic1.R#188) 
  4. Error: constraints: nothing (totally free - long chain) (@test_basic1.R#305) 
  5. Error: constraints: pdi with zero (p(di=0)=1.0) (@test_basic1.R#389) 

  Error: testthat unit tests failed
  Execution halted
samthiriot commented 6 years ago

Error context:

> library(testthat)
> library(gosp.dpp)
> 
> test_check("gosp.dpp")

starting the resolution of the case
    according to user weights, we already know: hat.nA,hat.fi,hat.fj
    checking the consistency of the current solution with hat.nA,hat.fi,hat.fj
    => the solution is consistent
    solving equations based on known variables: hat.nA,hat.fi,hat.fj
        hat.nA, hat.fi -> hat.ci
    starting the investigation of the missing chain: hat.di,hat.pij,hat.dj
        will test 7 hypothesis
        trying with hypothesis: hat.di=di
            solving equations based on known variables: hat.nA,hat.fi,hat.fj,hat.ci,hat.di
                hat.ci, hat.di -> hat.ni
                hat.ni -> hat.nL
                hat.ni -> hat.nij, hat.pij
                hat.nij -> hat.nj
                hat.pij -> hat.pi
                hat.pij -> hat.pj
                hat.pj, hat.fj -> hat.dj
                hat.di -> hat.pdi
                hat.dj -> hat.pdj
                    unable to update hat.pdj to fit hat.dj=0.622364469795453,0.895299759849167,0.861210533205464,1
            found an invalid solution.
        trying with hypothesis: hat.pij=pij
            solving equations based on known variables: hat.nA,hat.fi,hat.fj,hat.ci,hat.pij
                hat.pij -> hat.pi
                hat.pij -> hat.pj
                hat.pi, hat.fi -> hat.di
                hat.pj, hat.fj -> hat.dj
                hat.di -> hat.pdi
                hat.dj -> hat.pdj
                    unable to update hat.pdj to fit hat.dj=0.812681579154931,1,0.857344168555347,0.923097870582232
            found an invalid solution.
        trying with hypothesis: hat.dj=dj
            solving equations based on known variables: hat.nA,hat.fi,hat.fj,hat.ci,hat.dj
                hat.fj, hat.dj -> hat.pj
                hat.pj -> hat.pij
                hat.dj -> hat.pdj
                hat.pij -> hat.pi
                hat.pi, hat.fi -> hat.di
                hat.di -> hat.pdi
                hat.ci, hat.di -> hat.ni
                hat.ni -> hat.nL
                hat.ni -> hat.nij, hat.pij
                hat.nij -> hat.nj
                hat.nj, hat.dj -> hat.cj
                hat.pdi, hat.ci -> hat.ndi
                hat.pdj, hat.cj -> hat.ndj
                hat.cj -> hat.nB
            checking the consistency of the current solution with hat.nA,hat.fi,hat.fj,hat.ci,hat.dj,hat.pij,hat.di,hat.cj,hat.nB
            => the solution is consistent
            we found a valid solution which provides:  hat.nA,hat.fi,hat.fj,hat.ci,hat.dj,hat.pij,hat.di,hat.cj,hat.nB 
        trying with hypothesis: hat.di=di,hat.pij=pij
            solving equations based on known variables: hat.nA,hat.fi,hat.fj,hat.ci,hat.di,hat.pij
                hat.ci, hat.di -> hat.ni
                hat.ni -> hat.nL
                hat.ni -> hat.nij, hat.pij
                hat.nij -> hat.nj
                hat.pij -> hat.pi
                hat.pij -> hat.pj
                hat.pj, hat.fj -> hat.dj
                hat.di -> hat.pdi
                hat.dj -> hat.pdj
                    unable to update hat.pdj to fit hat.dj=0.622364469795453,0.895299759849167,0.861210533205464,1
            found an invalid solution.
        trying with hypothesis: hat.di=di,hat.dj=dj
            solving equations based on known variables: hat.nA,hat.fi,hat.fj,hat.ci,hat.di,hat.dj
                hat.ci, hat.di -> hat.ni
                hat.ni -> hat.nL
                hat.ni -> hat.nij, hat.pij
                hat.nij -> hat.nj
                hat.nj, hat.dj -> hat.cj
                hat.pij -> hat.pi
                hat.pij -> hat.pj
                hat.di -> hat.pdi
                hat.dj -> hat.pdj
                hat.cj -> hat.nB
                hat.pdi, hat.ci -> hat.ndi
                hat.pdj, hat.cj -> hat.ndj
            checking the consistency of the current solution with hat.nA,hat.fi,hat.fj,hat.ci,hat.di,hat.dj,hat.pij,hat.cj,hat.nB
            => the solution is consistent
            we found a valid solution which provides:  hat.nA,hat.fi,hat.fj,hat.ci,hat.di,hat.dj,hat.pij,hat.cj,hat.nB 
        trying with hypothesis: hat.pij=pij,hat.dj=dj
            solving equations based on known variables: hat.nA,hat.fi,hat.fj,hat.ci,hat.pij,hat.dj
                hat.pij -> hat.pi
                hat.pij -> hat.pj
                hat.pi, hat.fi -> hat.di
                hat.di -> hat.pdi
                hat.dj -> hat.pdj
                hat.ci, hat.di -> hat.ni
                hat.ni -> hat.nL
                hat.ni -> hat.nij, hat.pij
                hat.nij -> hat.nj
                hat.nj, hat.dj -> hat.cj
                hat.pdi, hat.ci -> hat.ndi
                hat.pdj, hat.cj -> hat.ndj
                hat.cj -> hat.nB
            checking the consistency of the current solution with hat.nA,hat.fi,hat.fj,hat.ci,hat.pij,hat.dj,hat.di,hat.cj,hat.nB
            => the solution is consistent
            we found a valid solution which provides:  hat.nA,hat.fi,hat.fj,hat.ci,hat.pij,hat.dj,hat.di,hat.cj,hat.nB 
        trying with hypothesis: hat.di=di,hat.pij=pij,hat.dj=dj
            solving equations based on known variables: hat.nA,hat.fi,hat.fj,hat.ci,hat.di,hat.pij,hat.dj
                hat.ci, hat.di -> hat.ni
                hat.ni -> hat.nL
                hat.ni -> hat.nij, hat.pij
                hat.nij -> hat.nj
                hat.nj, hat.dj -> hat.cj
                hat.pij -> hat.pi
                hat.pij -> hat.pj
                hat.di -> hat.pdi
                hat.dj -> hat.pdj
                hat.cj -> hat.nB
                hat.pdi, hat.ci -> hat.ndi
                hat.pdj, hat.cj -> hat.ndj
            checking the consistency of the current solution with hat.nA,hat.fi,hat.fj,hat.ci,hat.di,hat.pij,hat.dj,hat.cj,hat.nB
            => the solution is consistent
            we found a valid solution which provides:  hat.nA,hat.fi,hat.fj,hat.ci,hat.di,hat.pij,hat.dj,hat.cj,hat.nB 
        found  4  solutions, we have to select the best according to weights
            solution ( 1 ) => NA 0 0 0 
            solution ( 2 ) => NA NA 0 0 
            solution ( 3 ) => NA NA NA 0 
            solution ( 4 ) => NA NA NA NA 
── 1. Error: constraints: nA, phi.A, phi.B (@test_basic1.R#85)  ────────────────
subscript out of bounds
1: matching.solve(prepared, nA = 50000, nB = 40000, nu.A = 0, phi.A = 0, delta.A = 1, 
       gamma = 1, delta.B = 1, phi.B = 0, nu.B = 1, verbose = TRUE) at testthat/test_basic1.R:85
2: resolve(sol, case, nA, nB, nu.A, phi.A, delta.A, nu.B, phi.B, delta.B, gamma, verbose = verbose)
3: resolve.missing.chain(sol.tmp, chain, case, nA, nB, nu.A, phi.A, delta.A, nu.B, phi.B, 
       delta.B, gamma, verbose = verbose)
samthiriot commented 6 years ago

seems due to a problem in the mean() function in older versions of R


    => the solution is consistent
            we found a valid solution which provides:  hat.nA,hat.fi,hat.fj,hat.ci,hat.di,hat.dj,hat.pij,hat.cj,hat.nB 
[1] "computing the NRMSE of pij, for hat.pij="
        surface=1  surface=2  surface=3
size=1 0.14871773 0.04005239 0.01550551
size=2 0.07435887 0.13346571 0.03098990
size=3 0.03717943 0.10676412 0.12400186
size=4 0.01858972 0.05338206 0.21699269
[1] "original being"
       surface=1 surface=2 surface=3
size=1     0.200    0.0375    0.0125
size=2     0.100    0.1250    0.0250
size=3     0.050    0.1000    0.1000
size=4     0.025    0.0500    0.1750
[1] "difference is "
          surface=1   surface=2   surface=3
size=1 -0.051282268 0.002552389 0.003005514
size=2 -0.025641134 0.008465715 0.005989902
size=3 -0.012820567 0.006764122 0.024001859
size=4 -0.006410283 0.003382061 0.041992691
[1] "square is"
          surface=1    surface=2    surface=3
size=1 2.629871e-03 6.514691e-06 9.033112e-06
size=2 6.574678e-04 7.166832e-05 3.587893e-05
size=3 1.643669e-04 4.575334e-05 5.760892e-04
size=4 4.109173e-05 1.143834e-05 1.763386e-03
[1] "so mean is "
[1] NA
[1] "and thus"
[1] NA