Open Clzuy opened 5 days ago
@Clzuy I'm able to run the optimization. Some important points:
1) get the latest version of the package from github "remotes::install_github("femiguez/apsimx")" 2) Make sure that you use relative paths for your met file (there is code you do not need to run) 3) Do not try to optimize too many parameters. I do not know which parameters are the best to optimize in your case. I do not use the sugarcane model. This is not even a "rule-of-thumb", but optimize one parameter per variable. In your case, you measured three variables and I selected three parameters from your list. Again, I do not know if these are "good" parameters to try to optimize
@femiguez Thank you for your answer. I have tried, and it's not an issue with other modules. For example, I can successfully modify parameters for wheat or maize, but the sugarcane parameters cannot be modified. These parameters were determined after reviewing literature and conducting sensitivity analysis. I performed the sensitivity analysis by creating cultivars using the rapsiming package, but the parameter optimization is not implemented through creating cultivars. The definition of sugarcane parameters differs from other crops in that they don't have the '.FixedValue' suffix, as shown in the image. I have seen that people have optimized these parameters based on APSIM classic.
Thank you for taking the time to answer despite your busy schedule. I appreciate it. Best regards, Zongheng Li
Which version of the apsimx package are you running?
packageVersion("apsimx")
Which version of the apsimx package are you running?您运行的是哪个版本的 apsimx 软件包?
packageVersion("apsimx") packageVersion(“apsimx”)
package ‘apsimx’ version 2.8.206
I'm attaching your script with minor edits. The code runs, but it's possible that it might need a minor tweak to give best results. optSugar_fem.R.zip
In R you need to set your current directory maybe?
setwd("H:/Drought/lzhAPSIMfile")
place that line at the top of your script. All the relevant files should be in that folder. I'm making some changes to the script. I'll send you another version.
In R you need to set your current directory maybe?在 R 中,您需要设置当前目录,也许?
setwd("H:/Drought/lzhAPSIMfile")setwd(“H:/Drought/lzhAPSIMfile”)
place that line at the top of your script. All the relevant files should be in that folder. I'm making some changes to the script. I'll send you another version.将该行放在脚本的顶部。所有相关文件都应位于该文件夹中。我正在对脚本进行一些更改。我会给你发另一个版本。 Yes, I just discovered this issue, so I set the src.dir. You are really patient! Thank you, I might have to debug this tomorrow, it's already midnight. Thank you very much, have a wonderful day!
@femiguez Thank you very much for the code you provided. I tried running it today, and it worked very smoothly. The reason it didn't run properly before was probably because I passed in pp2 <- "Sugarcane.Cultivars.clzuy.sucrose_fraction_stalk", which is a vector.
But I still want to modify this parameter, so I modified the code as follows:
pp1 <- "Sugarcane.Cultivars.clzuy.cane_fraction" pp2 <- "Sugarcane.Cultivars.clzuy.sucrose_fraction_stalk" wop.h <- optim_apsimx("sugarRuan1004Opt.apsimx", parm.paths = c(pp1, pp2), data = obsSugar, weights = "mean", replacement = c(TRUE, TRUE), initial.values = c(0.7, 0.61), root = list("Models.Core.Folder", 1), parm.vector.index = c(0, 2), hessian = TRUE, control = list(trace = 2L)) I found an error in the code. System.Exception: Error in file:H:\Drought\APSIM\Optimi Analysis\FemR\sugarRuan1004Opt.apsimx ---> System.Exception: Error reading file H:\Drought\APSIM\Optimi Analysis\FemR\sugarRuan1004Opt.apsimx ---> Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: [. Path 'Children[0].Children[0].Children[0].Children[36].Command[2]', line 896, position 21. I opened the apsimx file and saw that it became like the picture below.
Is there a problem with the vector position I specified? Best regards, Zongheng Li
Dear Author,
I followed the parameter optimization example provided at https://femiguez.github.io/apsimx-docs/optim-apsim.html#optim_apsim to optimize parameters for the sugarcane crop, but I encountered some issues during the optimization process.
Initially, when using the default sugarcane type q138 provided by the system, I encountered the following error: