stocnet / goldfish

Actor-oriented and tie-based network event models in R
https://stocnet.github.io/goldfish/
GNU General Public License v3.0
61 stars 13 forks source link

C++ engines bug when no updates #38

Closed auzaheta closed 2 years ago

auzaheta commented 3 years ago

Describe the bug Any of the C++ engines through an error during data transformation of R objects to plain arrays due to the absences of updates on the network statistics.

To Reproduce

# # observed relational events
eventsMM <- data.frame(
  time = cumsum(
    c(1, 5, 3, 4, 2)),
  sender = sprintf(
    "Actor %d", 
    c(1, 3, 2, 2, 5)),
  receiver = sprintf(
    "Actor %d", 
    c(2, 2, 3, 3, 1)),
  increment =
    c(1, 2, 1, 1, 1),
  stringsAsFactors = FALSE
)
# # actors attributes
actorsMM <- data.frame(
  label = sprintf("Actor %d", 1:5),
  present = rep(TRUE, 5),
  attr1 = c(9.9, 0.1, 0.5, 0.45, 0.25),
  stringsAsFactors = FALSE
)

# # state at the beginning of the network
networkMM <- matrix(
  c(0, 3, 0, 0, 0,
    3, 0, 1, 1, 0,
    0, 1, 0, 1, 0,
    0, 1, 1, 0, 0,
    0, 0, 0, 0, 0), 
  nrow = 5, ncol = 5, byrow = TRUE,
  dimnames = list(sprintf("Actor %d", 1:5),
                  sprintf("Actor %d", 1:5))
)
# defining objects
networkMM <- defineNetwork(
  matrix = networkMM, nodes = actorsMM,
  directed = FALSE)
networkMM <- linkEvents(
  x = networkMM,
  changeEvent = eventsMM,
  nodes = actorsMM)
depNetMM <- defineDependentEvents(
  events = eventsMM,
  nodes = actorsMM,
  defaultNetwork = networkMM)
# model
mod01 <- estimate(depNetMM ~ inertia + trans,
                  model = "DyNAM", subModel = "choice_coordination",
                  estimationInit = list(engine = "default_c"))
Parsing formula.
Initializing objects.
Starting preprocessing.
Initializing cache objects and statistical matrices.
Preprocessing events.
  |**********************************************************************************************************************************| 100%
Estimating a model: “DyNAM”, subModel: “choice_coordination”.

error: Mat::cols(): indices out of bounds or incorrectly used
 Error: Error in DyNAM choice_coordination estimation: Error in convert_change(statsList$dependentStatsChange): Mat::cols(): indices out of bounds or incorrectly used 

Desktop (please complete the following information):

auzaheta commented 2 years ago

PR 1.6.2 includes f5d0d6d commit solving it.