MaC-Perez / Hydra-self-testing

0 stars 0 forks source link

.tpl #2

Closed MaC-Perez closed 1 year ago

MaC-Perez commented 1 year ago

Hi @gavinfay I am trying to run the model with the new dat files that Sarah sent me but I get an error when I run the .tpl file (I took the .tpl file from the hydra_sim folder) maybe I am not using the correct version.

The tpl dat and pin files are in the folder Hydra_self_testing --> input

hydra_sim.cpp: In member function 'void model_parameters::evaluate_the_objective_function()': hydra_sim.cpp:1812:34: error: 'isinf' was not declared in this scope if(isinf(value(sum(nll_survey)))) { ^ hydra_sim.cpp:1812:34: note: suggested alternative: In file included from hydra_sim.cpp:4:0: c:/gnu/GCC492-win64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/cmath:828:5: note: 'std::isinf' isinf(_Tp __f) ^

gavinfay commented 1 year ago

I'm guessing that "run the tpl" means compiling the program? i.e. the error you show is the output from admb hydra_sim

Works for me. Suspect this is an issue of not having admb and compilers linked properly. Are you able to compile the simple example? Are you able to compile a basic c++ program? What version of ADMB are you using? (am running on 12.3)

MaC-Perez commented 1 year ago

Hi @gavinfay I checked my admb with other examples and it is working. I also tried to compile the hydra_sim.tpl file in a different computer and I got the same error

hydra_sim.cpp:1812:34: error: 'isinf' was not declared in this scope if(isinf(value(sum(nll_survey)))) { ^

MaC-Perez commented 1 year ago

@gavinfay it is working now.... I just commented the lines ...

//if(isinf(value(sum(nll_survey)))) { // cout << " INFINITE OBJ FUN" << endl; // gavjunk << survey_q << endl; // gavjunk << ln_survey_q << endl; // gavjunk << "survey biomass data, predicted, residual, nll" << endl; //for (int i=1;i<=Nsurvey_obs;i++) // gavjunk << obs_survey_biomass(i) << " " << pred_survey_index(i) << " " << resid_survey(i) << " " << nll_survey(i) << endl; //exit(-1); //}

That doesn't interfere with the rest of the code right?

gavinfay commented 1 year ago

I think this almost certainly suggests that your installation is not linked properly. Whether it is your ADMB or your C++ compiler is probably not Basically your installation can't find the required header file. You'll need to ensure you are pointing to your cmath.h so I would start by looking at the definition for the various environmental variables and also seeing where cmath.h is located on your machine. Note that if the examples you have tried don't use things from the cmath header file (which is where isinf() is located) then you won't pick up on this through that. Which versions of ADMB & C++ are you using? When did you last run Hydra on these machines? Have you changed C++ compilers or environmental variables to install other software?

gavinfay commented 1 year ago

Don't edit the .cpp file. If you want to make this change, do it in the relevant part of the .tpl file. Otherwise you will have to repeat this step again and again each time you recompile.

MaC-Perez commented 1 year ago

@gavinfay I changed the tpl file not the cpp

MaC-Perez commented 1 year ago

I was using and older version of the .tpl file and the difference between both was exactly what you mentioned "cmath.h" in line 55

MaC-Perez commented 1 year ago

mmmm I think I change some things the day we try to install docker desktop for the MEBM class.... my admb was working properly before that day.

gavinfay commented 1 year ago

Glad you were able to resolve. My advice towards mitigating the problem of using an older version of a file is to only have the one version on your computer (rely on the version control system we have set up with Git and GitHub). e.g. for the hydra_sim.tpl, there's no need to have this outside of the location on your computer where the hydra-sim repository resides.

MaC-Perez commented 1 year ago

@gavinfay well I didn't fix it I just delete those lines, but I am not sure if that interfere with the rest of the code... I think it does because even when I manage to compile it I am having more issues when I try to run it.

my cmath file is in C:\ADMB-12.3\utilities\mingw64\include\c++\8.3.0

these are the lines I deleted // cmath.h

//if(isinf(value(sum(nll_survey)))) { // cout << " INFINITE OBJ FUN" << endl; // gavjunk << survey_q << endl; // gavjunk << ln_survey_q << endl; // gavjunk << "survey biomass data, predicted, residual, nll" << endl; //for (int i=1;i<=Nsurvey_obs;i++) // gavjunk << obs_survey_biomass(i) << " " << pred_survey_index(i) << " " << resid_survey(i) << " " << nll_survey(i) << endl; //exit(-1); //}

MaC-Perez commented 1 year ago

@gavinfay I asked Sarah if she was able to run the model with the hydra_sim_GBself_5bin input files but she is also getting an error when she try to compile it. Also she mentioned there is 3 more phase variables that need to be added to the .dat file after line 258 that have been added since she made the input files:

init_int m1_phase // M1 phase

-1

init_int oF1_phase // amount of other food included in the M2 term for the base (predator 1) phase

-1

init_int oFdev_phase //deviation from base other food for predators 2+ phase

-1

I am not tagging her here because she is really busy finishing some reports.

gavinfay commented 1 year ago

Yep. See hydra_sim commit #fe36d04 These are changes you can easily make and are only associated with the pin and dat files (so don't need to be incorporated into the generation of the simulated ts.dat files).

MaC-Perez commented 1 year ago

thanks @gavinfay ... I changed both files but I get this

q par map -2 0 0 matrix bound exceeded -- row index too low in imatrix::operator[]value was-1

sgaichas commented 1 year ago

I got the same thing with my executable. This may be a problem with the 4 species data input but I won't be able to diagnose until next week, apologies

gavinfay commented 1 year ago

Doesn't look like your dat file matches the correct format, because it is thinking there should be -2 catchability parameters. Cross-check you have a complete data file with the working examples in the hydra_sim GB-inputs folder. (e.g. hydra_sim_GB_5bin_1978_inpN_noM1.dat)

gavinfay commented 1 year ago

The dat file still has the M1 and other food inputs (these are moved to the pin file). Comment out these lines in the dat file and that does the trick.

MaC-Perez commented 1 year ago

I got the same thing with my executable. This may be a problem with the 4 species data input but I won't be able to diagnose until next week, apologies

sure, do not worry Sarah I appreciate that you tried to run it. Thanks!!

MaC-Perez commented 1 year ago

@gavinfay I checked my .dat files with those in the GB-inputs folder, I also I tried several different things but I keep getting the same error. I left the files that I am using in the "model" folder. I do not want to change the original files until I am sure everything works.

q par map -2 0 0

gavinfay commented 1 year ago

@MaC-Perez You haven't commented out the M1 and OtherFood entries. As mentioned above, this fixes your problem.

MaC-Perez commented 1 year ago

@gavinfay sorry, I didn't see that comment. It finally worked

Thanks again!