Skip to content

Commit

Permalink
Issue #107: developing fixes...
Browse files Browse the repository at this point in the history
  • Loading branch information
johnoel committed Mar 3, 2023
1 parent c483bff commit 0c0940c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 142 deletions.
8 changes: 8 additions & 0 deletions tests/issue-107/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,11 @@ clean:
@rm -vf pella_t_modified2.p03
@rm -vf pella_t_modified2.par
@rm -vf pella_t_modified2.std
@rm -vf pella_t_modified.r01
@rm -vf pella_t_modified.r02
@rm -vf pella_t_modified.r03
@rm -vf pella_t_modified.rep
@rm -vf pella_t_modified2.r01
@rm -vf pella_t_modified2.r02
@rm -vf pella_t_modified2.r03
@rm -vf pella_t_modified2.rep
87 changes: 12 additions & 75 deletions tests/issue-107/changes
Original file line number Diff line number Diff line change
@@ -1,96 +1,33 @@
diff --git a/src/nh99/model.cpp b/src/nh99/model.cpp
index ed8cb5a7..513f9b99 100644
--- a/src/nh99/model.cpp
+++ b/src/nh99/model.cpp
@@ -864,8 +864,10 @@ void param_init_vector::allocate(
void param_init_bounded_vector::set_value(const dvar_vector& x,
const int& ii, const dvariable& pen)
{
+ cout << __FILE__ << ':' << __LINE__ << endl;
if (!(!(*this)))
{
+ cout << "A: " << value(*this) << endl;
if (initial_params::mc_phase)
{
set_value_mc(*this,x,ii,minb,maxb);
@@ -877,13 +879,17 @@ void param_init_bounded_vector::set_value(const dvar_vector& x,
else
::set_value(*this,x,ii,minb,maxb,pen,scalefactor);
}
+ cout << "B: " << value(*this) << endl;
+ cout << "B25: " << value(this->operator()(25)) << endl;
}
}

void param_init_bounded_vector::set_value_inv(const dvector& x, const int& ii)
{
+ cout << __FILE__ << ':' << __LINE__ << endl;
if (!(!(*this)))
{
+ cout << value(*this) << endl;
if (initial_params::mc_phase)
{
set_value_inv_mc(*this,x,ii,minb,maxb);
@@ -895,6 +901,7 @@ void param_init_bounded_vector::set_value(const dvar_vector& x,
else
::set_value_inv(*this,x,ii,minb,maxb,scalefactor);
}
+ cout << value(*this) << endl;
}
}

diff --git a/src/nh99/model5.cpp b/src/nh99/model5.cpp
index 18a38a11..de9992ac 100644
index 18a38a11..ae7177f9 100644
--- a/src/nh99/model5.cpp
+++ b/src/nh99/model5.cpp
@@ -9,6 +9,8 @@
void param_init_bounded_dev_vector::set_value(const dvar_vector& x,
const int& ii, const dvariable& _pen)
{
+ cout << __FILE__ << ':' << __LINE__ << endl;
+ cout << "A: " << value(*this) << endl;
dvariable& pen= (dvariable&) _pen;
if (initial_params::mc_phase)
{
@@ -18,10 +20,13 @@ void param_init_bounded_dev_vector::set_value(const dvar_vector& x,
@@ -18,10 +18,10 @@ void param_init_bounded_dev_vector::set_value(const dvar_vector& x,
{
::set_value(*this,x,ii,minb,maxb,pen);
}
+ cout << "B: " << value(*this) << endl;
dvariable s=mean(*this);
- dvariable s=mean(*this);
- pen+=10000.0*s*s;
+ //pen+=10000.0*s*s;
if (!initial_params::mc_phase)
{
+ dvariable s=mean(*this);
+ //pen+=10000.0*s*s;
(*this)-=s;
}
+ //cout << "C: " << value(*this) << endl;
+ cout << "B25: " << value(this->operator()(25)) << endl;
}
diff --git a/src/nh99/xmodelm3.cpp b/src/nh99/xmodelm3.cpp
index 2db14566..086cd517 100644
index 2db14566..7dc2f739 100644
--- a/src/nh99/xmodelm3.cpp
+++ b/src/nh99/xmodelm3.cpp
@@ -526,10 +526,14 @@ void tracing_message(int traceflag,const char *s);
print_is_diagnostics(lapprox);
}
initial_params::save();
+ cout << __FILE__ << ':' << __LINE__ << endl;
@@ -529,7 +529,10 @@ void tracing_message(int traceflag,const char *s);
report(g);
// in case the user changes some initial_params in the report section
// call reset again
+ cout << __FILE__ << ':' << __LINE__ << endl;
initial_params::reset(dvar_vector(x));
+ cout << __FILE__ << ':' << __LINE__ << endl;
+ report(g);
- initial_params::reset(dvar_vector(x));
+ if (initial_params::current_phase < initial_params::max_number_phases)
+ {
+ initial_params::reset(dvar_vector(x));
+ }
report_function_minimizer_stats();
if (quit_flag=='Q') break;
if (!quit_flag || quit_flag == 'N')
@@ -544,6 +548,7 @@ void tracing_message(int traceflag,const char *s);
initial_params::max_number_phases;
}
tracing_message(traceflag,"N2");
+ cout << __FILE__ << ':' << __LINE__ << endl;
}
void function_minimizer::set_multinomial_weights(dvector& d)
{
30 changes: 0 additions & 30 deletions tests/issue-107/pella_t_modified.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,6 @@ PROCEDURE_SECTION
cout << " MCeval: " << ++mceval_counter;
}

cout<< ++count
<< std::setprecision(40)
<<" phase: " << initial_params::current_phase
<<" mc_phase: " << initial_params::mc_phase
<<" obj_fun: "<<ff
<<" mean: " << mean(value(effort_devs))
<<" sum(effort_devs): "<<sum(effort_devs)<<endl;

if (count == 556)
{
cout <<" sum: " << sum(value(effort_devs)) << endl;
double result = 0;
for (int i = effort_devs.indexmin(); i <= effort_devs.indexmax(); ++i)
{
double v = value(effort_devs(i));
result += v;
cout << "i: " << i << std::setprecision(20) << " v: " << v <<" result: " << result << endl;
}
ad_exit(1);
}

FUNCTION calculate_fishing_mortality
// calculate the fishing mortality
f=q*effort;
Expand Down Expand Up @@ -176,12 +155,3 @@ FUNCTION calculate_the_objective_function
{
ff+=1000.*square(log(mean(f)/.4));
}
BETWEEN_PHASES_SECTION
cout << "between phase: " << initial_params::current_phase << endl;
if (initial_params::current_phase == 4)
{
cout << value(effort_devs) << endl;
//ad_exit(1);
}
REPORT_SECTION
cout << "Report: " << value(effort_devs) << endl;
40 changes: 3 additions & 37 deletions tests/issue-107/pella_t_modified2.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,12 @@ PRELIMINARY_CALCS_SECTION
PROCEDURE_SECTION
if (initial_params::current_phase >= 3)
{
cout << "A: " << value(effort_devs) << endl;
dvariable s = mean(effort_devs);
//ff += 10000.0 * s * s;
if (!initial_params::mc_phase)
{
dvariable s = mean(effort_devs);
//ff += 10000.0 * s * s;
effort_devs -= s;
}
cout << "B: " << value(effort_devs) << endl;
cout << "B25: " << value(effort_devs(25)) << endl;
}

// calculate the fishing mortality
Expand All @@ -83,27 +80,6 @@ PROCEDURE_SECTION
cout << " MCeval: " << ++mceval_counter;
}

cout<< ++count
<< std::setprecision(40)
<<" phase: " << initial_params::current_phase
<<" mc_phase: " << initial_params::mc_phase
<<" obj_fun: "<<ff
<<" mean: " << mean(value(effort_devs))
<<" sum(effort_devs): "<<sum(effort_devs)<<endl;

if (count == 556)
{
cout <<" sum: " << sum(value(effort_devs)) << endl;
double result = 0;
for (int i = effort_devs.indexmin(); i <= effort_devs.indexmax(); ++i)
{
double v = value(effort_devs(i));
result += v;
cout << "i: " << i << std::setprecision(20) << " v: " << v <<" result: " << result << endl;
}
ad_exit(1);
}

FUNCTION calculate_fishing_mortality
// calculate the fishing mortality
f=q*effort;
Expand Down Expand Up @@ -190,21 +166,11 @@ FUNCTION calculate_the_objective_function
ff+=1000.*square(log(mean(f)/.4));
}
BETWEEN_PHASES_SECTION
cout << "between phase: " << initial_params::current_phase << endl;
if (initial_params::current_phase == 4)
{
dvariable s = mean(effort_devs);
//ff += 10000.0 * s * s;
if (!initial_params::mc_phase)
{
double s = mean(value(effort_devs));
effort_devs -= s;
}

cout << value(effort_devs) << endl;

//double result = mean(value(effort_devs));
//effort_devs -= result;
//ad_exit(1);
}
REPORT_SECTION
cout << "Report: " << value(effort_devs) << endl;

0 comments on commit 0c0940c

Please sign in to comment.