<div dir="ltr">Working on this now...</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 16, 2014 at 8:13 AM, William Stockhausen - NOAA Federal <span dir="ltr"><<a href="mailto:william.stockhausen@noaa.gov" target="_blank">william.stockhausen@noaa.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Here's Dave's solution to my problem (for some reason he wasn't able to post to the developers list). His full solution is attached.<div>
<div class="h5"><div><br><div class="gmail_quote">---------- Forwarded message ----------<br>
From: <b class="gmail_sendername">dave fournier</b> <span dir="ltr"><<a href="mailto:davef@otter-rsch.com" target="_blank">davef@otter-rsch.com</a>></span><br>Date: Mon, Jun 16, 2014 at 10:00 AM<br>Subject: Re: [Developers] method set_initial_values(...) not working for param_init_number_vector<br>

To: William Stockhausen - NOAA Federal <<a href="mailto:william.stockhausen@noaa.gov" target="_blank">william.stockhausen@noaa.gov</a>>, developers <<a href="mailto:developers@admb-project.org" target="_blank">developers@admb-project.org</a>><br>

<br><br>
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div><div><br></div>
      It appears that this function was some duped code which was never
      finished properly.<br>
      I think it should look like this at the top of the file
      model48.cpp.<br>
      <br>
      There may also be other set_initial_value functions which were not
      finished.<br>
      <br>
       void param_init_bounded_number_vector::set_initial_value(const
      double_index_type& _it)<br>
       {<br>
         int mmin=indexmin();<br>
         int mmax=indexmax();<br>
         for (int i=mmin;i<=mmax;i++)<br>
         {<br>
           (*this)(i)=ad_double(_it(i));<br>
         }<br>
       }<br>
      <br>
      <br>
      <br>
      <br>
      On 06/16/2014 07:08 AM, William Stockhausen - NOAA Federal wrote:<br>
    </div>
    <blockquote type="cite"><div><div>
      <div dir="ltr">Hi developers,
        <div><br>
          <div> I'm running ADMB 11.1 on MacOSX and Windows 7. I'm
            trying to set the initial values for a
            param_init_number_vector (p, say) from a dvector (vls, say)
            in a function using the following:</div>
          <div><br>
          </div>
          <div>p.set_initial_value(vls);<br>
            <div><br>
            </div>
            <div>The actual function is:</div>
            <div><br>
            </div>
            <div>
              <div><font face="courier new, monospace">void
                  setInitVals(BoundedNumberVectorInfo* pI,
                  param_init_bounded_number_vector& p){</font></div>
              <div><span style="font-family:'courier new',monospace">   
                  int np = pI->getSize();</span><br>
              </div>
              <div><font face="courier new, monospace">    if (np){</font></div>
              <div><font face="courier new, monospace">        dvector
                  vls = pI->getInitVals();</font></div>
              <div><font face="courier new, monospace">       
                  p.set_initial_value(vls);</font></div>
              <div><span style="font-family:'courier new',monospace">   
                      cout<<"vls = "<<vls<<endl;</span><br>
              </div>
              <div><font face="courier new, monospace">       
                  cout<<"p   = "<<p<<endl;</font></div>
              <div><font face="courier new, monospace"> </font><span style="font-family:'courier new',monospace">    }</span></div>
              <div><font face="courier new, monospace">}</font></div>
            </div>
            <div><br>
            </div>
            <div>where pI is a pointer to an object whose method
              getInitVals() returns a dvector.</div>
            <div><br>
            </div>
            <div>Everything compiles fine, but when I run the code,  the
              initial values for p are not equal to vls (they're equal
              to the default initial values) after running setInits. </div>
            <div><br>
            </div>
            <div>Fortunately this caused my code to produce some really
              strange results so I realized there was a problem. Using
              the ADMB website, I tracked down the following:</div>
            <div> </div>
            <div>The 'set_initial_value' method for
              param_init_bounded_number_vector is defined in model45.cpp
              as</div>
            <div><br>
            </div>
            <div>
              <pre style="white-space:pre-wrap;font-family:monospace,fixed;font-size:9pt;border:1px solid rgb(214,229,196);padding:4px 6px;margin:4px 8px 4px 2px;overflow:auto;word-wrap:break-word;line-height:15px;color:rgb(0,0,0);background-color:rgb(252,253,251)">
00008 
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00009" style="color:rgb(103,140,61)"></a><a href="http://www.admb-project.org/documentation/api/classparam__init__bounded__vector__vector.html#ad696a4660a01ad50266fcbafa7d3beb7" style="color:rgb(70,101,162);text-decoration:none" target="_blank">00009</a> <span style="color:rgb(96,64,32)">void</span> <a href="http://www.admb-project.org/documentation/api/classparam__init__bounded__vector__vector.html#ad696a4660a01ad50266fcbafa7d3beb7" style="color:rgb(70,101,162);text-decoration:none" target="_blank">param_init_bounded_vector_vector::set_initial_value</a>(
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00010" style="color:rgb(103,140,61)"></a>00010   <span style="color:rgb(0,128,0)">const</span> <a href="http://www.admb-project.org/documentation/api/classdouble__index__type.html" title="Description not yet available." style="color:rgb(70,101,162);text-decoration:none" target="_blank">double_index_type</a>& _it)
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00011" style="color:rgb(103,140,61)"></a>00011  {
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00012" style="color:rgb(103,140,61)"></a>00012     <a href="http://www.admb-project.org/documentation/api/classparam__init__bounded__vector__vector.html#a106e1b4f5049a08386645afbb658384b" style="color:rgb(70,101,162);text-decoration:none" target="_blank">it</a>=<span style="color:rgb(0,128,0)">new</span> <a href="http://www.admb-project.org/documentation/api/classdouble__index__type.html" title="Description not yet available." style="color:rgb(70,101,162);text-decoration:none" target="_blank">double_index_type</a>(_it);
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00013" style="color:rgb(103,140,61)"></a>00013  }
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00014" style="color:rgb(103,140,61)"></a>00014 
</pre>
            </div>
            <div><br>
            </div>
            <div>and the conversion of a dvector to double_index_type is
              defined in doublind.cpp as</div>
            <div>
              <pre style="white-space:pre-wrap;font-family:monospace,fixed;font-size:9pt;border:1px solid rgb(214,229,196);padding:4px 6px;margin:4px 8px 4px 2px;overflow:auto;word-wrap:break-word;line-height:15px;color:rgb(0,0,0);background-color:rgb(252,253,251)">
00057 
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00062" style="color:rgb(103,140,61)"></a><a href="http://www.admb-project.org/documentation/api/classdouble__index__type.html#a70db7015028be71be42cbc4c37b59319" style="color:rgb(70,101,162);text-decoration:none" target="_blank">00062</a> <a href="http://www.admb-project.org/documentation/api/classdouble__index__type.html#a2265b2e72fbd497b8cd4d4688398957a" title="Description not yet available." style="color:rgb(70,101,162);text-decoration:none" target="_blank">double_index_type::double_index_type</a>(<span style="color:rgb(0,128,0)">const</span> <a href="http://www.admb-project.org/documentation/api/classdvector.html" title="Vector of double precision numbers." style="color:rgb(70,101,162);text-decoration:none" target="_blank">dvector</a>& x)
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00063" style="color:rgb(103,140,61)"></a>00063   {
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00064" style="color:rgb(103,140,61)"></a>00064     <a href="http://www.admb-project.org/documentation/api/classdouble__index__type.html#ad1bebc88ffff9232f7502f2c764ee3f2" style="color:rgb(70,101,162);text-decoration:none" target="_blank">p</a> = <span style="color:rgb(0,128,0)">new</span> <a href="http://www.admb-project.org/documentation/api/classdvector__index.html" title="Description not yet available." style="color:rgb(70,101,162);text-decoration:none" target="_blank">dvector_index</a>((<span style="color:rgb(0,128,0)">const</span> <a href="http://www.admb-project.org/documentation/api/classdvector.html" title="Vector of double precision numbers." style="color:rgb(70,101,162);text-decoration:none" target="_blank">dvector</a>&)(x));
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00065" style="color:rgb(103,140,61)"></a>00065   }
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00066" style="color:rgb(103,140,61)"></a>00066 
</pre>
            </div>
            <div><br>
            </div>
            <div>but the constructor for the dvector_index uses the copy
              constructor for dvector</div>
            <div><br>
            </div>
            <div>
              <pre style="white-space:pre-wrap;font-family:monospace,fixed;font-size:9pt;border:1px solid rgb(214,229,196);padding:4px 6px;margin:4px 8px 4px 2px;overflow:auto;word-wrap:break-word;line-height:15px;color:rgb(0,0,0);background-color:rgb(252,253,251)">
00184 
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00189" style="color:rgb(103,140,61)"></a><a href="http://www.admb-project.org/documentation/api/classdvector__index.html#aba2c20e6f7432a5b4441e828427ce6e7" style="color:rgb(70,101,162);text-decoration:none" target="_blank">00189</a> <a href="http://www.admb-project.org/documentation/api/classdvector__index.html#aba2c20e6f7432a5b4441e828427ce6e7" title="Description not yet available." style="color:rgb(70,101,162);text-decoration:none" target="_blank">dvector_index::dvector_index</a>(<span style="color:rgb(0,128,0)">const</span> <a href="http://www.admb-project.org/documentation/api/classdvector.html" title="Vector of double precision numbers." style="color:rgb(70,101,162);text-decoration:none" target="_blank">dvector</a>& v) : <a href="http://www.admb-project.org/documentation/api/classdvector.html" title="Vector of double precision 
 numbers." style="color:rgb(70,101,162);text-decoration:none" target="_blank">dvector</a>(v)
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00190" style="color:rgb(103,140,61)"></a>00190 {
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00191" style="color:rgb(103,140,61)"></a>00191 }
<a name="146a5e2b09e6d263_146a59fe58776640_14671f50a40b0b90_l00192" style="color:rgb(103,140,61)"></a>00192 
</pre>
              <div style="font-family:arial,sans-serif;font-size:13px"><br>
              </div>
              <div style="font-family:arial,sans-serif;font-size:13px">which
                makes a shallow copy of v. Not sure why this doesn't
                work, but it doesn't. </div>
              <div style="font-family:arial,sans-serif;font-size:13px"><br>
              </div>
              <div style="font-family:arial,sans-serif;font-size:13px">My
                immediate issue is that I want to put setInitVals(...)
                in a code library--i.e., not in the tpl code and the
                usual methods for setting the initial values (i.e.,
                simple assignment by element) are private and only work
                when the function is defined inside the tpl. </div>
              <div style="font-family:arial,sans-serif;font-size:13px"><br>
              </div>
              <div style="font-family:arial,sans-serif;font-size:13px">I've
                also tried the set_initial_value(...) method in the tpl
                code but it doesn't work there either. Setting the
                initial values element-by-element in the tpl code does
                work, so the problem is not on my end (e.g., the dvector
                vls is all 0's).</div>
              <div style="font-family:arial,sans-serif;font-size:13px"><br>
              </div>
              <div style="font-family:arial,sans-serif;font-size:13px">Hope
                this is helpful.</div>
              <div style="font-family:arial,sans-serif;font-size:13px"><br>
              </div>
              <div style="font-family:arial,sans-serif;font-size:13px">
                Buck Stockhausen</div>
            </div>
          </div>
          <div>
            <div dir="ltr"><font face="courier new, monospace">***************************************************<br>
                * Dr. William T. Stockhausen                      *<br>
                ***************************************************<br>
                * Resource Ecology and Fisheries Management       *<br>
                * Alaska Fisheries Science Center                 *<br>
                * National Marine Fisheries Service               *<br>
                * National Oceanic and Atmospheric Administration *<br>
                * 7600 Sand Point Way N.E.                        *<br>
                * Seattle, Washington 98115-6349                  *<br>
                ***************************************************<br>
                * email: <a href="mailto:William.Stockhausen@noaa.gov" target="_blank">William.Stockhausen@noaa.gov</a>     
                       *<br>
                * voice: <a href="tel:206-526-4241" value="+12065264241" target="_blank">206-526-4241</a> fax: <a href="tel:206-526-6723" value="+12065266723" target="_blank">206-526-6723</a>           *<br>
                * web  : <a href="http://www.afsc.noaa.gov" target="_blank">http://www.afsc.noaa.gov</a> 
                               *<br>
                ***************************************************<br>
                All models are wrong, some are useful.--G.E.P. Box<br>
                Beware of geeks bearing equations.    --W. Buffett<br>
                ***************************************************<br>
                Disclaimer: The opinions expressed above are personal <br>
                and do not necessarily reflect official NOAA policy.<br>
              </font><br>
              <br>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><div><pre>_______________________________________________
Developers mailing list
<a href="mailto:Developers@admb-project.org" target="_blank">Developers@admb-project.org</a>
<a href="http://lists.admb-project.org/mailman/listinfo/developers" target="_blank">http://lists.admb-project.org/mailman/listinfo/developers</a>
</pre>
    </div></blockquote>
    <br>
  </div>

</div><br></div></div></div></div>
<br>_______________________________________________<br>
Developers mailing list<br>
<a href="mailto:Developers@admb-project.org">Developers@admb-project.org</a><br>
<a href="http://lists.admb-project.org/mailman/listinfo/developers" target="_blank">http://lists.admb-project.org/mailman/listinfo/developers</a><br>
<br></blockquote></div><br></div>