Closed guillemodon closed 6 months ago
@guillemodon I need to add a check for 'tibbles' since they are not compatible with other functions. Can you try the following? And use the object 'OBSdf' in the optimization
OBSdf <- as.data.frame(OBS)
Hello Fernando, thank you very much for your response. I get that OBSdf is not a valid tibble, and the following error message: Number of rows in data 9 Number of rows in subset simulation 0 Error in obj_fun(cfs = rep(1, length(parm.paths)), parm.paths = parm.paths, : Number of rows in data does not equal number of rows in simulation
Thanks
Modifique el dataframe OBS con la funcion tibble, peor aun asi sigo recibiendo el mismo error Error in xtfrm.data.frame(x) : cannot xtfrm data frames
@guillemodon The problem is that the dates do not match. Maybe you should change the observed yield dates to match the dates in the simulation. Also, optimizing RUE is not a good idea if all you have is yield. I would first make sure the model is set up correctly
Muchas gracias por la respuesta Fernando, respecto a la RUE tenes razón pero no es un problema ya que solamente estoy explorando como funciona optim_apsimx. Me parece extraño que no coincida cuando son exactamente las mismas. Seguiré intentando
@guillemodon Las fechas simuladas y observadas no coinciden
> data.frame(obs.date = OBSdf$Date, simulated.date = sim0$Date)
obs.date simulated.date
1 2014-02-06 12:00:00 2014-02-10 12:00:00
2 2015-02-07 12:00:00 2015-02-20 12:00:00
3 2016-02-10 12:00:00 2016-02-13 12:00:00
4 2017-02-09 12:00:00 2017-02-14 12:00:00
5 2018-02-07 12:00:00 2018-02-16 12:00:00
6 2019-02-08 12:00:00 2019-02-17 12:00:00
7 2020-02-08 12:00:00 2020-02-16 12:00:00
8 2021-02-10 12:00:00 2021-02-07 12:00:00
9 2022-02-04 12:00:00 2022-02-06 12:00:00
Por eso recibias el error "Number of rows in data does not equal number of rows in simulation". La forma más sencilla de corregir esto es cambiar las fechas observadas para que coincidan con las simuladas
I'm closing this. open a new issue if needed
Hello again
I am having problems being able to successfully use the optim_apsim function, I apply it this way:
wop <- optim_apsimx("OPT1.apsimx", src.dir = "C:/Users/54343/Desktop/OPT", parm.paths = c(pp3, pp4), data = OBS, weights = "mean", replacement = c(TRUE, TRUE), initial.values = c(2, 700), root = list("Models.Core.Folder", 1))
and I get this error message:
Error in xtfrm.data.frame(x) : cannot xtfrm data frames traceback() 11: stop("cannot xtfrm data frames") 10: xtfrm.data.frame(x) 9: xtfrm(x) 8: as.vector(xtfrm(x)) 7: FUN(X[[i]], ...) 6: lapply(z, function(x) if (is.object(x)) as.vector(xtfrm(x)) else x) 5: order(data[, index[1]]) 4:
[.tbl_df
(data, order(data[, index[1]]), ) 3: data[order(data[, index[1]]), ] 2: obj_fun(cfs = rep(1, length(parm.paths)), parm.paths = parm.paths, data = data, iparms = iparms, weights = weights, index = index, parm.vector.index = parm.vector.index, replacement = replacement, root = root) 1: optim_apsimx("OPT1.apsimx", src.dir = "C:/Users/54343/Desktop/OPT", parm.paths = c(pp3, pp4), data = OBS, weights = "mean", index = "Date", replacement = c(TRUE, TRUE), initial.values = c(2, 700), root = list("Models.Core.Folder", NA))OPT - copia.zip
The dataframe that contains the observed data has the same structure as the simulation output report. Attached is the apsimx file.