<div>Hello,</div>
<div>&nbsp;</div>
<div>&nbsp;I am trying to use a GA1DArrayGenome with the elements of the array being instances of user defined class &quot;Point&quot;. </div>
<div>&nbsp;</div>
<div>The error appears on the line when I try to isntantiate a genome of type GA1DArrayGenome&lt;Point&gt; :</div>
<div>&nbsp;</div>
<div>GA1DArrayGenome&lt;Point&gt; genome1(5,objective);</div>
<div>(I need to create an array of 5 points).</div>
<div>&nbsp;</div>
<div>Here is my code, and following that are the errors that I keep on getting. If anyone has any suggestions,&nbsp;I would greatly appreciate it.</div>
<div>&nbsp;</div>
<div>Regards,</div>
<div>&nbsp;</div>
<div>Faisal Goussous</div>
<div>Research Assistant</div>
<div>The University of Iowa</div>
<div>IA, USA</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>
<p>#include &lt;iostream&gt;<br>#include &lt;fstream&gt;<br>#include &lt;stdio.h&gt;<br>#include &lt;ga/ga.h&gt;<br>#include &lt;ga/std_stream.h&gt;<br>#include &lt;ga/GA1DArrayGenome.h&gt;<br>#include &lt;ga/GA1DArrayGenome.c&gt; 
</p>
<p><br>#define INSTANTIATE_REAL_GENOME<br>#define ostream STD_OSTREAM</p>
<p>using std::ifstream;<br>using std::ofstream;<br>using std::ios;<br>using std::cout;<br>using std::cin;<br>using std::endl;</p>
<p>// function prototypes<br>float objective(GAGenome &amp;);</p>
<p>/*************************************************************************************************/<br>class Point {<br>public:<br>&nbsp; Point(float x, float y, float z) { _x = x; _y = y; _z = z; }<br>&nbsp; Point(const Point &amp; p) { _x = p._x; _y = p._y; _z = p._z; } 
<br>&nbsp; Point(){} // default constructor</p>
<p>&nbsp; int operator ==(const Point &amp; p) const<br>&nbsp; {<br>&nbsp;&nbsp; if((p.x()==_x)&amp;&amp;(p.y()==_y)&amp;&amp;(p.z()==_z))<br>&nbsp;&nbsp;&nbsp; return 1;<br>&nbsp;&nbsp; else return 0;<br>&nbsp; }</p>
<p>&nbsp; int operator !=(const Point &amp; p) const<br>&nbsp; {<br>&nbsp;&nbsp; if((p.x()==_x)&amp;&amp;(p.y()==_y)&amp;&amp;(p.z()==_z))<br>&nbsp;&nbsp;&nbsp; return 0;<br>&nbsp;&nbsp; else return 1;<br>&nbsp; }</p>
<p>&nbsp; Point &amp; operator=(const Point &amp; p) { _x=p._x;_y=p._y;_z=p._z; return *this; }<br>&nbsp; ~Point() {}</p>
<p>&nbsp; float x() const { return _x; }<br>&nbsp; float y() const { return _y; }<br>&nbsp; float z() const { return _z; }<br>&nbsp; float x(float val) { return _x=val; }<br>&nbsp; float y(float val) { return _y=val; }<br>&nbsp; float z(float val) { return _z=val; } 
</p>
<p>&nbsp; friend ostream &amp; operator&lt;&lt;(ostream &amp; os, const Point &amp; p){<br>&nbsp;&nbsp;&nbsp; os &lt;&lt; &quot;(&quot; &lt;&lt; p._x &lt;&lt; &quot;, &quot; &lt;&lt; p._y &lt;&lt; &quot;, &quot; &lt;&lt; p._z &lt;&lt; &quot;)&quot;; 
<br>&nbsp;&nbsp;&nbsp; return os;<br>&nbsp; }</p>
<p>protected:<br>&nbsp; float _x, _y, _z;<br>};</p>
<p>/***************************************************************************************************/<br>int main(int argc, char** argv)<br>{</p>
<p>// See if we've been given a seed to use (for testing purposes).&nbsp; When you<br>// specify a random seed, the evolution will be exactly the same each time<br>// you use that seed number.<br>&nbsp; unsigned int seed = 0;<br>&nbsp; for(int ii=1; ii&lt;argc; ii++) 
<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; if(strcmp(argv[ii++],&quot;seed&quot;) == 0)<br>&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; seed = atoi(argv[ii]);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }</p>
<p>// create the genome (design representation)<br>GA1DArrayGenome&lt;Point&gt; genome1(5,objective);</p>
<p>// Create a GA class and set its parameters and options<br>GASteadyStateGA ga1(genome1);</p>
<p>// no scaling of fitness function values<br>GANoScaling scale;<br>ga1.scaling(scale);</p>
<p>GAParameterList params;<br>GASteadyStateGA::registerDefaultParameters(params);<br>params.set(gaNnGenerations, 100); // number of generations<br>params.set(gaNpopulationSize, 110); // population size<br>params.set(gaNscoreFrequency, 10); // Specify how often the generational scores should be recorded 
<br>params.set(gaNflushFrequency, 50); //specify how often the scores should be flushed to disk (every 50 generations)<br>params.set(gaNpCrossover, 0.6);&nbsp;&nbsp;// probability of crossover<br>params.set(gaNpMutation, 0.10);&nbsp;&nbsp;// probability of mutation (higher than normal, but suitable for the problem) 
<br>params.set(gaNselectScores, (int)GAStatistics::AllScores);<br>params.parse(argc, argv, gaFalse);</p>
<p>ga1.parameters(params);<br>ga1.set(gaNscoreFilename, &quot;faisal's output.dat&quot;);<br>ga1.initialize();</p>
<p>// start the evolution<br>ga1.evolve();</p>
<p>cout&lt;&lt; ga1.population().best();</p>
<p>return 0 ;</p>
<p>}</p>
<p>// The Fitness Function to be MAXIMIZED<br>float objective(GAGenome&amp; g)<br>{<br>&nbsp; GA1DArrayGenome&lt;Point&gt;&amp; genome = (GA1DArrayGenome&lt;Point&gt;&amp;)g;</p>
<p>&nbsp; Point p1 = genome.gene(0);<br>&nbsp; Point p2 = genome.gene(1);<br>&nbsp; Point p3 = genome.gene(2);<br>&nbsp; Point p4 = genome.gene(3);<br>&nbsp; Point p5 = genome.gene(4);</p>
<p>&nbsp; float objective = p1.z()+p2.z()+p3.z()+ p4.z()+ p5.z(); // objective function<br>&nbsp; return objective;<br>}<br></p>
<p>Errors ( actually only 1 eerror):</p><font size="1">
<p><strong>Compiling...</strong></p>
<p><strong>main.cpp</strong></p>
<p><strong>D:\Profile\fgoussou\Desktop\GAs\GAlib\ga\GAArray.h(34) : error C2440: 'type cast' : cannot convert from 'int' to 'Point'</strong></p>
<p><strong>No constructor could take the source type, or constructor overload resolution was ambiguous</strong></p>
<p><strong>D:\Profile\fgoussou\Desktop\GAs\GAlib\ga\GAArray.h(33) : while compiling class-template member function 'GAArray&lt;T&gt;::GAArray(unsigned int)'</strong></p>
<p><strong>with</strong></p>
<p><strong>[</strong></p>
<p><strong>T=Point</strong></p>
<p><strong>]</strong></p>
<p><strong>D:\Profile\fgoussou\Desktop\GAs\GAlib\ga\GA1DArrayGenome.h(37) : see reference to class template instantiation 'GAArray&lt;T&gt;' being compiled</strong></p>
<p><strong>with</strong></p>
<p><strong>[</strong></p>
<p><strong>T=Point</strong></p>
<p><strong>]</strong></p>
<p><strong>main.cpp(80) : see reference to class template instantiation 'GA1DArrayGenome&lt;T&gt;' being compiled</strong></p>
<p><strong>with</strong></p>
<p><strong>[</strong></p>
<p><strong>T=Point</strong></p>
<p><strong>]</strong></p></font></div>