Add some examples for the genetic algos 10/10010/2
Sylvestre Ledru [Wed, 12 Dec 2012 14:42:28 +0000 (15:42 +0100)]
Change-Id: Ife065a7dda1eae55cadc98905e8421efa847b109

scilab/modules/genetic_algorithms/help/en_US/utilities/coding_ga_binary.xml
scilab/modules/genetic_algorithms/help/en_US/utilities/coding_ga_identity.xml
scilab/modules/genetic_algorithms/help/en_US/utilities/pareto_filter.xml

index 45d640f..d3fa649 100644 (file)
             </listitem>
         </itemizedlist>
     </refsection>
+    <refsection>
+      <title>Examples</title>
+      <programlisting role="example"><![CDATA[
+
+pop_in = list();
+pop_in(1) = 2;
+
+pop_out = coding_ga_binary(pop_in,'code',[])
+// Will return 11111111
+
+pop_in_2 = coding_ga_binary(pop_out,'decode',[])
+// Should be 2
+
+]]></programlisting>
+    </refsection>
     <refsection role="see also">
         <title>See Also</title>
         <simplelist type="inline">
index 832c1ac..6e7f918 100644 (file)
             This function is a do-nothing function. It is essentially useful to implement an evolutionnary algorithm. In an evolutionnary algorithm, we work directly on the variable and not on a binary code.
         </para>
     </refsection>
+
+    <refsection>
+      <title>Examples</title>
+      <programlisting role="example"><![CDATA[
+pop_in = list();
+pop_in(1) = 2;
+
+pop_out = coding_ga_identity(pop_in,'code',[])
+
+pop_in_2 = coding_ga_identity(pop_out,'decode',[])
+]]></programlisting>
+    </refsection>
+
     <refsection role="see also">
         <title>See Also</title>
         <simplelist type="inline">
index 971a1d5..7e5d9b3 100644 (file)
             </listitem>
         </itemizedlist>
     </refsection>
+    <refsection>
+      <title>Examples</title>
+      <programlisting role="example"><![CDATA[
+function Res = min_bd_deb_1(n)
+if ~isdef('n','local') then n = 10; end;
+Res = zeros(n,1);
+endfunction
+
+function Res = max_bd_deb_1(n)
+if ~isdef('n','local') then n = 10; end;
+Res = ones(n,1);
+endfunction
+
+function f = get_opti_deb_1(x)
+f1_x1 = x(1);
+g_x2  = 1;
+h     = 1 - sqrt(f1_x1 / g_x2);
+
+f(1,1) = f1_x1;
+f(1,2) = g_x2 * h;
+endfunction
+
+function f = deb_1(x)
+f1_x1 = x(1);
+g_x2  = 1 + 9 * sum((x(2:$)-x(1)).^2) / (length(x) - 1);
+h     = 1 - sqrt(f1_x1 / g_x2);
+
+f(1,1) = f1_x1;
+f(1,2) = g_x2 * h;
+endfunction
+
+Max = max_bd_deb_1(2);
+Min = min_bd_deb_1(2);
+
+X_in = list();
+for i=1:100
+  X_in(i) = (Max - Min) .* rand(size(Max,1),size(Max,2)) + Min;
+  F_in(i,:) = deb_1(X_in(i));
+end
+
+[F_out, X_out, Ind_out] = pareto_filter(F_in, X_in)
+]]></programlisting>
+    </refsection>
     <refsection role="see also">
         <title>See Also</title>
         <simplelist type="inline">