Error in file when running Maxent in biomod2

111 Views Asked by At

When I run Maxent in biomod2, I meet the error, although I have tried many solutions which people have solved their similar problem, but they didn't work with my code. I have tried to change the file path of maxent.jar without any spaces or change the system environmental variables(following:http://modata.ceoe.udel.edu/dev/dhaulsee/class_rcode/r_pkgmanuals/MAXENT4R_directions.pdf), but they don't help me for my trouble.

this is my code and parameters #######################Defining Models Options using default options sdm.opt.default = BIOMOD_ModelingOptions( MAXENT = list( path_to_maxent.jar = "F:/1_SDM/maxent.jar"))

  `####################Constrcut sdm models by setting parameters
   Bio.mod.all = BIOMOD_Modeling( bm.format = Sp.biomod.data,
                             models = "MAXENT",
                             models.pa = [email protected],
                             bm.options = sdm.opt.default,
                             CV.strategy = 'random',
                             #Number of Evaluation run
                             CV.nb.rep = 1,
                             #80% of data train the model
                             CV.perc = 0.8,
                             #models  be  calibrated and validated over the whole dataset
                             CV.do.full.models = F,
                             #Below arg is whether control the weight?
                             weights=NULL,
                             #absences will be weighted equally to the presences
                             prevalence = 0.5,
                             #Set model evaluations methods
                             metric.eval = mode.eva,
                             #Number of permutation to estimate variable importance
                             var.import = 1,
                             nb.cpu =1,
                             do.progress =T)`

this the errors: Model=MAXENT > MAXENT modeling... Creating Maxent Temp Proj Data... Getting predictions...Error in file(file, "rt") : cannot open the connection Getting predictor contributions...Error in file(fname, "r") : cannot open the connection Error in { : task 1 failed - "Unable to make model prediction"

If anyone could help me treat the problem, I will great grateful!!!!

1

There are 1 best solutions below

0
m10 On

When the error report "cannot open the connection" is because the file cannot be found. Here are some solutions you can try:

  1. put double "\" in the path to maxent.jar
  2. put the maxent.jar in your working directory
  3. change the path to maxent.jar with something with no numbers or strange characters

In my case I've solved by putting the following instruction:

path_to_maxent.jar = paste(system.file(package="dismo"), "/java", sep='')

hope it will help!