Merge remote-tracking branch 'origin/5.5' 48/14848/1
Vincent COUVERT [Fri, 11 Jul 2014 07:46:12 +0000 (09:46 +0200)]
Conflicts:
scilab/CHANGES_5.5.X
scilab/modules/javasci/Makefile.in

Change-Id: I8919f1b744462ad64c7219fac209266ed22fea89

144 files changed:
scilab/CHANGES_5.5.X
scilab/bin/scilab
scilab/configure
scilab/configure.ac
scilab/m4/libsmath.m4
scilab/modules/cacsd/help/en_US/damp.xml
scilab/modules/core/sci_gateway/c/sci_error.c
scilab/modules/core/src/c/callinterf.c
scilab/modules/core/src/c/signal_mgmt.c
scilab/modules/core/src/c/tmpdir.c
scilab/modules/core/tests/nonreg_tests/bug_8781.dia.ref [new file with mode: 0644]
scilab/modules/core/tests/nonreg_tests/bug_8781.tst [new file with mode: 0644]
scilab/modules/core/tests/nonreg_tests/bug_9252.tst [new file with mode: 0644]
scilab/modules/data_structures/help/en_US/rlist.xml
scilab/modules/data_structures/help/fr_FR/rlist.xml
scilab/modules/data_structures/sci_gateway/c/sci_rlist.c
scilab/modules/development_tools/macros/assert/assert_checkequal.sci
scilab/modules/development_tools/tests/unit_tests/assert/checkequal.dia.ref
scilab/modules/development_tools/tests/unit_tests/assert/checkequal.tst
scilab/modules/differential_equations/src/fortran/dqk21.f
scilab/modules/differential_equations/tests/nonreg_tests/bug_13491.dia.ref [new file with mode: 0644]
scilab/modules/differential_equations/tests/nonreg_tests/bug_13491.tst [new file with mode: 0644]
scilab/modules/dynamic_link/macros/ilib_build_jar.sci
scilab/modules/dynamic_link/tests/nonreg_tests/bug_13471.dia.ref [new file with mode: 0644]
scilab/modules/dynamic_link/tests/nonreg_tests/bug_13471.tst [new file with mode: 0644]
scilab/modules/elementary_functions/help/en_US/bitwise/bitxor.xml
scilab/modules/elementary_functions/sci_gateway/fortran/sci_f_kron.f
scilab/modules/elementary_functions/src/c/xerhlt.c
scilab/modules/elementary_functions/tests/nonreg_tests/bug_10168.dia.ref [new file with mode: 0644]
scilab/modules/elementary_functions/tests/nonreg_tests/bug_10168.tst [new file with mode: 0644]
scilab/modules/fileio/etc/fileio.start
scilab/modules/fileio/sci_gateway/c/sci_copyfile.c
scilab/modules/fileio/sci_gateway/c/sci_movefile.c
scilab/modules/fileio/src/c/getFullFilename.c
scilab/modules/fileio/tests/nonreg_tests/bug_4339.dia.ref
scilab/modules/fileio/tests/nonreg_tests/bug_4339.tst
scilab/modules/genetic_algorithms/help/en_US/algorithms/optim_ga.xml
scilab/modules/genetic_algorithms/help/en_US/algorithms/optim_moga.xml
scilab/modules/genetic_algorithms/help/en_US/algorithms/optim_nsga.xml
scilab/modules/genetic_algorithms/help/en_US/algorithms/optim_nsga2.xml
scilab/modules/genetic_algorithms/help/en_US/utilities/crossover_ga_binary.xml
scilab/modules/genetic_algorithms/help/en_US/utilities/mutation_ga_binary.xml
scilab/modules/genetic_algorithms/help/en_US/utilities/output_ga_default.xml [new file with mode: 0644]
scilab/modules/genetic_algorithms/macros/crossover_ga_binary.sci
scilab/modules/genetic_algorithms/macros/mutation_ga_binary.sci
scilab/modules/genetic_algorithms/macros/optim_ga.sci
scilab/modules/genetic_algorithms/macros/optim_moga.sci
scilab/modules/genetic_algorithms/macros/optim_nsga.sci
scilab/modules/genetic_algorithms/macros/optim_nsga2.sci
scilab/modules/genetic_algorithms/macros/output_ga_default.sci [new file with mode: 0644]
scilab/modules/genetic_algorithms/macros/output_moga_default.sci [new file with mode: 0644]
scilab/modules/genetic_algorithms/macros/output_nsga2_default.sci [new file with mode: 0644]
scilab/modules/genetic_algorithms/macros/output_nsga_default.sci [new file with mode: 0644]
scilab/modules/genetic_algorithms/tests/nonreg_tests/bug_13420.dia.ref [new file with mode: 0644]
scilab/modules/genetic_algorithms/tests/nonreg_tests/bug_13420.tst [new file with mode: 0644]
scilab/modules/genetic_algorithms/tests/nonreg_tests/bug_13421.dia.ref [new file with mode: 0644]
scilab/modules/genetic_algorithms/tests/nonreg_tests/bug_13421.tst [new file with mode: 0644]
scilab/modules/genetic_algorithms/tests/nonreg_tests/bug_8415.dia.ref
scilab/modules/genetic_algorithms/tests/unit_tests/crossover_ga_binary.dia.ref
scilab/modules/genetic_algorithms/tests/unit_tests/crossover_ga_binary.tst
scilab/modules/genetic_algorithms/tests/unit_tests/optim_ga.dia.ref
scilab/modules/graphics/help/en_US/annotation/xtitle.xml
scilab/modules/graphics/help/en_US/axis/drawaxis.xml
scilab/modules/graphics/help/fr_FR/axis/drawaxis.xml
scilab/modules/graphics/help/ja_JP/annotation/xtitle.xml
scilab/modules/graphics/help/pt_BR/annotation/xtitle.xml
scilab/modules/graphics/sci_gateway/c/sci_drawaxis.c
scilab/modules/graphics/sci_gateway/c/sci_xarrows.c
scilab/modules/graphics/sci_gateway/c/sci_xfpolys.c
scilab/modules/graphics/tests/nonreg_tests/bug_13438.dia.ref [new file with mode: 0644]
scilab/modules/graphics/tests/nonreg_tests/bug_13438.tst [new file with mode: 0644]
scilab/modules/graphics/tests/nonreg_tests/bug_13503.dia.ref [new file with mode: 0644]
scilab/modules/graphics/tests/nonreg_tests/bug_13503.tst [new file with mode: 0644]
scilab/modules/graphics/tests/nonreg_tests/bug_8502.dia.ref [new file with mode: 0644]
scilab/modules/graphics/tests/nonreg_tests/bug_8502.tst [new file with mode: 0644]
scilab/modules/graphics/tests/nonreg_tests/bug_9052.dia.ref [new file with mode: 0644]
scilab/modules/graphics/tests/nonreg_tests/bug_9052.tst [new file with mode: 0644]
scilab/modules/gui/src/nogui/nogui.c
scilab/modules/helptools/etc/images_md5.txt
scilab/modules/helptools/images/LOGICAL_OP.png
scilab/modules/helptools/images/RELATIONALOP.png
scilab/modules/helptools/images/analpf_1.png
scilab/modules/helptools/images/optim_1.png
scilab/modules/helptools/images/window_1.png
scilab/modules/helptools/images/window_3.png
scilab/modules/io/help/en_US/file.xml
scilab/modules/javasci/Makefile.in
scilab/modules/localization/sci_gateway/c/sci_addlocalizationdomain.c
scilab/modules/matio/tests/nonreg_tests/bug_11035.dia.ref [new file with mode: 0644]
scilab/modules/matio/tests/nonreg_tests/bug_11035.mat [new file with mode: 0644]
scilab/modules/matio/tests/nonreg_tests/bug_11035.tst [new file with mode: 0644]
scilab/modules/optimization/help/en_US/optim.xml
scilab/modules/output_stream/help/ja_JP/msprintf.xml
scilab/modules/output_stream/src/fortran/dmpdsp.f
scilab/modules/output_stream/tests/nonreg_tests/bug_8874.dia.ref
scilab/modules/overloading/macros/%r_varn.sci [new file with mode: 0644]
scilab/modules/overloading/tests/nonreg_tests/bug_13481.dia.ref [new file with mode: 0644]
scilab/modules/overloading/tests/nonreg_tests/bug_13481.tst [new file with mode: 0644]
scilab/modules/overloading/tests/nonreg_tests/bug_9783.dia.ref [new file with mode: 0644]
scilab/modules/overloading/tests/nonreg_tests/bug_9783.tst [new file with mode: 0644]
scilab/modules/polynomials/help/en_US/bezout.xml
scilab/modules/polynomials/help/en_US/diophant.xml
scilab/modules/polynomials/help/en_US/varn.xml
scilab/modules/polynomials/help/fr_FR/varn.xml
scilab/modules/polynomials/help/ja_JP/varn.xml
scilab/modules/polynomials/help/pt_BR/varn.xml
scilab/modules/polynomials/help/ru_RU/varn.xml
scilab/modules/prebuildjava/build.xml
scilab/modules/preferences/src/java/org/scilab/modules/preferences/ScilabPreferences.java
scilab/modules/scicos_blocks/macros/Misc/LOGICAL_OP.sci
scilab/modules/scicos_blocks/macros/Misc/RELATIONALOP.sci
scilab/modules/scinotes/src/java/jflex/scilab.jflex
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/ScilabLexer.java
scilab/modules/signal_processing/help/en_US/filters/analpf.xml
scilab/modules/signal_processing/help/en_US/filters/window.xml
scilab/modules/signal_processing/help/ja_JP/filters/analpf.xml
scilab/modules/signal_processing/help/ja_JP/filters/window.xml
scilab/modules/time/help/en_US/getdate.xml
scilab/modules/time/help/fr_FR/getdate.xml
scilab/modules/xcos/etc/Xcos-style.xml
scilab/modules/xcos/help/ja_JP/palettes/Continuous_pal/AA_Continuous_pal.xml [new file with mode: 0644]
scilab/modules/xcos/help/ja_JP/palettes/Continuous_pal/CHAPTER [new file with mode: 0644]
scilab/modules/xcos/help/ja_JP/palettes/Continuous_pal/CLINDUMMY_f.xml [new file with mode: 0644]
scilab/modules/xcos/help/ja_JP/palettes/Continuous_pal/CLR.xml [new file with mode: 0644]
scilab/modules/xcos/help/ja_JP/palettes/Continuous_pal/CLSS.xml [new file with mode: 0644]
scilab/modules/xcos/help/ja_JP/palettes/Continuous_pal/DERIV.xml [new file with mode: 0644]
scilab/modules/xcos/help/ja_JP/palettes/Continuous_pal/INTEGRAL_f.xml [new file with mode: 0644]
scilab/modules/xcos/help/ja_JP/palettes/Continuous_pal/INTEGRAL_m.xml [new file with mode: 0644]
scilab/modules/xcos/help/ja_JP/palettes/Continuous_pal/PID.xml [new file with mode: 0644]
scilab/modules/xcos/help/ja_JP/palettes/Continuous_pal/TCLSS.xml [new file with mode: 0644]
scilab/modules/xcos/help/ja_JP/palettes/Continuous_pal/TIME_DELAY.xml [new file with mode: 0644]
scilab/modules/xcos/help/ja_JP/palettes/Continuous_pal/VARIABLE_DELAY.xml [new file with mode: 0644]
scilab/modules/xcos/images/palettes/LOGICAL_OP.png
scilab/modules/xcos/images/palettes/RELATIONALOP.png
scilab/modules/xml/help/en_US/xmlNs.xml
scilab/modules/xml/help/ja_JP/xmlNs.xml
scilab/modules/xml/sci_gateway/cpp/sci_xmlNs.cpp
scilab/modules/xml/src/cpp/XMLElement.cpp
scilab/modules/xml/tests/nonreg_tests/bug_13435.dia.ref [new file with mode: 0644]
scilab/modules/xml/tests/nonreg_tests/bug_13435.tst [new file with mode: 0644]
scilab/modules/xml/tests/nonreg_tests/bug_13509.dia.ref [new file with mode: 0644]
scilab/modules/xml/tests/nonreg_tests/bug_13509.tst [new file with mode: 0644]
scilab/scilab-lib.properties.in
scilab/tools/innosetup/icons.iss

index c7c6e8e..58014fa 100644 (file)
@@ -10,25 +10,59 @@ Obsolete & Removed Functions
 Scilab Bug Fixes
 ================
 
+* Bug #6979 fixed - Help page of rlist was unclear.
+
 * Bug #7203 fixed - Help page of titlepage was unclear.
 
 * Bug #7549 fixed - edit_curv did not disable standard plot menus.
 
 * Bug #7804 fixed - Small improvements made in struct help page.
 
+* Bug #8502 fixed - Axis labels wrongly used number with 3 digits in the exponent.
+
 * Bug #8646 fixed - The datatips contextual menu opened a selection list which
                     was not ergonomic.
 
+* Bug #8781 fixed - There was no error message when error was called with a complex value.
+
+* Bug #8898 fixed - Help page of getdate improved.
+
+* Bug #9052 fixed - Some demonstrations in graphics were automatically closed at
+                    the end of their execution.
+
+* Bug #9252 fixed - Some error prototypes produced screwed display.
+
+* Bug #9381 fixed - parallel_run did not work on CentOS (GLIBC issue).
+
+* Bug #9783 fixed - Insertion overloading did not seem to work with mlists.
+
+* Bug #10168 fixed - kron produced a segfault in some cases.
+
 * Bug #10555 fixed - Scilab failed to build with some configure options.
 
+* Bug #10583 fixed - ./configure --without-xcos did not work.
+
+* Bug #10646 fixed - ./configure ARPACK check linked `-larpack -lblas` instead
+                     of `-larpack -llapack -lblas`.
+
 * Bug #10777 fixed - Home and End keys were not trapped in CLI mode.
 
 * Bug #10784 fixed - clc function was not available in CLI & ADV-CLI modes.
 
+* Bug #11035 fixed - Scilab crashed when loading a file created with Matlab 7.12.
+
+* Bug #11284 fixed - Some calling sequences added in file help page.
+
 * Bug #12700 fixed - edit_curv (used by CURV_f) was broken.
 
+* Bug #12834 fixed - Graphics did not work on Fedora (GLIBC issue).
+
 * Bug #12918 fixed - OpenSUSE 12.3 x64 did not have gluegen2-rt in librarypath.
 
+* Bug #12986 fixed - Scilab did not start on CentOS 5.9 (GLIBC issue).
+
+* Bug #12987 fixed - Scilab did not start on Ubuntu 10.04 (GLIBC issue).
+
 * Bug #13180 fixed - surf did not handle degenerate cases.
 
 * Bug #13291 fixed - xmltojar([],[],'ja_JP') might lead to a crash when the
@@ -43,6 +77,8 @@ Scilab Bug Fixes
 
 * Bug #13324 fixed - Legends were completely modified when an item was clicked and modified.
 
+* Bug #13330 fixed - gtk2-oxygen theme engine (used by KDE) crashed Scilab.
+
 * Bug #13331 fixed - Users are no longer able to write inconsistent options to mopen,
                      mopen(file, "wr") now exits with a proper error.
 
@@ -51,12 +87,16 @@ Scilab Bug Fixes
 
 * Bug #13344 fixed - User defined ticks were not drawn at the right position.
 
+* Bug #13345 fixed - Scilab did not start on Debian Wheezy (GLIBC issue).
+
 * Bug #13349 fixed - Double-clicking on a MAT-file in file browser did not load it.
 
 * Bug #13351 fixed - xstringb failed with LaTeX code.
 
 * Bug #13358 fixed - Intersect and unique were slow due to an issue in quicksort implementation.
 
+* Bug #13364 fixed - Scilab did not start on CentOS 6.5, RedHat 5.4, RedHat 5.5 (GLIBC issue).
+
 * Bug #13365 fixed - Data bounds werenot correctly updated in 3-D.
 
 * Bug #13378 fixed - The "Console" handle display was not homogeneous with others.
@@ -85,14 +125,53 @@ Scilab Bug Fixes
 * Bug #13404 fixed - rect property was not taken into account in polarplot.
 
 * Bug #13409 fixed - permute(x, dims) failed when dims was greater than the dimensions of size(x)
-                     now permute treats extra dimensions as 1
+                     now permute treats extra dimensions as 1.
+
+* Bug #13418 fixed - Help page for crossover_ga_binary was unclear.
+                     Also added mix to check the crossover positions.
+
+* Bug #13419 fixed - Help page for mutation_ga_binary function was not clear and lacked of examples.
 
-* Bug #13507 fixed - Imaginary part in result of a complex power was missing. (Real^Complex)
+* Bug #13420 fixed - mutation_ga_binary did not calculate properly multiple mutations.
+
+* Bug #13421 fixed - Callback functions for genetic algorithms were missing.
+                     Now the user can set functions to stop iterations and access the population.
+
+* Bug #13422 fixed - Genetic algorithms did not log the minimum and maximum values properly.
+
+* Bug #13424 fixed - crossover_ga_binary algorithm was not the classical point crossover one.
+                     Also fixed the usage of binary length.
+
+* Bug #13425 fixed - optim_ga and optim_moga needed optimization.
+
+* Bug #13426 fixed - optim help page was written with bad indentation.
+
+* Bug #13435 fixed - Windows version crashes when calling xmlRemove on the first child.
+
+* Bug #13438 fixed - drawaxis did not return the handle of the created axis.
+
+* Bug #13459 fixed - A warning message about libcurl.so version was displayed at Scilab startup.
+
+* Bug #13471 fixed - ilib_build_jar infinite loop when used on an empty directory fixed.
+
+* Bug #13481 fixed - varn did not work on rational fractions
+
+* Bug #13491 fixed - intg now properly returns when the user function produces an error.
+
+* Bug #13501 fixed - Typos fixed in English help pages.
+
+* Bug #13503 fixed - xarrows made Scilab crash in some cases.
+
+* Bug #13507 fixed - Imaginary part in result of a complex power was missing (Real^Complex).
+
+* Bug #13509 fixed - It was not possible to have an empty prefix with xmlNs.
 
 
 Xcos Bug Fixes
 ==============
 
+* Bug #9996 fixed - The RELATION_OP box drawn in the work space is not compliant to the programming.
+
 * Bug #11823 fixed - Ctrl+F2 shortcut did not work on a selected block.
 
 * Bug #12718 fixed - Modelica Generic block reshaped the output ports and the label was double-written.
@@ -115,6 +194,16 @@ Xcos Bug Fixes
 * Bug #13396 fixed - MBLOCK did not work with an external file containing the modelica class.
 
 
+Known issues
+=============
+
+* On GNU/Linux with KDE and on some distributions, gtk2-oxygen theming engine
+  crashes Scilab. As a workaround, see http://bugzilla.scilab.org/show_bug.cgi?id=13330#c6.
+
+Besides these points, do not hesitate to report bugs on:
+http://bugzilla.scilab.org/
+
+
 
                      Changes between version 5.4.1 and 5.5.0
                      =======================================
index b8bd61d..863cb3c 100755 (executable)
@@ -612,8 +612,15 @@ fi
 
 if test $IS_SCILAB_BINARY -eq 1; then
 
-    TCL_LIBRARY="$SCIBINARYBASE/thirdparty/tcl8.5"
-    Tk_LIBRARY="$SCIBINARYBASE/thirdparty/tk8.5"
+    if test ! -d "$SCIBINARYBASE/thirdparty/tcl8.5"; then
+        # New packaging path (similar to Windows one)
+        TCL_LIBRARY="$SCIBINARYBASE/share/scilab/modules/tclsci/tcl/tcl8.5"
+        TK_LIBRARY="$SCIBINARYBASE/share/scilab/modules/tclsci/tcl/tk8.5"
+    else
+        # Old packaging path
+        TCL_LIBRARY="$SCIBINARYBASE/thirdparty/tcl8.5"
+        TK_LIBRARY="$SCIBINARYBASE/thirdparty/tk8.5"
+    fi
     LD_LIBRARY_PATH=$SCIBINARYBASE/lib/scilab:$SCIBINARYBASE/lib/thirdparty${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
     DOCBOOK_ROOT="$SCI/../../thirdparty/docbook"
     PATH="$PATH:$SCI/modules/scicos/"
@@ -622,7 +629,7 @@ if test $IS_SCILAB_BINARY -eq 1; then
     export PATH
     export LD_LIBRARY_PATH
     export TCL_LIBRARY
-    export Tk_LIBRARY
+    export TK_LIBRARY
 
     case $OS in
         *darwin* | *Darwin*)
index a337d30..1d79c94 100755 (executable)
@@ -9860,8 +9860,7 @@ case "$CC" in
 
    if test "$enable_debug_C" = yes; then
       DEBUG_CFLAGS="-pipe -Wformat -Wshadow -Wfloat-equal -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations  -Wstrict-prototypes  -Wmissing-noreturn -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wwrite-strings -Winline -Wredundant-decls -Wall -Wchar-subscripts -Wextra  -Wuninitialized -Wno-format-y2k -Wmissing-format-attribute -Wno-missing-field-initializers -Wno-strict-aliasing  -Wold-style-definition -g3 -Wunsafe-loop-optimizations"
-      # used to be -O
-      # -D_FORTIFY_SOURCE=2
+      # used to be -O0
       case "$host" in
       *-linux-gnu )
       # Only doing that under Linux
@@ -11048,7 +11047,7 @@ $as_echo "$ac_java_classpath" >&6; }
 $as_echo_n "checking to see if the java compiler works... " >&6; }
 
     cat << \EOF > conftest.java
-// #line 11051 "configure"
+// #line 11050 "configure"
 import java.util.regex.Pattern;
 
 
@@ -11135,7 +11134,7 @@ $as_echo_n "checking type of jvm... " >&6; }
     if test "x$ac_java_jvm_name" = "x" ; then
 
     cat << \EOF > conftest.java
-// #line 11138 "configure"
+// #line 11137 "configure"
 import java.util.regex.Pattern;
 
 import gnu.java.io.EncodingManager;
@@ -11219,7 +11218,7 @@ $as_echo_n "checking java API version... " >&6; }
     # The class java.nio.charset.Charset is new to 1.4
 
     cat << \EOF > conftest.java
-// #line 11222 "configure"
+// #line 11221 "configure"
 import java.util.regex.Pattern;
 
 import java.nio.charset.Charset;
@@ -11284,7 +11283,7 @@ EOF
     # The class java.lang.StringBuilder is new to 1.5
 
     cat << \EOF > conftest.java
-// #line 11287 "configure"
+// #line 11286 "configure"
 import java.util.regex.Pattern;
 
 import java.lang.StringBuilder;
@@ -11349,7 +11348,7 @@ EOF
     # The class java.util.ArrayDeque is new to 1.6
 
     cat << \EOF > conftest.java
-// #line 11352 "configure"
+// #line 11351 "configure"
 import java.util.regex.Pattern;
 
 import java.util.ArrayDeque;
@@ -11414,7 +11413,7 @@ EOF
     # The class java.nio.file.Path is new to 1.7
 
     cat << \EOF > conftest.java
-// #line 11417 "configure"
+// #line 11416 "configure"
 import java.util.regex.Pattern;
 
 import java.nio.file.Path;
@@ -11479,7 +11478,7 @@ EOF
     # The class java.util.stream.DoubleStream is new to 1.8
 
     cat << \EOF > conftest.java
-// #line 11482 "configure"
+// #line 11481 "configure"
 import java.util.regex.Pattern;
 
 import java.util.stream.DoubleStream;
@@ -12857,7 +12856,7 @@ $as_echo_n "checking jgraphx... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 12860 "configure"
+// #line 12859 "configure"
 import java.util.regex.Pattern;
 
 import com.mxgraph.model.mxCell;
@@ -12964,7 +12963,7 @@ $as_echo_n "checking minimal version (2.0.0.1) of jgraphx... " >&6; }
    if test "x" == "x"; then
 
     cat << \EOF > conftest.java
-// #line 12967 "configure"
+// #line 12966 "configure"
 import java.util.regex.Pattern;
 
 import com.mxgraph.view.mxGraph;
@@ -13036,7 +13035,7 @@ EOF
    else
 
     cat << \EOF > conftest.java
-// #line 13039 "configure"
+// #line 13038 "configure"
 import java.util.regex.Pattern;
 
 import com.mxgraph.view.mxGraph;
@@ -13130,7 +13129,7 @@ $as_echo_n "checking scirenderer... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 13133 "configure"
+// #line 13132 "configure"
 import java.util.regex.Pattern;
 
 import org.scilab.forge.scirenderer.PackageInfo;
@@ -13237,7 +13236,7 @@ $as_echo_n "checking minimal version (1.1.0) of scirenderer... " >&6; }
    if test "x" == "x"; then
 
     cat << \EOF > conftest.java
-// #line 13240 "configure"
+// #line 13239 "configure"
 import java.util.regex.Pattern;
 
 import org.scilab.forge.scirenderer.PackageInfo;
@@ -13309,7 +13308,7 @@ EOF
    else
 
     cat << \EOF > conftest.java
-// #line 13312 "configure"
+// #line 13311 "configure"
 import java.util.regex.Pattern;
 
 import org.scilab.forge.scirenderer.PackageInfo;
@@ -13408,7 +13407,7 @@ $as_echo_n "checking flexdock... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 13411 "configure"
+// #line 13410 "configure"
 import java.util.regex.Pattern;
 
 import org.flexdock.docking.DockingManager;
@@ -13515,7 +13514,7 @@ $as_echo_n "checking minimal version (1.2.4) of flexdock... " >&6; }
    if test "x" == "x"; then
 
     cat << \EOF > conftest.java
-// #line 13518 "configure"
+// #line 13517 "configure"
 import java.util.regex.Pattern;
 
 import org.flexdock.util.Utilities;
@@ -13587,7 +13586,7 @@ EOF
    else
 
     cat << \EOF > conftest.java
-// #line 13590 "configure"
+// #line 13589 "configure"
 import java.util.regex.Pattern;
 
 import org.flexdock.util.Utilities;
@@ -13678,7 +13677,7 @@ $as_echo_n "checking looks... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 13681 "configure"
+// #line 13680 "configure"
 import java.util.regex.Pattern;
 
 import com.jgoodies.looks.common.MenuItemRenderer;
@@ -13795,7 +13794,7 @@ $as_echo_n "checking jgoodies-looks... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 13798 "configure"
+// #line 13797 "configure"
 import java.util.regex.Pattern;
 
 import com.jgoodies.looks.common.MenuItemRenderer;
@@ -13913,7 +13912,7 @@ $as_echo_n "checking skinlf... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 13916 "configure"
+// #line 13915 "configure"
 import java.util.regex.Pattern;
 
 import com.l2fprod.util.AccessUtils;
@@ -14030,7 +14029,7 @@ $as_echo_n "checking jogl2... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 14033 "configure"
+// #line 14032 "configure"
 import java.util.regex.Pattern;
 
 import javax.media.opengl.glu.GLUnurbs;
@@ -14253,7 +14252,7 @@ $as_echo_n "checking gluegen2-rt... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 14256 "configure"
+// #line 14255 "configure"
 import java.util.regex.Pattern;
 
 import jogamp.common.os.MachineDescriptionRuntime;
@@ -14427,7 +14426,7 @@ $as_echo_n "checking jhall... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 14430 "configure"
+// #line 14429 "configure"
 import java.util.regex.Pattern;
 
 import javax.help.JHelp;
@@ -14542,7 +14541,7 @@ $as_echo_n "checking javahelp2... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 14545 "configure"
+// #line 14544 "configure"
 import java.util.regex.Pattern;
 
 import javax.help.JHelp;
@@ -14660,7 +14659,7 @@ $as_echo_n "checking jrosetta-API... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 14663 "configure"
+// #line 14662 "configure"
 import java.util.regex.Pattern;
 
 import com.artenum.rosetta.interfaces.core.ConsoleConfiguration;
@@ -14774,7 +14773,7 @@ $as_echo_n "checking jrosetta-api... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 14777 "configure"
+// #line 14776 "configure"
 import java.util.regex.Pattern;
 
 import com.artenum.rosetta.interfaces.core.ConsoleConfiguration;
@@ -14892,7 +14891,7 @@ $as_echo_n "checking jrosetta-engine... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 14895 "configure"
+// #line 14894 "configure"
 import java.util.regex.Pattern;
 
 import com.artenum.rosetta.core.action.AbstractConsoleAction;
@@ -14998,7 +14997,7 @@ $as_echo_n "checking minimal version (1.0.4) of jrosetta-engine... " >&6; }
    if test "x" == "x"; then
 
     cat << \EOF > conftest.java
-// #line 15001 "configure"
+// #line 15000 "configure"
 import java.util.regex.Pattern;
 
 import com.artenum.rosetta.util.ConfigurationBuilder;
@@ -15070,7 +15069,7 @@ EOF
    else
 
     cat << \EOF > conftest.java
-// #line 15073 "configure"
+// #line 15072 "configure"
 import java.util.regex.Pattern;
 
 import com.artenum.rosetta.util.ConfigurationBuilder;
@@ -15163,7 +15162,7 @@ $as_echo_n "checking jeuclid-core... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 15166 "configure"
+// #line 15165 "configure"
 import java.util.regex.Pattern;
 
 import net.sourceforge.jeuclid.LayoutContext;
@@ -15282,7 +15281,7 @@ $as_echo_n "checking fop... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 15285 "configure"
+// #line 15284 "configure"
 import java.util.regex.Pattern;
 
 import org.apache.fop.pdf.PDFInfo;
@@ -15406,7 +15405,7 @@ $as_echo_n "checking freehep-graphics2d... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 15409 "configure"
+// #line 15408 "configure"
 import java.util.regex.Pattern;
 
 import org.freehep.graphics2d.VectorGraphics;
@@ -15523,7 +15522,7 @@ $as_echo_n "checking freehep-graphicsio-emf... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 15526 "configure"
+// #line 15525 "configure"
 import java.util.regex.Pattern;
 
 import org.freehep.graphicsio.emf.EMFGraphics2D;
@@ -15640,7 +15639,7 @@ $as_echo_n "checking freehep-graphicsio... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 15643 "configure"
+// #line 15642 "configure"
 import java.util.regex.Pattern;
 
 import org.freehep.graphicsio.VectorGraphicsIO;
@@ -15757,7 +15756,7 @@ $as_echo_n "checking freehep-io... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 15760 "configure"
+// #line 15759 "configure"
 import java.util.regex.Pattern;
 
 import org.freehep.util.io.XMLSequence;
@@ -15874,7 +15873,7 @@ $as_echo_n "checking freehep-util... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 15877 "configure"
+// #line 15876 "configure"
 import java.util.regex.Pattern;
 
 import org.freehep.util.StringUtilities;
@@ -15992,7 +15991,7 @@ $as_echo_n "checking batik-all... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 15995 "configure"
+// #line 15994 "configure"
 import java.util.regex.Pattern;
 
 import org.apache.batik.parser.Parser;
@@ -16109,7 +16108,7 @@ $as_echo_n "checking batik... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 16112 "configure"
+// #line 16111 "configure"
 import java.util.regex.Pattern;
 
 import org.apache.batik.parser.Parser;
@@ -16216,7 +16215,7 @@ $as_echo_n "checking minimal version (1.7) of batik... " >&6; }
    if test "x" == "x"; then
 
     cat << \EOF > conftest.java
-// #line 16219 "configure"
+// #line 16218 "configure"
 import java.util.regex.Pattern;
 
 import org.apache.batik.Version;
@@ -16288,7 +16287,7 @@ EOF
    else
 
     cat << \EOF > conftest.java
-// #line 16291 "configure"
+// #line 16290 "configure"
 import java.util.regex.Pattern;
 
 import org.apache.batik.Version;
@@ -16379,7 +16378,7 @@ $as_echo_n "checking commons-io... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 16382 "configure"
+// #line 16381 "configure"
 import java.util.regex.Pattern;
 
 import org.apache.commons.io.output.CountingOutputStream;
@@ -16496,7 +16495,7 @@ $as_echo_n "checking xmlgraphics-commons... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 16499 "configure"
+// #line 16498 "configure"
 import java.util.regex.Pattern;
 
 import org.apache.xmlgraphics.util.Service;
@@ -16613,7 +16612,7 @@ $as_echo_n "checking avalon-framework... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 16616 "configure"
+// #line 16615 "configure"
 import java.util.regex.Pattern;
 
 import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -16730,7 +16729,7 @@ $as_echo_n "checking xml-apis-ext... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 16733 "configure"
+// #line 16732 "configure"
 import java.util.regex.Pattern;
 
 import org.w3c.dom.svg.SVGDocument;
@@ -16847,7 +16846,7 @@ $as_echo_n "checking xml-commons-apis-ext... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 16850 "configure"
+// #line 16849 "configure"
 import java.util.regex.Pattern;
 
 import org.w3c.dom.svg.SVGDocument;
@@ -16968,7 +16967,7 @@ $as_echo_n "checking commons-logging... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 16971 "configure"
+// #line 16970 "configure"
 import java.util.regex.Pattern;
 
 import org.apache.commons.logging.LogFactory;
@@ -17085,7 +17084,7 @@ $as_echo_n "checking jlatexmath... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 17088 "configure"
+// #line 17087 "configure"
 import java.util.regex.Pattern;
 
 import org.scilab.forge.jlatexmath.TeXFormula;
@@ -17192,7 +17191,7 @@ $as_echo_n "checking minimal version (1.0.3) of jlatexmath... " >&6; }
    if test "x" == "x"; then
 
     cat << \EOF > conftest.java
-// #line 17195 "configure"
+// #line 17194 "configure"
 import java.util.regex.Pattern;
 
 import org.scilab.forge.jlatexmath.TeXFormula;
@@ -17264,7 +17263,7 @@ EOF
    else
 
     cat << \EOF > conftest.java
-// #line 17267 "configure"
+// #line 17266 "configure"
 import java.util.regex.Pattern;
 
 import org.scilab.forge.jlatexmath.TeXFormula;
@@ -17355,7 +17354,7 @@ $as_echo_n "checking jlatexmath-fop... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 17358 "configure"
+// #line 17357 "configure"
 import java.util.regex.Pattern;
 
 import org.scilab.forge.jlatexmath.fop.JLaTeXMathObj;
@@ -17478,7 +17477,7 @@ $as_echo_n "checking checkstyle... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 17481 "configure"
+// #line 17480 "configure"
 import java.util.regex.Pattern;
 
 import com.puppycrawl.tools.checkstyle.CheckStyleTask;
@@ -17595,7 +17594,7 @@ $as_echo_n "checking commons-beanutils... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 17598 "configure"
+// #line 17597 "configure"
 import java.util.regex.Pattern;
 
 import org.apache.commons.beanutils.Converter;
@@ -17712,7 +17711,7 @@ $as_echo_n "checking antlr... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 17715 "configure"
+// #line 17714 "configure"
 import java.util.regex.Pattern;
 
 import antlr.TokenStreamException;
@@ -17829,7 +17828,7 @@ $as_echo_n "checking junit4... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 17832 "configure"
+// #line 17831 "configure"
 import java.util.regex.Pattern;
 
 import org.junit.Assert;
@@ -17943,7 +17942,7 @@ $as_echo_n "checking junit... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 17946 "configure"
+// #line 17945 "configure"
 import java.util.regex.Pattern;
 
 import org.junit.Assert;
@@ -18064,7 +18063,7 @@ $as_echo_n "checking cobertura... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 18067 "configure"
+// #line 18066 "configure"
 import java.util.regex.Pattern;
 
 import net.sourceforge.cobertura.merge.Main;
@@ -18181,7 +18180,7 @@ $as_echo_n "checking asm3... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 18184 "configure"
+// #line 18183 "configure"
 import java.util.regex.Pattern;
 
 import org.objectweb.asm.Type;
@@ -18295,7 +18294,7 @@ $as_echo_n "checking asm... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 18298 "configure"
+// #line 18297 "configure"
 import java.util.regex.Pattern;
 
 import org.objectweb.asm.Type;
@@ -18412,7 +18411,7 @@ $as_echo_n "checking ecj... " >&6; }
             export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 
     cat << \EOF > conftest.java
-// #line 18415 "configure"
+// #line 18414 "configure"
 import java.util.regex.Pattern;
 
 import org.eclipse.jdt.core.compiler.batch.BatchCompiler;
@@ -22659,7 +22658,7 @@ if test "$with_openmp" != no; then
 #   AC_OPENMP
     OPENMP_CFLAGS="-fopenmp"
     OPENMP_CXXFLAGS="-fopenmp"
-    OPENMP_LIBS="-lgomp"
+    OPENMP_LIBS="-lgomp -lstdc++" # Force -lstdc++ because some compilers do not add it automatically.
 
     for ac_header in omp.h
 do :
@@ -24815,6 +24814,7 @@ $as_echo_n "checking if ARPACK-NG is available... " >&6; }
 echo ""
 
 
+
 acx_arpack_ok=no
 
 
@@ -24852,13 +24852,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 # We cannot use ARPACK if BLAS is not found
-if test "x$acx_blas_ok" != xyes; then
+if test "x$acx_blas_ok" != xyes -a "x$acx_lapack_ok" != xyes ; then
         acx_arpack_ok=noblas
 fi
 
 # First, check ARPACK_LIBS environment variable
 if test "x$ARPACK_LIBS" != x; then
-        save_LIBS="$LIBS"; LIBS="$ARPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
+        save_LIBS="$LIBS"; LIBS="$ARPACK_LIBS $LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
         { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $znaupd in $ARPACK_LIBS" >&5
 $as_echo_n "checking for $znaupd in $ARPACK_LIBS... " >&6; }
         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -24931,7 +24931,7 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
-  save_LIBS="$LIBS"; LIBS="$ARPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
+  save_LIBS="$LIBS"; LIBS="$ARPACK_LIBS $LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the arpack library works" >&5
 $as_echo_n "checking whether the arpack library works... " >&6; }
 if ${lib_cv_arpack_ok+:} false; then :
index e6423dc..48b2509 100644 (file)
@@ -559,8 +559,7 @@ case "$CC" in
 
    if test "$enable_debug_C" = yes; then
       DEBUG_CFLAGS="-pipe -Wformat -Wshadow -Wfloat-equal -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations  -Wstrict-prototypes  -Wmissing-noreturn -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wwrite-strings -Winline -Wredundant-decls -Wall -Wchar-subscripts -Wextra  -Wuninitialized -Wno-format-y2k -Wmissing-format-attribute -Wno-missing-field-initializers -Wno-strict-aliasing  -Wold-style-definition -g3 -Wunsafe-loop-optimizations"
-      # used to be -O
-      # -D_FORTIFY_SOURCE=2
+      # used to be -O0
       case "$host" in
       *-linux-gnu )
       # Only doing that under Linux
@@ -1418,7 +1417,7 @@ if test "$with_openmp" != no; then
 #   AC_OPENMP
     OPENMP_CFLAGS="-fopenmp"
     OPENMP_CXXFLAGS="-fopenmp"
-    OPENMP_LIBS="-lgomp"
+    OPENMP_LIBS="-lgomp -lstdc++" # Force -lstdc++ because some compilers do not add it automatically.
 
     AC_CHECK_HEADERS([omp.h], [],
      [AC_MSG_ERROR([Could not find omp.h])])
index 0c2265c..c599574 100644 (file)
@@ -305,6 +305,7 @@ dnl @author Sylvestre Ledru <sylvestre.ledru@scilab-enterprises.com>
 
 AC_DEFUN([ACX_ARPACK], [
 AC_REQUIRE([ACX_BLAS])
+AC_REQUIRE([ACX_LAPACK])
 acx_arpack_ok=no
 
 AC_ARG_WITH(arpack-library,
@@ -320,13 +321,13 @@ ARPACK_LIBS="-larpack"
 AC_F77_FUNC(znaupd)
 
 # We cannot use ARPACK if BLAS is not found
-if test "x$acx_blas_ok" != xyes; then
+if test "x$acx_blas_ok" != xyes -a "x$acx_lapack_ok" != xyes ; then
         acx_arpack_ok=noblas
 fi
 
 # First, check ARPACK_LIBS environment variable
 if test "x$ARPACK_LIBS" != x; then
-        save_LIBS="$LIBS"; LIBS="$ARPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
+        save_LIBS="$LIBS"; LIBS="$ARPACK_LIBS $LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
         AC_MSG_CHECKING([for $znaupd in $ARPACK_LIBS])
         AC_TRY_LINK_FUNC($znaupd, [acx_arpack_ok=yes], [ARPACK_LIBS="-larpack"])
         AC_MSG_RESULT($acx_arpack_ok)
@@ -368,7 +369,7 @@ dnl This code is released under the GPL license.
 dnl
 AC_DEFUN([CHECK_ARPACK_OK], [
   AC_LANG_PUSH(C++)
-  save_LIBS="$LIBS"; LIBS="$ARPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
+  save_LIBS="$LIBS"; LIBS="$ARPACK_LIBS $LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
   AC_CACHE_CHECK([whether the arpack library works],
     [lib_cv_arpack_ok], [
       AC_RUN_IFELSE([AC_LANG_PROGRAM([[
index ac3a38d..385ba93 100644 (file)
@@ -32,7 +32,7 @@
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>P</term>
+                <term>R</term>
                 <listitem>
                     <para>
                         An array of real or complex floating point numbers.
@@ -52,7 +52,7 @@
                 <listitem>
                     <para>
                         vector of floating point numbers in increasing
-                        order: the natural pulsation in rd/s.
+                        order: the natural pulsation in rad/s.
                     </para>
                 </listitem>
             </varlistentry>
         <title>Description</title>
         <para>
             The denominator second order continuous time transfer function
-            with complex poles can be written as <literal>s^2+2*z*wn*s+wn^2</literal> where<literal>z</literal>
-            is the damping factor and <literal>wn </literal>the natural pulsation.
+            with complex poles can be written as <literal>s^2 + 2*z*wn*s + wn^2</literal> where <literal>z</literal>
+            is the damping factor and <literal>wn</literal> the natural pulsation.
         </para>
         <para>
             If <literal>sys</literal> is a continuous time system,
             <literal>[wn,z] = damp(sys)</literal> returns in <literal>wn</literal> the natural
-            pulsation <latex>\omega_n</latex>(in rd/s) and in <literal>z</literal> the damping factors
+            pulsation <latex>\omega_n</latex>(in rad/s) and in <literal>z</literal> the damping factors
             <latex>\xi</latex> of the poles of the linear dynamical system
             <literal>sys</literal>. The <literal>wn</literal> and
             <literal>z</literal> arrays are ordered according to the increasing
             If <literal>sys</literal> is a discrete time system
             <literal>[wn,z] = damp(sys)</literal> returns in
             <literal>wn</literal> the natural pulsation
-            <latex>\omega_n</latex>(in rd/s) and in <literal>z</literal> the
+            <latex>\omega_n</latex>(in rad/s) and in <literal>z</literal> the
             damping factors <latex>\xi</latex> of the continuous time
             equivalent poles of <literal>sys</literal>. The
             <literal>wn</literal> and <literal>z</literal> arrays are
             ordered according to the increasing pulsation order.
         </para>
         <para>
-            <literal>[wn,z] = damp(P)</literal>  returns in
+            <literal>[wn,z] = damp(P)</literal> returns in
             <literal>wn</literal> the natural pulsation
-            <latex>\omega_n</latex>(in rd/s) and in <literal>z</literal> the
+            <latex>\omega_n</latex>(in rad/s) and in <literal>z</literal> the
             damping factors <latex>\xi</latex> of the set of roots of the polynomials
-            stored in the <literal>P</literal> array.  If
+            stored in the <literal>P</literal> array. If
             <literal>dt</literal> is given and non 0, the roots are first
             converted to their continuous time equivalents.
             
             according to the increasing pulsation order.
         </para>
         <para>
-            <literal>[wn,z] = damp(R)</literal>  returns in
+            <literal>[wn,z] = damp(R)</literal> returns in
             <literal>wn</literal> the natural pulsation
-            <latex>\omega_n</latex>(in rd/s) and in <literal>z</literal> the
-            damping factors <latex>\xi</latex> of  the set of roots stored in the
-            <literal>R</literal> array. 
+            <latex>\omega_n</latex>(in rad/s) and in <literal>z</literal> the
+            damping factors <latex>\xi</latex> of the set of roots stored in the
+            <literal>R</literal> array.
             
             If <literal>dt</literal> is given and non 0, the roots are first
             converted to their continuous time equivalents.
     <refsection>
         <title>Examples</title>
         <programlisting role="example"><![CDATA[
-    s=%s;
-    num=22801+4406.18*s+382.37*s^2+21.02*s^3+s^4;
-    den=22952.25+4117.77*s+490.63*s^2+33.06*s^3+s^4
-    h=syslin('c',num/den);
+    s = %s;
+    num = 22801 + 4406.18*s + 382.37*s^2 + 21.02*s^3 + s^4;
+    den = 22952.25 + 4117.77*s + 490.63*s^2 + 33.06*s^3 + s^4
+    h = syslin('c', num/den);
     [wn,z] = damp(h)
     ]]></programlisting>
         <para>
             the frequency response of a second order system.
         </para>
         <programlisting role="example"><![CDATA[
-   s=%s;
-   wn=1;
+   s = %s;
+   wn = 1;
    clf();
-   Z=[0.95 0.7 0.5 0.3 0.13 0.0001];
+   Z = [0.95 0.7 0.5 0.3 0.13 0.0001];
    for k=1:size(Z,'*')
-     z=Z(k)
-     H=syslin('c',1+5*s+10*s^2,s^2+2*z*wn*s+wn^2);
-     gainplot(H,0.01,1)
-     p=gce();p=p.children;
-     p.foreground=k;
+     z = Z(k)
+     H = syslin('c', 1 + 5*s + 10*s^2, s^2 + 2*z*wn*s + wn^2);
+     gainplot(H, 0.01, 1)
+     p = gce();
+     p = p.children;
+     p.foreground = k;
    end
    title("$\frac{1+5 s+10 s^2}{\omega_n^2+2\omega_n\xi s+s^2}, \quad \omega_n=1$")
-   legend('$\xi='+string(Z)+'$')
-   plot(wn/(2*%pi)*[1 1],[0 70],'r') //natural pulsation
+   legend('$\xi = '+string(Z)+'$')
+   plot(wn/(2*%pi)*[1 1], [0 70], 'r') // Natural pulsation
    ]]></programlisting>
         <para>
             <scilab:image localized="true">
index e400bdc..0f59527 100644 (file)
@@ -73,6 +73,8 @@ static int error_one_rhs(const char *fname)
 {
     SciErr sciErr;
     int *piAddressVarOne = NULL;
+    int iComplex = 0;
+
     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
     if (sciErr.iErr)
     {
@@ -83,7 +85,15 @@ static int error_one_rhs(const char *fname)
     {
         if (isDoubleType(pvApiCtx, piAddressVarOne))
         {
-            return error_one_rhs_number(pvApiCtx, piAddressVarOne,  fname);
+            iComplex = isVarComplex(pvApiCtx, piAddressVarOne);
+            if (iComplex)
+            {
+                Scierror(999, _("%s: Wrong type for input argument #%d.\n"), fname, 1);
+            }
+            else
+            {
+                return error_one_rhs_number(pvApiCtx, piAddressVarOne,  fname);
+            }
         }
         else if (isStringType(pvApiCtx, piAddressVarOne))
         {
@@ -103,6 +113,8 @@ static int error_two_rhs(const char *fname)
     SciErr sciErr;
     int *piAddressVarOne = NULL;
     int *piAddressVarTwo = NULL;
+    int iComplexVarOne = 0;
+    int iComplexVarTwo = 0;
 
     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
     if (sciErr.iErr)
@@ -122,15 +134,44 @@ static int error_two_rhs(const char *fname)
 
     if (isDoubleType(pvApiCtx, piAddressVarOne) && isStringType(pvApiCtx, piAddressVarTwo))
     {
-        return error_two_rhs_number_string(pvApiCtx, piAddressVarTwo, 2, piAddressVarOne, 1, fname);
+        iComplexVarOne = isVarComplex(pvApiCtx, piAddressVarOne);
+        if (iComplexVarOne)
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d.\n"), fname, 1);
+        }
+        else
+        {
+            return error_two_rhs_number_string(pvApiCtx, piAddressVarTwo, 2, piAddressVarOne, 1, fname);
+        }
     }
     else if (isDoubleType(pvApiCtx, piAddressVarTwo) && isStringType(pvApiCtx, piAddressVarOne))
     {
-        return error_two_rhs_number_string(pvApiCtx, piAddressVarOne, 1, piAddressVarTwo, 2, fname);
+        iComplexVarTwo = isVarComplex(pvApiCtx, piAddressVarTwo);
+        if (iComplexVarTwo)
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d.\n"), fname, 2);
+        }
+        else
+        {
+            return error_two_rhs_number_string(pvApiCtx, piAddressVarOne, 1, piAddressVarTwo, 2, fname);
+        }
     }
     else if (isDoubleType(pvApiCtx, piAddressVarTwo) && isDoubleType(pvApiCtx, piAddressVarOne))
     {
-        return error_two_rhs_number_number(pvApiCtx, piAddressVarOne, piAddressVarTwo, fname);
+        iComplexVarOne = isVarComplex(pvApiCtx, piAddressVarOne);
+        iComplexVarTwo = isVarComplex(pvApiCtx, piAddressVarTwo);
+        if (iComplexVarOne)
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d.\n"), fname, 1);
+        }
+        else if (iComplexVarTwo)
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d.\n"), fname, 2);
+        }
+        else
+        {
+            return error_two_rhs_number_number(pvApiCtx, piAddressVarOne, piAddressVarTwo, fname);
+        }
     }
     else
     {
index 4ad609d..4361b79 100644 (file)
  *
  */
 /*--------------------------------------------------------------------------*/
+
 #include <string.h>
-#if defined(__linux__)
-#define __USE_FORTIFY_LEVEL 0 /* Avoid dependency on GLIBC_2.11 (__longjmp_chk) */
-#endif
 #include <setjmp.h>
 #include <stdio.h>
 #include <ctype.h>
index 8b378c0..cf66a57 100644 (file)
@@ -17,6 +17,7 @@
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <string.h>
 #include <libintl.h>
 
-#if defined(__linux__)
-#define __USE_FORTIFY_LEVEL 0   /* Avoid dependency on GLIBC_2.11 (__longjmp_chk) */
-#endif
-#include <setjmp.h>             /* this declaration should remain close the __USE_FORTIFY_LEVEL define */
+#include <setjmp.h>
 
 #include <sys/types.h>          /* getpid */
 #include <unistd.h>             /* gethostname */
@@ -36,7 +34,6 @@
 #include "localization.h"
 #include "backtrace.h"
 #include "signal_mgmt.h"
-#include "machine.h"
 #include "Scierror.h"
 #include "suspendProcess.h"
 #include "scilabmode.h"
index a08acd9..c26ba86 100644 (file)
@@ -11,6 +11,8 @@
  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
  *
  */
+
+
 #include <stdio.h>
 #include <string.h>
 
@@ -20,9 +22,6 @@
 #endif
 
 #if defined(__STDC__) || defined(_MSC_VER)
-#if defined(__linux__)
-#define __USE_FORTIFY_LEVEL 0 /* Avoid dependency on GLIBC_2.4 (__realpath_chk) */
-#endif
 #include <stdlib.h>
 #ifndef _MSC_VER
 #include <sys/types.h>
diff --git a/scilab/modules/core/tests/nonreg_tests/bug_8781.dia.ref b/scilab/modules/core/tests/nonreg_tests/bug_8781.dia.ref
new file mode 100644 (file)
index 0000000..945b6ff
--- /dev/null
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 8781 -->
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/8781
+//
+// <-- Short Description -->
+// Calling error with complex value is ok for Scilab
+msg1 = msprintf(gettext("%s: Wrong type for input argument #%d.\n"), "error", 1);
+msg2 = msprintf(gettext("%s: Wrong type for input argument #%d.\n"), "error", 2);
+assert_checkerror("error(1+%i)", msg1);
+assert_checkerror("error(%i, 1)", msg1);
+assert_checkerror("error(45+%i, [''A''; ''multi'';''line'';''error'';''message''])", msg1);
+assert_checkerror("error(52, %i)", msg2);
diff --git a/scilab/modules/core/tests/nonreg_tests/bug_8781.tst b/scilab/modules/core/tests/nonreg_tests/bug_8781.tst
new file mode 100644 (file)
index 0000000..c4c2869
--- /dev/null
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 8781 -->
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/8781
+//
+// <-- Short Description -->
+// Calling error with complex value is ok for Scilab
+
+msg1 = msprintf(gettext("%s: Wrong type for input argument #%d.\n"), "error", 1);
+msg2 = msprintf(gettext("%s: Wrong type for input argument #%d.\n"), "error", 2);
+assert_checkerror("error(1+%i)", msg1);
+assert_checkerror("error(%i, 1)", msg1);
+assert_checkerror("error(45+%i, [''A''; ''multi'';''line'';''error'';''message''])", msg1);
+assert_checkerror("error(52, %i)", msg2);
diff --git a/scilab/modules/core/tests/nonreg_tests/bug_9252.tst b/scilab/modules/core/tests/nonreg_tests/bug_9252.tst
new file mode 100644 (file)
index 0000000..f5ba70f
--- /dev/null
@@ -0,0 +1,35 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 9252 -->
+//
+// <-- CLI SHELL MODE -->
+// 
+// <-- INTERACTIVE TEST -->
+// 
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9252
+//
+// <-- Short Description -->
+// Some error prototypes produce screwed display
+
+function bugme()
+    error(666,"My freaking error")
+endfunction
+
+bugme
+
+// Check that the error message is this one:
+// !--error 666 
+//My freaking error
+//at line       2 of function bugme called by :  
+//bugme
+
+// and not this one:
+// !--error 666 
+//My freaking errorat line       2 of function bugme called by :  
+//bugme()
index fb54193..31f279b 100644 (file)
     </refnamediv>
     <refsynopsisdiv>
         <title>Calling Sequence</title>
-        <synopsis>rlist()
-            rlist(a1 ,..., an)
+        <synopsis>[r] = rlist()
+            [r] = rlist(N, D [,dom])
         </synopsis>
     </refsynopsisdiv>
     <refsection>
+        <title>Arguments</title>
+        <variablelist>
+            <varlistentry>
+                <term>N,D</term>
+                <listitem>
+                    <para>polynomial martices.</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>dom</term>
+                <listitem>
+                    <para>
+                        character string, or <literal>[]</literal> or a scalar.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>r</term>
+                <listitem>
+                    <para>
+                        tlist ("r" list) representing the rational fraction.
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
         <title>Description</title>
         <para>
-            <literal>rlist(a1, ..., an)</literal> is a shortcut  to
-            <literal>tlist(['r','num';'den','dt'], a1, ..., an)</literal>.
+            <literal>rlist(N, D, dom)</literal> is a shortcut  to
+            <literal>tlist(['r','num','den','dt'], N, D, dom)</literal>.
         </para>
         <para>
-            <literal>rlist(a1, ..., an)</literal> creates a <literal>tlist</literal> with  <literal>['r','num';'den','dt']</literal> as
-            first entry and  <literal>ai</literal>'s as next entries if any. No type nor size
-            checking is done on <literal>ai</literal>'s.
+            To correspond to the domain time of a linear system, <varname>dom</varname> 
+            must be equal to <literal>'c'</literal>,<literal>'d'</literal>, <literal>[]</literal> or a scalar.
+            One the one hand, to be similar to functions as <link linkend="syslin">syslin</link>, 
+            and on the other, to use some functions as <link linkend="tf2ss">tf2ss</link>, it
+            is necessary that <varname>dom</varname> is equal to these values.
         </para>
     </refsection>
     <refsection>
@@ -42,6 +71,11 @@ W'*W
 Num=[s,s+2;1,s];
 Den=[s*s,s;s,s*s];
 rlist(Num,Den,[])
+
+H1=(1+2*s)/s^2;
+S1bis=syslin('c',H1)
+r=rlist(H1.num, H1.den, 'c')
+r == S1bis
  ]]></programlisting>
     </refsection>
     <refsection role="see also">
@@ -56,6 +90,9 @@ rlist(Num,Den,[])
             <member>
                 <link linkend="rational">rational</link>
             </member>
+            <member>
+                <link linkend="tf2ss">tf2ss</link>
+            </member>
         </simplelist>
     </refsection>
 </refentry>
index 1bebf90..6d57967 100644 (file)
@@ -6,20 +6,49 @@
     </refnamediv>
     <refsynopsisdiv>
         <title>Séquence d'appel</title>
-        <synopsis>rlist()
-            rlist(a1,....an)
+        <synopsis>[r] = rlist()
+            [r] = rlist(N, D [,dom])
         </synopsis>
     </refsynopsisdiv>
     <refsection>
+        <title>Arguments</title>
+        <variablelist>
+            <varlistentry>
+                <term>N,D</term>
+                <listitem>
+                    <para>martices polynomiales.</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>dom</term>
+                <listitem>
+                    <para>
+                        chaîne de caractères ou <literal>[]</literal>, ou un scalaire.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>r</term>
+                <listitem>
+                    <para>
+                        tlist (liste de type "r") représentant la fraction rationnelle.
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
         <title>Description</title>
         <para>
-            <literal>rlist(a1,....an)</literal> est équivalent à
-            <literal>tlist(['r','num';'den','dt'], a1,....an)</literal> 
-        </para>
-        <para>
-            Crée une <literal>tlist</literal> avec <literal>['r','num';'den','dt']</literal> comme premier argument et les <literal>ai</literal> comme termes suivants s'ils sont présents dans les arguments. Aucune vérification de type ou de taille n'est faite sur les <literal>ai</literal>.
+            <literal>[r] = rlist(N, D, dom)</literal> est équivalent à
+            <literal>tlist(['r','num','den','dt'], N, D, dom)</literal>
         </para>
         <para>
+            Pour correspondre au domaine temporel d'un système linéaire, <varname>dom</varname> doit être égale à
+            <literal>'c'</literal>,<literal>'d'</literal>, <literal>[]</literal> ou à un scalaire.
+            D'une part, par analogie à des fonctions comme <link linkend="syslin">syslin</link>, 
+            et d'autre part, pour être compatible avec des fonctions comme <link linkend="tf2ss">tf2ss</link>,
+            il est nécessaire que <varname>dom</varname> soit égale à ces valeurs.
         </para>
     </refsection>
     <refsection>
@@ -31,6 +60,11 @@ W'*W
 Num=[s,s+2;1,s];
 Den=[s*s,s;s,s*s];
 rlist(Num,Den,[])
+
+H1=(1+2*s)/s^2;
+S1bis=syslin('c',H1)
+r=rlist(H1.num, H1.den, 'c')
+r == S1bis
  ]]></programlisting>
     </refsection>
     <refsection role="see also">
@@ -45,6 +79,9 @@ rlist(Num,Den,[])
             <member>
                 <link linkend="rational">rational</link>
             </member>
+            <member>
+                <link linkend="tf2ss">tf2ss</link>
+            </member>
         </simplelist>
     </refsection>
 </refentry>
index 066f07d..5ff6056 100644 (file)
@@ -19,6 +19,9 @@ extern int C2F(mtlist)(); /* fortran */
 /*--------------------------------------------------------------------------*/
 int sci_rlist(char *fname, unsigned long fname_len)
 {
+
+    CheckInputArgument(pvApiCtx, 0, 3);
+
     if (nbInputArgument(pvApiCtx) == 2)
     {
         int lw = 0;
index 61a139f..444980c 100644 (file)
@@ -48,14 +48,13 @@ function [flag,errmsg] = assert_checkequal ( computed , expected )
         errmsg = sprintf ( gettext ( "%s: Wrong number of input arguments: %d expected.\n") , "assert_checkequal" , 2 )
         error(errmsg)
     end
-    //
+
     // Check types of variables
     if ( typeof(computed) <> typeof(expected) ) then
         errmsg = sprintf ( gettext ( "%s: Incompatible input arguments #%d and #%d: Same types expected.\n" ) , "assert_checkequal" , 1 , 2 )
         error(errmsg)
-    end
+   end
 
-    //
     // Check hypermat type
     if (typeof(computed) == "hypermat") then
         // Check on first element type
@@ -113,19 +112,21 @@ function [flag,errmsg] = assert_checkequal ( computed , expected )
             flag = %f
         end
     end
+
     if ( flag == %t ) then
+
         errmsg = ""
     else
         // Change the message if the matrix contains more than one value
         if ( size(expected,"*") == 1 ) then
-            if ( typeof(expected) == "sparse") then
+            if ( or(typeof(expected) == ["sparse", "boolean sparse"])) then
                 val = full(expected)
             else
                 val = expected
             end
             estr = string(val)
         else
-            if ( typeof(expected) == "sparse") then
+            if ( or(typeof(expected) == ["sparse", "boolean sparse"])) then
                 val = full(expected(1))
             else
                 val = expected(1)
@@ -133,14 +134,14 @@ function [flag,errmsg] = assert_checkequal ( computed , expected )
             estr = "[" + string(val) + " ...]"
         end
         if ( size(computed,"*") == 1 ) then
-            if ( typeof(computed) == "sparse") then
+            if ( or(typeof(computed) == ["sparse", "boolean sparse"])) then
                 val = full(computed)
             else
                 val = computed
             end
             cstr = string(val)
         else
-            if ( typeof(computed) == "sparse") then
+            if ( or(typeof(computed) == ["sparse", "boolean sparse"])) then
                 val = full(computed(1))
             else
                 val = computed(1)
index a38e5de..f8d1714 100644 (file)
@@ -9,19 +9,19 @@
 // <-- CLI SHELL MODE -->
 // <-- ENGLISH IMPOSED -->
 function flag = MY_assert_equal ( computed , expected )
-  if ( and ( computed==expected ) ) then
-    flag = 1;
-  else
-    flag = 0;
-  end
-  if flag <> 1 then bugmes();quit;end
+    if ( and ( computed==expected ) ) then
+        flag = 1;
+    else
+        flag = 0;
+    end
+    if flag <> 1 then bugmes();quit;end
 endfunction
 function checkassert ( flag , errmsg , ctype )
-  if ( ctype == "success" ) then
-    MY_assert_equal ( (flag==%t) & (errmsg==""), %t )
-  else
-    MY_assert_equal ( (flag==%f) & (errmsg<>""), %t )
-  end
+    if ( ctype == "success" ) then
+        MY_assert_equal ( (flag==%t) & (errmsg==""), %t )
+    else
+        MY_assert_equal ( (flag==%f) & (errmsg<>""), %t )
+    end
 endfunction
 format("v",10);
 // Check error message when number of arguments is false
@@ -107,12 +107,12 @@ checkassert ( flag , errmsg , "success" );
 // Check various types
 //
 //  Mlist
-s=mlist(['V','name','value'],['a','b';'c' 'd'],[1 2; 3 4]);
+s=mlist(["V","name","value"],["a","b";"c" "d"],[1 2; 3 4]);
 t=s;
 assert_checkequal(s, t);
 //
 //  Tlist
-s=tlist(['V','name','value'],['a','b';'c' 'd'],[1 2; 3 4]);
+s=tlist(["V","name","value"],["a","b";"c" "d"],[1 2; 3 4]);
 t=s;
 assert_checkequal(s, t);
 //
@@ -125,6 +125,10 @@ assert_checkequal(s, t);
 s=spzeros(3,5);
 t=s;
 assert_checkequal(s, t);
+s(1)=12;
+instr="assert_checkequal(s, t)";
+ierr=execstr(instr,"errcatch");
+MY_assert_equal(ierr, 10000);
 //
 // Boolean
 s=(ones(3,5)==ones(3,5));
@@ -135,6 +139,10 @@ assert_checkequal(s, t);
 s=(spzeros(3,5)==spzeros(3,5));
 t=s;
 assert_checkequal(s, t);
+s(1)=%f;
+instr="assert_checkequal(s, t)";
+ierr=execstr(instr,"errcatch");
+MY_assert_equal(ierr, 10000);
 //
 // Integer  8
 s=int8(3);
index a701b96..3ffaae8 100644 (file)
 // <-- ENGLISH IMPOSED -->
 
 function flag = MY_assert_equal ( computed , expected )
-  if ( and ( computed==expected ) ) then
-    flag = 1;
-  else
-    flag = 0;
-  end
-  if flag <> 1 then pause,end
+    if ( and ( computed==expected ) ) then
+        flag = 1;
+    else
+        flag = 0;
+    end
+    if flag <> 1 then pause,end
 endfunction
 
 function checkassert ( flag , errmsg , ctype )
-  if ( ctype == "success" ) then
-    MY_assert_equal ( (flag==%t) & (errmsg==""), %t )
-  else
-    MY_assert_equal ( (flag==%f) & (errmsg<>""), %t )
-  end
+    if ( ctype == "success" ) then
+        MY_assert_equal ( (flag==%t) & (errmsg==""), %t )
+    else
+        MY_assert_equal ( (flag==%f) & (errmsg<>""), %t )
+    end
 endfunction
 
 format("v",10);
@@ -113,12 +113,12 @@ checkassert ( flag , errmsg , "success" );
 // Check various types
 //
 //  Mlist
-s=mlist(['V','name','value'],['a','b';'c' 'd'],[1 2; 3 4]);
+s=mlist(["V","name","value"],["a","b";"c" "d"],[1 2; 3 4]);
 t=s;
 assert_checkequal(s, t);
 //
 //  Tlist
-s=tlist(['V','name','value'],['a','b';'c' 'd'],[1 2; 3 4]);
+s=tlist(["V","name","value"],["a","b";"c" "d"],[1 2; 3 4]);
 t=s;
 assert_checkequal(s, t);
 //
@@ -131,6 +131,11 @@ assert_checkequal(s, t);
 s=spzeros(3,5);
 t=s;
 assert_checkequal(s, t);
+s(1)=12;
+instr="assert_checkequal(s, t)";
+ierr=execstr(instr,"errcatch");
+MY_assert_equal(ierr, 10000);
+
 //
 // Boolean
 s=(ones(3,5)==ones(3,5));
@@ -141,6 +146,11 @@ assert_checkequal(s, t);
 s=(spzeros(3,5)==spzeros(3,5));
 t=s;
 assert_checkequal(s, t);
+s(1)=%f;
+instr="assert_checkequal(s, t)";
+ierr=execstr(instr,"errcatch");
+MY_assert_equal(ierr, 10000);
+
 //
 // Integer  8
 s=int8(3);
index 9ea1458..29bd2e9 100644 (file)
@@ -55,6 +55,7 @@ c
      *  resg,resk,reskh,result,uflow,wg,wgk,xgk
       integer j,jtw,jtwm1
       external f
+      common/ierajf/iero
 c
       dimension fv1(10),fv2(10),wg(5),wgk(11),xgk(11)
 c
@@ -140,13 +141,16 @@ c           the integral, and estimate the absolute error.
 c
       resg = 0.0d+00
       fc = f(centr)
+      if(iero.gt.0) return
       resk = wgk(11)*fc
       resabs = dabs(resk)
       do 10 j=1,5
         jtw = 2*j
         absc = hlgth*xgk(jtw)
         fval1 = f(centr-absc)
+        if(iero.gt.0) return
         fval2 = f(centr+absc)
+        if(iero.gt.0) return
         fv1(jtw) = fval1
         fv2(jtw) = fval2
         fsum = fval1+fval2
@@ -158,7 +162,9 @@ c
         jtwm1 = 2*j-1
         absc = hlgth*xgk(jtwm1)
         fval1 = f(centr-absc)
+        if(iero.gt.0) return
         fval2 = f(centr+absc)
+        if(iero.gt.0) return
         fv1(jtwm1) = fval1
         fv2(jtwm1) = fval2
         fsum = fval1+fval2
diff --git a/scilab/modules/differential_equations/tests/nonreg_tests/bug_13491.dia.ref b/scilab/modules/differential_equations/tests/nonreg_tests/bug_13491.dia.ref
new file mode 100644 (file)
index 0000000..20852e6
--- /dev/null
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Paul Bignier
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 13491 -->
+//
+// <-- Bugzilla URL -->
+//http://bugzilla.scilab.org/show_bug.cgi?id=13491
+//
+// <-- Short Description -->
+// intg now properly returns when the user function produces an error.
+deff("y = f(x)", "y = sin(x) ./ x");
+// This function is going to be evaluated by intg at the midpoint of the interval [-1; 1], so it will produce a "Division by zero" error.
+refMsg = msprintf(_("Division by zero...\n"));
+assert_checkerror("intg(-1, 1, f)", refMsg);
+deff("y = g(x)", "y = b");
+// In any evaluation point, 'b' is unknown so the function will yield an error.
+refMsg = msprintf(_("Undefined variable: %s\n"), "b");
+assert_checkerror("intg(-1, 1, g)", refMsg);
diff --git a/scilab/modules/differential_equations/tests/nonreg_tests/bug_13491.tst b/scilab/modules/differential_equations/tests/nonreg_tests/bug_13491.tst
new file mode 100644 (file)
index 0000000..0316615
--- /dev/null
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Paul Bignier
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 13491 -->
+//
+// <-- Bugzilla URL -->
+//http://bugzilla.scilab.org/show_bug.cgi?id=13491
+//
+// <-- Short Description -->
+// intg now properly returns when the user function produces an error.
+
+deff("y = f(x)", "y = sin(x) ./ x");
+// This function is going to be evaluated by intg at the midpoint of the interval [-1; 1], so it will produce a "Division by zero" error.
+refMsg = msprintf(_("Division by zero...\n"));
+assert_checkerror("intg(-1, 1, f)", refMsg);
+
+deff("y = g(x)", "y = b");
+// In any evaluation point, 'b' is unknown so the function will yield an error.
+refMsg = msprintf(_("Undefined variable: %s\n"), "b");
+assert_checkerror("intg(-1, 1, g)", refMsg);
index 0c56911..aeae565 100644 (file)
@@ -20,6 +20,9 @@ function ilib_build_jar(jarFilePath, packageNames, sourcePaths, classPaths, mani
     // Returns all the java source files contained in a path tree
     function javaFilePaths = findJavaFiles(path, javaFilePaths)
         fileNames = listfiles(path)';
+        if (isempty(fileNames)) then
+            return;
+        end
         filePaths = fullfile(path, fileNames);
 
         // First, explore sub directories
diff --git a/scilab/modules/dynamic_link/tests/nonreg_tests/bug_13471.dia.ref b/scilab/modules/dynamic_link/tests/nonreg_tests/bug_13471.dia.ref
new file mode 100644 (file)
index 0000000..4852f63
--- /dev/null
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Simon MARCHETTO
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 13471 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=13471
+//
+// <-- Short Description -->
+// Infinite loop in ilib_build_jar used on an empty dir
+//
+ilib_verbose(0);
+originalDir = pwd();
+cd(TMPDIR);
+emptyDir = fullfile(TMPDIR, 'emptyDir');
+mkdir(emptyDir);
+jarPath = fullfile(TMPDIR, 'emptyDir.jar');
+ierr = execstr('ilib_build_jar(jarPath, ''emptyDir'', emptyDir)', 'errcatch');
+cd(originalDir);
+assert_checkequal(ierr, 0);
+assert_checktrue(isfile(jarPath));
diff --git a/scilab/modules/dynamic_link/tests/nonreg_tests/bug_13471.tst b/scilab/modules/dynamic_link/tests/nonreg_tests/bug_13471.tst
new file mode 100644 (file)
index 0000000..568aa2f
--- /dev/null
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Simon MARCHETTO
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 13471 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=13471
+//
+// <-- Short Description -->
+// Infinite loop in ilib_build_jar used on an empty dir
+//
+
+ilib_verbose(0);
+originalDir = pwd();
+cd(TMPDIR);
+emptyDir = fullfile(TMPDIR, 'emptyDir');
+mkdir(emptyDir);
+jarPath = fullfile(TMPDIR, 'emptyDir.jar');
+ierr = execstr('ilib_build_jar(jarPath, ''emptyDir'', emptyDir)', 'errcatch');
+cd(originalDir);
+assert_checkequal(ierr, 0);
+assert_checktrue(isfile(jarPath));
index dec2fd7..c5cf730 100644 (file)
@@ -1,15 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
- * 
+ *
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2011 - DIGITEO - Michael Baudin
- * 
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
- * 
+ *
  -->
 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns3="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="bitxor" xml:lang="en">
     <refnamediv>
@@ -19,7 +19,7 @@
     <refsynopsisdiv>
         <title>Calling Sequence</title>
         <synopsis>
-            z = bitxor(x, y)            
+            z = bitxor(x, y)
         </synopsis>
     </refsynopsisdiv>
     <refsection>
@@ -76,7 +76,7 @@
 x = [0 1 0 1];
 y = [0 0 1 1];
 z = bitxor(x, y)
-expected = [0 1 1 1];
+expected = [0 1 1 0];
 
 // Compute the bitwise XOR of two matrices of integers.
 x = uint8([0 1 0 1]);
index 7f78de8..1b54ec1 100644 (file)
@@ -14,6 +14,7 @@ c
       integer tops
       logical refa,refb
       integer iadr,sadr
+      double precision s
 c
       iadr(l)=l+l-1
       sadr(l)=(l/2)+1
@@ -72,6 +73,14 @@ c
       ita=istk(il+3)
       la=sadr(il+4)
       mna=ma*na
+
+c     Check if there is enough free space
+      s=dble(mnb)*dble(mna)- lstk(bot)
+      if(s.gt.0.0d0) then
+         err=s
+         call error(17)
+         return
+      endif
 c
       l=sadr(ilr+4)
       l1=l+mnb*mna*(max(itb,ita)+1)
index 980d576..e2176b2 100644 (file)
  */
 
 /*--------------------------------------------------------------------------*/
+
 #include <string.h>
-#if defined(__linux__)
-#define __USE_FORTIFY_LEVEL 0 /* Avoid dependency on GLIBC_2.11 (__longjmp_chk) */
-#endif
 #include <setjmp.h>
 #include "xerhlt.h"
 /*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_10168.dia.ref b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_10168.dia.ref
new file mode 100644 (file)
index 0000000..6c9e2e5
--- /dev/null
@@ -0,0 +1,19 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 10168 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10168
+//
+// <-- Short Description -->
+// kron() produces a segfault in some cases
+a = 1:1:10000;
+b = a';
+assert_checktrue(execstr("kron(a,b)","errcatch")==17);
diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_10168.tst b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_10168.tst
new file mode 100644 (file)
index 0000000..d82a651
--- /dev/null
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 10168 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10168
+//
+// <-- Short Description -->
+// kron() produces a segfault in some cases
+
+a = 1:1:10000;
+b = a';
+assert_checktrue(execstr("kron(a,b)","errcatch")==17);
index d893408..1084cb8 100644 (file)
@@ -1,12 +1,42 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 2009-2011 - DIGITEO
-// 
+//
 // This file must be used under the terms of the CeCILL.
 // This source file is licensed as described in the file COPYING, which
 // you should have received as part of this distribution.  The terms
-// are also available at    
+// are also available at
 // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 
 //Load  functions libraries
 // =============================================================================
-  load('SCI/modules/fileio/macros/lib');
+load('SCI/modules/fileio/macros/lib');
+
+// Initialize CURL environment
+// =============================================================================
+if getos()=="Linux" then
+
+    // List of hard-coded paths comes from curl sources (configure.ac)
+
+    userBundle = getenv("CURL_CA_BUNDLE", "");
+    if isempty(userBundle) then // Not defined by the user
+
+        standardFiles = ["/etc/ssl/certs/ca-certificates.crt";
+                "/etc/pki/tls/certs/ca-bundle.crt";
+                "/usr/share/ssl/certs/ca-bundle.crt";
+                "/usr/local/share/certs/ca-root.crt";
+                "/etc/ssl/cert.pem"];
+
+        for iFile = 1:size(standardFiles, "*")
+            if isfile(standardFiles(iFile)) then
+                setenv("CURL_CA_BUNDLE", standardFiles(iFile));
+                break
+            end
+        end
+    end
+
+    caBundle = getenv("CURL_CA_BUNDLE", "");
+    caPath = getenv("CURL_CA_PATH", "");
+    if isempty(caBundle) & isempty(caPath) then
+        setenv("CURL_CA_PATH", "/etc/ssl/certs/");
+    end
+end
index 8f8f7dd..5acd573 100644 (file)
@@ -10,9 +10,7 @@
 *
 */
 /*--------------------------------------------------------------------------*/
-#if defined(__linux__)
-#undef _FORTIFY_SOURCE /* Avoid dependency on GLIBC_2.4 (__wcscat_chk/__wcscpy_chk) */
-#endif
+
 #ifndef _MSC_VER
 #include <errno.h>
 #else
index ca2362f..7129e62 100644 (file)
@@ -10,9 +10,7 @@
 *
 */
 /*--------------------------------------------------------------------------*/
-#if defined(__linux__)
-#undef _FORTIFY_SOURCE /* Avoid dependency on GLIBC_2.4 (__wcscat_chk/__wcscpy_chk) */
-#endif
+
 #ifndef _MSC_VER
 #include <errno.h>
 #else
index 84d2bf9..874120a 100644 (file)
@@ -10,9 +10,6 @@
 *
 */
 /*--------------------------------------------------------------------------*/
-#if defined(__linux__)
-#undef _FORTIFY_SOURCE /* Avoid dependency on GLIBC_2.4 (__wcscat_chk/__wcscpy_chk) */
-#endif
 #include "getFullFilename.h"
 #include "charEncoding.h"
 #include "MALLOC.h"
index 74610b4..826bbeb 100644 (file)
@@ -13,7 +13,7 @@
 // <-- Short Description -->
 // listvarinfile does not manage graphic handles
 clear;
-warning('off')
+warning("off")
 //figure
 hF = figure();
 //axes + plot3d
@@ -28,7 +28,7 @@ scf();
 t = [0 : 0.3 : 2*%pi]';
 z = sin(t) * cos(t');
 [xx, yy, zz] = genfac3d(t, t, z);
-plot3d([xx xx],[yy yy],list([zz zz+4],[4*ones(1,400) 5*ones(1,400)])) 
+plot3d([xx xx],[yy yy],list([zz zz+4],[4*ones(1,400) 5*ones(1,400)]))
 hFac3d = gce();
 clear t z xx yy zz;
 //Rectangle
@@ -64,7 +64,7 @@ scf();
 x = [0 1 0 -1];
 y = [0 0 1  1];
 T = [1 1 2 3 1;
-     2 3 4 1 1];
+2 3 4 1 1];
 z = [0 1 0 -1];
 fec(x, y, T, z, strf="040", mesh=%t)
 hFec = gce();
@@ -75,13 +75,13 @@ hText = gce();
 //Axis
 scf();
 plot2d(1:10,1:10,1,"020")
-// horizontal axis 
-drawaxis(x=2:7,y=4,dir='u',tics='v')
+// horizontal axis
+drawaxis(x=2:7,y=4,dir="u",tics="v");
 hAxis = gce();
 //uimenu
-hMenu = uimenu(hF,'label', 'windows');
+hMenu = uimenu(hF,"label", "windows");
 //uicontrol
-hUiControl = uicontrol(hF,'style','listbox', 'position', [10 10 150 160]);
+hUiControl = uicontrol(hF,"style","listbox", "position", [10 10 150 160]);
 save(TMPDIR + "/bug_4339.bin", hUiControl, hMenu, hAxis, hText, hFec, hMatplot, hGrayplot, hSeg, hChamp, hArc, hRectangle, hFac3d, hPlot2d, hPlot3d, hF);
 [varList, varSize] = listvarinfile(TMPDIR + "/bug_4339.bin");
 varListRef = ["hUiControl"; "hMenu"; "hAxis"; "hText"; "hFec"; "hMatplot"; "hGrayplot"; "hSeg"; "hChamp"; "hArc"; "hRectangle"; "hFac3d"; "hPlot2d"; "hPlot3d"; "hF"];
index ba2b823..07d8f94 100644 (file)
@@ -14,7 +14,7 @@
 // listvarinfile does not manage graphic handles
 
 clear;
-warning('off')
+warning("off")
 //figure
 hF = figure();
 
@@ -32,7 +32,7 @@ scf();
 t = [0 : 0.3 : 2*%pi]';
 z = sin(t) * cos(t');
 [xx, yy, zz] = genfac3d(t, t, z);
-plot3d([xx xx],[yy yy],list([zz zz+4],[4*ones(1,400) 5*ones(1,400)])) 
+plot3d([xx xx],[yy yy],list([zz zz+4],[4*ones(1,400) 5*ones(1,400)]))
 hFac3d = gce();
 clear t z xx yy zz;
 //Rectangle
@@ -74,7 +74,7 @@ scf();
 x = [0 1 0 -1];
 y = [0 0 1  1];
 T = [1 1 2 3 1;
-     2 3 4 1 1];
+2 3 4 1 1];
 z = [0 1 0 -1];
 fec(x, y, T, z, strf="040", mesh=%t)
 hFec = gce();
@@ -87,15 +87,15 @@ hText = gce();
 //Axis
 scf();
 plot2d(1:10,1:10,1,"020")
-// horizontal axis 
-drawaxis(x=2:7,y=4,dir='u',tics='v')
+// horizontal axis
+drawaxis(x=2:7,y=4,dir="u",tics="v");
 hAxis = gce();
 
 //uimenu
-hMenu = uimenu(hF,'label', 'windows');
+hMenu = uimenu(hF,"label", "windows");
 
 //uicontrol
-hUiControl = uicontrol(hF,'style','listbox', 'position', [10 10 150 160]);
+hUiControl = uicontrol(hF,"style","listbox", "position", [10 10 150 160]);
 
 save(TMPDIR + "/bug_4339.bin", hUiControl, hMenu, hAxis, hText, hFec, hMatplot, hGrayplot, hSeg, hChamp, hArc, hRectangle, hFac3d, hPlot2d, hPlot3d, hF);
 
index ff05995..6c2a029 100644 (file)
@@ -67,8 +67,9 @@
                 <term>Log</term>
                 <listitem>
                     <para>
-                        if %T, we will display to information message during the run
-                        of the genetic algorithm.
+                        if %T, will call the output function at the end of each
+                        iteration, see <literal>"output_func"</literal> under
+                        <varname>param</varname> variable below.
                     </para>
                 </listitem>
             </varlistentry>
                             <para>
                                 "codage_func": the function which will perform the coding
                                 and decoding of individuals (default function:
-                                coding_ga_identity).
+                                <link linkend="coding_ga_identity">coding_ga_identity</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para>
                                 "init_func": the function which will perform the
                                 initialization of the population (default function:
-                                init_ga_default).
+                                <link linkend="init_ga_default">init_ga_default</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para>
                                 "crossover_func": the function which will perform the
                                 crossover between two individuals (default function:
-                                crossover_ga_default).
+                                <link linkend="crossover_ga_default">crossover_ga_default</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para>
                                 "mutation_func": the function which will perform the
                                 mutation of one individual (default function:
-                                mutation_ga_default).
+                                <link linkend="mutation_ga_default">mutation_ga_default</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para>
-                                "selection_func": the function whcih will perform the
+                                "selection_func": the function which will perform the
                                 selection of individuals at the end of a generation (default
-                                function: selection_ga_elitist).
+                                function: <link linkend="selection_ga_elitist">selection_ga_elitist</link>).
                             </para>
                         </listitem>
                         <listitem>
                         </listitem>
                         <listitem>
                             <para>
-                                "pressure": the value the efficiency of the worst
+                                "pressure": the value of the efficiency of the worst
                                 individual (default value: 0.05).
                             </para>
                         </listitem>
+                        <listitem>
+                            <para>
+                                "output_func": a callback function called after each
+                                generation if <varname>Log</varname> is %T (default
+                                function <link linkend="output_ga_default">output_ga_default</link>).
+                            </para>
+                        </listitem>
                     </itemizedlist>
                 </listitem>
             </varlistentry>
             <literal>optim_ga</literal> function.
             This flexibility is provided by the various functions which
             can be set in the <literal>param</literal> variable.
-            In order to analyze the header of these functions (i.e.
-            the input and output arguments), we may read the help page
+            The header of these functions (i.e.
+            the input and output arguments), can be checked through the help page
             corresponding to the default function.
             For example, in order to understand what are the input and output arguments of the
-            "codage_func" function, we may read the page of the <literal>coding_identity</literal> function.
+            <literal>"codage_func"</literal> function, please refer to the help page of the <link linkend="coding_ga_identity">coding_identity</link> function.
         </para>
         <para>
-            See in the Demonstrations for more examples for this function.
+            See the Demonstrations for more examples for this function.
         </para>
     </refsection>
     <refsection>
         <para>
             The following session presents the simplest possible example.
             We minimize a quadratic function in dimension 3.
-            By default, all the parameters are taken in the interval 
+            By default, all the parameters are taken in the interval
             [0,1]^3.
-            The "dimension" field is passed to the function which computes the 
-            initial population, which is <literal>init_ga_default</literal> 
+            The "dimension" field is passed to the function which computes the
+            initial population, which is <literal>init_ga_default</literal>
             function by default.
             In the case where the "dimension" field is not customized,
             the default value is used, which is equal to 2.
         </para>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
 function y=f(x)
   y = sum(x.^2)
 endfunction
@@ -222,7 +230,7 @@ ga_params = add_param(ga_params,"dimension",3);
             In the following script, we compute some basic statistics about the
             optimum population and get the best and the worst points.
         </para>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
 // Display basic statistics
 // min, mean and max function values of the population.
 disp([min(fobj_pop_opt) mean(fobj_pop_opt) max(fobj_pop_opt)])
@@ -234,18 +242,31 @@ xmin = pop_opt(k)
 xmax = pop_opt(k)
  ]]></programlisting>
         <para>
-            In the following example, we customize all the options 
+            In the following example, we customize all the options
             in order to show all the features of the algorithm.
         </para>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
+// Objective function
 function y=f(x)
   y = sum(x.^2)
 endfunction
 
+// Output function with a stop criterion
+function stop = output_ga_custom(gen_index, nb_generation, Pop, FObj_Pop, param)
+    [threshold, err] = get_param(param, "threshold", 1E-10); // default value for the threshold
+    printf(_("%s: iteration %d / %d \n"), "optim_ga", gen_index, nb_generation);
+    printf(_("    min / max value found = %.4E / %.4E\n"), min(FObj_Pop), max(FObj_Pop));
+    stop = %f
+    if abs(max(FObj_Pop) - min(FObj_Pop)) < threshold then
+        printf(_("    Stop criterion reached: Delta Max to Min under threshold"));
+        stop = %t
+    end
+endfunction
+
 PopSize     = 100;
 Proba_cross = 0.7;
 Proba_mut   = 0.1;
-NbGen       = 10;
+NbGen       = 20;
 NbCouples   = 110;
 Log         = %T;
 pressure    = 0.05;
@@ -257,18 +278,23 @@ ga_params = add_param(ga_params,"maxbound",[2; 2]);
 ga_params = add_param(ga_params,"dimension",2);
 ga_params = add_param(ga_params,"beta",0);
 ga_params = add_param(ga_params,"delta",0.1);
-// Parameters to fine tune the Genetic algorithm. 
+// Parameters to fine tune the Genetic algorithm.
 // All these parameters are optional for continuous optimization
-// If you need to adapt the GA to a special problem, you 
+// If you need to adapt the GA to a special problem, you
 ga_params = add_param(ga_params,"init_func",init_ga_default);
 ga_params = add_param(ga_params,"crossover_func",crossover_ga_default);
 ga_params = add_param(ga_params,"mutation_func",mutation_ga_default);
 ga_params = add_param(ga_params,"codage_func",coding_ga_identity);
 ga_params = add_param(ga_params,"selection_func",selection_ga_elitist);
+
 //ga_params = add_param(ga_params,"selection_func",selection_ga_random);
 ga_params = add_param(ga_params,"nb_couples",NbCouples);
 ga_params = add_param(ga_params,"pressure",pressure);
 
+// Customized output function with a stop criterion added
+ga_params = add_param(ga_params, "threshold", 1E-6); // User defined parameter for the output function
+ga_params = add_param(ga_params, "output_func", output_ga_custom);
+
 [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = ..
   optim_ga(f, PopSize, NbGen, Proba_mut, Proba_cross, Log, ga_params);
  ]]></programlisting>
@@ -276,23 +302,23 @@ ga_params = add_param(ga_params,"pressure",pressure);
     <refsection>
         <title>Customizing the initial population</title>
         <para>
-            In the following example, we customize the init function, 
+            In the following example, we customize the init function,
             which computes the initial population.
-            In the <literal>myinitga</literal> function, we use the grand function 
+            In the <literal>myinitga</literal> function, we use the grand function
             (instead of the default rand used in
             init_ga_default).
-            We could use any other type of population generator, including, 
-            for example, a low discrepancy sequence such as the Halton or Sobol 
+            We could use any other type of population generator, including,
+            for example, a low discrepancy sequence such as the Halton or Sobol
             sequence.
         </para>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
 function y=f(x)
   y = sum(x.^2)
 endfunction
 
 function Pop_init = myinitga ( popsize , param )
   // This message is to be displayed in the console
-  // for demonstration purpose only : 
+  // for demonstration purpose only :
   // remove it in a real application!
   disp("Initializing the Population with grand")
   // We deal with some parameters to take into account
@@ -300,7 +326,7 @@ function Pop_init = myinitga ( popsize , param )
   [Dim,err]       = get_param(param,"dimension",2)
   [MinBounds,err] = get_param(param,"minbound",-2*ones(1,Dim))
   [MaxBounds,err] = get_param(param,"maxbound",2*ones(1,Dim))
-  
+
   // Pop_init must be a list()
   Pop_init = list()
   nr = size(MaxBounds,1)
@@ -334,17 +360,17 @@ ga_params = add_param(ga_params,"init_func",myinitga);
         <para>
             In some cases, the objective function needs additional parameters
             in order to be evaluated.
-            In this case, we can pass a list to the <literal>optim_ga</literal> 
-            function, where the first element of the list is the function and the 
+            In this case, we can pass a list to the <literal>optim_ga</literal>
+            function, where the first element of the list is the function and the
             remaining elements are the extra parameters.
         </para>
         <para>
             This is done in the following script, where the function <literal>f</literal>
             needs the two extra parameters <literal>a1</literal> and <literal>a2</literal>.
-            This is why we define the list <literal>myobjfun</literal> and 
+            This is why we define the list <literal>myobjfun</literal> and
             pass it to the <literal>optim_ga</literal> solver.
         </para>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
 function y = f ( x , a1 , a2 )
   y = a1*sum(x.^2) + a2
 endfunction
index bd27ddd..2969120 100644 (file)
@@ -28,7 +28,7 @@
                     <para>the function to be optimized. The header of the function is
                         the following :
                     </para>
-                    <programlisting role=""><![CDATA[ 
+                    <programlisting role=""><![CDATA[
 y = f(x)
  ]]></programlisting>
                     <para>or</para>
@@ -69,8 +69,10 @@ y = list(f,p1,p2,...)
             <varlistentry>
                 <term>Log</term>
                 <listitem>
-                    <para>if %T, we will display to information message during the run
-                        of the genetic algorithm.
+                    <para>
+                        if %T, will call the output function at the end of each
+                        iteration, see <literal>"output_func"</literal> under
+                        <varname>param</varname> variable below.
                     </para>
                 </listitem>
             </varlistentry>
@@ -81,13 +83,13 @@ y = list(f,p1,p2,...)
                     <itemizedlist>
                         <listitem>
                             <para>'codage_func': the function which will perform the coding
-                                and decoding of individuals (default function: codage_identity).
+                                and decoding of individuals (default function: <link linkend="coding_ga_identity">coding_ga_identity</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para> 'init_func': the function which will perform the
                                 initialization of the population (default function:
-                                init_ga_default). 
+                                <link linkend="init_ga_default">init_ga_default</link>).
                             </para>
                         </listitem>
                         <listitem>
@@ -99,25 +101,25 @@ y = list(f,p1,p2,...)
                         <listitem>
                             <para> 'crossover_func': the function which will perform the
                                 crossover between two individuals (default function:
-                                crossover_ga_default). 
+                                <link linkend="crossover_ga_default">crossover_ga_default</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para> 'mutation_func': the function which will perform the
                                 mutation of one individual (default function:
-                                mutation_ga_default). 
+                                <link linkend="mutation_ga_default">mutation_ga_default</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para> 'selection_func': the function whcih will perform the
                                 selection of individuals at the end of a generation (default
-                                function: selection_ga_elitist). 
+                                function: <link linkend="selection_ga_elitist">selection_ga_elitist</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para>'nb_couples': the number of couples which will be selected
                                 so as to perform the crossover and mutation (default value:
-                                100). 
+                                100).
                             </para>
                         </listitem>
                         <listitem>
@@ -125,6 +127,13 @@ y = list(f,p1,p2,...)
                                 individual (default value: 0.05).
                             </para>
                         </listitem>
+                        <listitem>
+                            <para>
+                                "output_func": a callback function called after each
+                                generation if <varname>Log</varname> is %T (default
+                                function <literal>output_moga_default</literal>).
+                            </para>
+                        </listitem>
                     </itemizedlist>
                 </listitem>
             </varlistentry>
@@ -172,7 +181,7 @@ y = list(f,p1,p2,...)
     
     <refsection>
         <title>Examples</title>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
 function f = deb_1(x)
    f1_x1 = x(1);
    g_x2  = 1 + 9 * sum((x(2:$)-x(1)).^2) / (length(x) - 1);
index d52fb59..7c4c5ea 100644 (file)
             <varlistentry>
                 <term>Log</term>
                 <listitem>
-                    <para>if %T, we will display to information message during the run
-                        of the genetic algorithm.
+                    <para>
+                        if %T, will call the output function at the end of each
+                        iteration, see <literal>"output_func"</literal> under
+                        <varname>param</varname> variable below.
                     </para>
                 </listitem>
             </varlistentry>
                     <itemizedlist>
                         <listitem>
                             <para> 'codage_func': the function which will perform the coding
-                                and decoding of individuals (default function: codage_identity).
+                                and decoding of individuals (default function: <link linkend="coding_ga_identity">coding_ga_identity</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para> 'init_func': the function which will perform the
                                 initialization of the population (default function:
-                                init_ga_default). 
+                                <link linkend="init_ga_default">init_ga_default</link>).
                             </para>
                         </listitem>
                         <listitem>
                         <listitem>
                             <para> 'crossover_func': the function which will perform the
                                 crossover between two individuals (default function:
-                                crossover_ga_default). 
+                                <link linkend="crossover_ga_default">crossover_ga_default</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para> 'mutation_func': the function which will perform the
                                 mutation of one individual (default function:
-                                mutation_ga_default). 
+                                <link linkend="mutation_ga_default">mutation_ga_default</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para> 'selection_func': the function whcih will perform the
                                 selection of individuals at the end of a generation (default
-                                function: selection_ga_elitist). 
+                                function: <link linkend="selection_ga_elitist">selection_ga_elitist</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para> 'nb_couples': the number of couples which will be
                                 selected so as to perform the crossover and mutation (default
-                                value: 100). 
+                                value: 100).
                             </para>
                         </listitem>
                         <listitem>
                                 individual (default value: 0.05).
                             </para>
                         </listitem>
+                        <listitem>
+                            <para>
+                                "output_func": a callback function called after each
+                                generation if <varname>Log</varname> is %T (default
+                                function <literal>output_nsga_default</literal>).
+                            </para>
+                        </listitem>
                     </itemizedlist>
                 </listitem>
             </varlistentry>
     </refsection>
     <refsection>
         <title>Examples</title>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
 function f = deb_1(x)
    f1_x1 = x(1);
    g_x2  = 1 + 9 * sum((x(2:$)-x(1)).^2) / (length(x) - 1);
index 2f24b02..dda910c 100644 (file)
             <varlistentry>
                 <term>Log</term>
                 <listitem>
-                    <para>if %T, we will display to information message during the run
-                        of the genetic algorithm.
+                    <para>
+                        if %T, will call the output function at the end of each
+                        iteration, see <literal>"output_func"</literal> under
+                        <varname>param</varname> variable below.
                     </para>
                 </listitem>
             </varlistentry>
                     <itemizedlist>
                         <listitem>
                             <para> 'codage_func': the function which will perform the coding
-                                and decoding of individuals (default function: codage_identity).
+                                and decoding of individuals (default function: <link linkend="coding_ga_identity">coding_ga_identity</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para> 'init_func': the function which will perform the
                                 initialization of the population (default function:
-                                init_ga_default). 
+                                <link linkend="init_ga_default">init_ga_default</link>).
                             </para>
                         </listitem>
                         <listitem>
                         <listitem>
                             <para> 'crossover_func': the function which will perform the
                                 crossover between two individuals (default function:
-                                crossover_ga_default). 
+                                <link linkend="crossover_ga_default">crossover_ga_default</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para> 'mutation_func': the function which will perform the
                                 mutation of one individual (default function:
-                                mutation_ga_default). 
+                                <link linkend="mutation_ga_default">mutation_ga_default</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para> 'selection_func': the function whcih will perform the
                                 selection of individuals at the end of a generation (default
-                                function: selection_ga_elitist). 
+                                function: <link linkend="selection_ga_elitist">selection_ga_elitist</link>).
                             </para>
                         </listitem>
                         <listitem>
                             <para> 'nb_couples': the number of couples which will be
                                 selected so as to perform the crossover and mutation (default
-                                value: 100). 
+                                value: 100).
                             </para>
                         </listitem>
                         <listitem>
                                 individual (default value: 0.05).
                             </para>
                         </listitem>
+                        <listitem>
+                            <para>
+                                "output_func": a callback function called after each
+                                generation if <varname>Log</varname> is %T (default
+                                function <literal>output_nsga2_default</literal>).
+                            </para>
+                        </listitem>
                     </itemizedlist>
                 </listitem>
             </varlistentry>
     </refsection>
     <refsection>
         <title>Examples</title>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
 function f = deb_1(x)
    f1_x1 = x(1);
    g_x2  = 1 + 9 * sum((x(2:$)-x(1)).^2) / (length(x) - 1);
index 16a9e19..faec260 100644 (file)
@@ -2,6 +2,8 @@
 <!--
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2008 - Yann COLLETTE <yann.collette@renault.com>
+ * Copyright (C) 2014 - Michael BAUDIN <michael.baudin@contrib.scilab.org>
+ * Copyright (C) Scilab Enterprises - 2014 - Pierre-Aime AGNEL
  *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
@@ -17,7 +19,7 @@
     </refnamediv>
     <refsynopsisdiv>
         <title>Calling Sequence</title>
-        <synopsis>[Crossed_Indiv1,Crossed_Indiv2] = crossover_ga_binary(Indiv1,Indiv2,param)</synopsis>
+        <synopsis>[Crossed_Indiv1, Crossed_Indiv2, mix] = crossover_ga_binary(Indiv1, Indiv2, param)</synopsis>
     </refsynopsisdiv>
     <refsection>
         <title>Arguments</title>
@@ -25,6 +27,7 @@
             <varlistentry>
                 <term>Indiv1</term>
                 <listitem>
+                    <para>A string</para>
                     <para>the first individual (here a binary code) to be
                         crossed-over.
                     </para>
             <varlistentry>
                 <term>Indiv2</term>
                 <listitem>
+                    <para>A string</para>
                     <para>the second individual to be crossed-over.</para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>param</term>
                 <listitem>
-                    <para>a list of parameters. </para>
+                    <para>a list of parameters.</para>
                     <itemizedlist>
                         <listitem>
-                            <para> 'binary_length': the length of the binary code. </para>
+                            <para>
+                                <literal>"binary_length"</literal>: an integer, the length of the binary
+                                code (default 8).
+                            </para>
                         </listitem>
                         <listitem>
-                            <para> 'multi_cross': a boolean. If %T then we allow several
-                                cuts in the binary code. 
+                            <para>
+                                <literal>"multi_cross"</literal>: a boolean. If <literal>%T</literal> then we allow several
+                                cuts in the binary code (default <literal>%F</literal>).
                             </para>
                         </listitem>
                         <listitem>
-                            <para> 'multi_cross_nb': the number of cuts in the binary code.
-                                Only used when multi_cross is set to %T.
+                            <para>
+                                <literal>"multi_cross_nb"</literal>: an integer, the number of cuts in the binary code.
+                                Only used when multi_cross is set to %T (default 2).
                             </para>
                         </listitem>
                     </itemizedlist>
@@ -60,6 +69,7 @@
             <varlistentry>
                 <term>Crossed_Indiv1</term>
                 <listitem>
+                    <para>A string</para>
                     <para>The first individual obtained by the cross-over
                         function.
                     </para>
             <varlistentry>
                 <term>Crossed_Indiv2</term>
                 <listitem>
+                    <para>A string</para>
                     <para>The second individual obtained by the cross-over
                         function.
                     </para>
                 </listitem>
             </varlistentry>
+            <varlistentry>
+                <term>mix</term>
+                <listitem>
+                    <para>A vector of integers</para>
+                    <para>The positions the crossover occurred.</para>
+                </listitem>
+            </varlistentry>
         </variablelist>
     </refsection>
     <refsection>
         <title>Description</title>
-        <itemizedlist>
-            <listitem>
-                <para>This function implements a classical binary cross-over.</para>
-            </listitem>
-        </itemizedlist>
+        <para>This function implements a classical binary cross-over.</para>
+        <para>
+            <literal>crossover_ga_binary(Indiv1, Indiv2)</literal> generates
+            the crossover between <varname>Indiv1</varname> and <varname>Indiv2</varname>
+            by merging the characters from each string.
+        </para>
+        <para>
+            A position <literal>i</literal> is chosen randomly
+            between 1 and the length of the binary code.
+        </para>
+        <para>
+            Then <literal>Indiv1</literal> and <literal>Indiv2</literal>
+            are split in two parts:
+            the first <literal>i</literal> characters (the head),
+            and the remaining characters (the tail).
+            The crossover swaps the tails of the binary codes.
+        </para>
+        <para>
+            The following schema presents the crossover:
+            <programlisting role="explanation"><![CDATA[
+                Indiv1=[H1 T1]
+                Indiv2=[H2 T2]
+                Crossed_Indiv1=[H1 T2]
+                Crossed_Indiv2=[H2 T1]
+                ]]></programlisting>
+        </para>
+        <para>
+            The behaviour of the function can be modified with the use of <varname>param</varname>:
+        </para>
+        <variablelist>
+            <varlistentry>
+                <term>
+                    binary_length
+                </term>
+                <listitem>
+                    <para>
+                        changes the minimal length of the binary code, by default 8 characters.
+                    </para>
+                    <para>
+                        Binary code for <varname>Indiv1</varname> or <varname>Indiv2</varname>
+                        of lower length are zero padded to the right to be of
+                        <literal>binary_length</literal> length or <literal>max([length(Indiv1), length(Indiv2)])</literal>
+                        whichever is greater.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>multi_cross</term>
+                <listitem>
+                    <para>
+                        if set to <literal>%T</literal> multiple crossovers
+                        can happen (default <literal>%F</literal>)
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>multi_cross_nb</term>
+                <listitem>
+                    <para>
+                        the number of locations for crossovers.
+                        (default 2 if
+                        multi_cross is set to <literal>%T</literal>, 1 otherwise)
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title> Random number generator </title>
+        <para>
+            <literal>crossover_ga_binary</literal> is based
+            on <link linkend="grand">grand</link>
+            for generating the random samples.
+            Use <literal>grand("setsd", seed)</literal> to change the seed
+            for <literal>crossover_ga_binary</literal>.
+        </para>
+        <programlisting role="example"><![CDATA[
+            seed = getdate("s");
+            grand("setsd", seed); //sets the seed to current date
+
+            seed = 0;
+            grand("setsd", seed); //sets the seed to default value
+            ]]>
+        </programlisting>
+    </refsection>
+    <refsection>
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[
+            A = "11100000"
+            B = "00011111"
+            [A_crossed, B_crossed, mix] = crossover_ga_binary(A, B)
+
+            C = dec2bin(2^16 - 1, 16)
+            D = "0"
+            param = init_param();
+            param = add_param(param, "binary_length", 16);  // Code of length 16
+            param = add_param(param, "multi_cross", %T);    // Multiple Crossover
+            param = add_param(param, "multi_cross_nb", 3);  // Occurs over 3 locations
+
+            [C_crossed, D_crossed, mix] = crossover_ga_binary(C, D, param)
+ ]]></programlisting>
     </refsection>
     <refsection role="see also">
         <title>See Also</title>
             <member>
                 <link linkend="optim_ga"> optim_ga </link>
             </member>
+            <member>
+                <link linkend="grand">grand</link>
+            </member>
         </simplelist>
     </refsection>
 </refentry>
index 4e1162b..65c5070 100644 (file)
@@ -18,7 +18,7 @@
     </refnamediv>
     <refsynopsisdiv>
         <title>Calling Sequence</title>
-        <synopsis>Mut_Indiv = mutation_ga_binary(Indiv,param)</synopsis>
+        <synopsis>[Mut_Indiv, pos] = mutation_ga_binary(Indiv,param)</synopsis>
     </refsynopsisdiv>
     <refsection>
         <title>Arguments</title>
             <varlistentry>
                 <term>Indiv</term>
                 <listitem>
-                    <para>the individual on which we will perform the mutation.</para>
+                    <para>A string.</para>
+                    <para>The individual on which we will perform the mutation.</para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>param</term>
                 <listitem>
-                    <para>a list of parameters. </para>
+                    <para>a list of parameters.</para>
                     <itemizedlist>
                         <listitem>
-                            <para> "binary_length": the size of the binary code. </para>
+                            <para> "binary_length": an integer scalar, the size of the binary code. </para>
                         </listitem>
                         <listitem>
                             <para> "multi_mut": a boolean. If %T, several random bits will
@@ -43,8 +44,8 @@
                             </para>
                         </listitem>
                         <listitem>
-                            <para> "multi_mut_nd": the number of bits to be flipped. Works
-                                only when multi_mut is set to %T.
+                            <para> "multi_mut_nb": an integer scalar, the number of bits to be flipped.
+                                Only used when multi_mut is set to %T (default 2).
                             </para>
                         </listitem>
                     </itemizedlist>
             <varlistentry>
                 <term>Mut_Indiv</term>
                 <listitem>
-                    <para>The mutated individual.</para>
+                    <para>
+                        A string.
+                    </para>
+                    <para>
+                        The mutated individual.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>pos</term>
+                <listitem>
+                    <para>
+                        A vector of integers.
+                    </para>
+                    <para>
+                        The positions of the mutated bits.
+                    </para>
                 </listitem>
             </varlistentry>
         </variablelist>
             This function performs a classical multi-bits binary
             mutation.
         </para>
+        <para>
+            This generates the individual <varname>Mut_Indiv</varname> by inverting bits on random positions.
+        </para>
+        <para>
+            By default <literal>mutation_ga_binary(Indiv)</literal> selects randomly
+            an index <literal>i</literal> between 1 and <literal>length(Indiv)</literal>.
+            It then modifies the i-th character of Indiv to 1 if it was 0, or 0 if it was 1.
+        </para>
+        <para>
+            If <literal>"multi_mut"</literal> is set to <literal>%T</literal> multiple mutations may occur.
+            The maximal number of mutation is given by <literal>"multi_mut_nb"</literal>.
+        </para>
+    </refsection>
+    <refsection>
+        <title> Random number generator </title>
+        <para>
+            <literal>mutation_ga_binary</literal> is based
+            on <link linkend="grand">grand</link>
+            for generating the random samples.
+            Use <literal>grand("setsd", seed)</literal> to change the seed
+            for <literal>crossover_ga_binary</literal>.
+        </para>
+        <programlisting role="example"><![CDATA[
+            seed = getdate("s");
+            grand("setsd", seed); //sets the seed to current date
+
+            seed = 0;
+            grand("setsd", seed); //sets the seed to default value
+            ]]>
+        </programlisting>
+    </refsection>
+    <refsection>
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[
+            Indiv="00010000"
+            [Mut_Indiv, pos] = mutation_ga_binary(Indiv)
+            
+            // With multiple mutation
+            param=init_param("multi_mut",%t,"multi_mut_nb",3);
+            Indiv="00010000"
+            [Mut_Indiv, pos] = mutation_ga_binary(Indiv,param)
+ ]]></programlisting>
     </refsection>
     <refsection role="see also">
         <title>See Also</title>
diff --git a/scilab/modules/genetic_algorithms/help/en_US/utilities/output_ga_default.xml b/scilab/modules/genetic_algorithms/help/en_US/utilities/output_ga_default.xml
new file mode 100644 (file)
index 0000000..15e5c74
--- /dev/null
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2014 - Michael BAUDIN <michael.baudin@contrib.scilab.org>
+ * Copyright (C) 2014 - Scilab Enterprises - Pierre-Aime AGNEL
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns3="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="output_ga_default" xml:lang="en">
+    <refnamediv>
+        <refname>output_ga_default</refname>
+        <refpurpose>A simple output function used for logging purposes</refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>Calling Sequence</title>
+        <synopsis>stop = output_ga_default(gen_index, nb_generation, Pop, FObj_Pop, param)</synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>Arguments</title>
+        <variablelist>
+            <varlistentry>
+                <term>gen_index</term>
+                <listitem>
+                    <para>The index of the current generation.</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>nb_generation</term>
+                <listitem>
+                    <para>The maximum number of generations.</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>Pop</term>
+                <listitem>
+                    <para>The current population.</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>FObj_Pop</term>
+                <listitem>
+                    <para>The evaluation for each member of the population.</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>param</term>
+                <listitem>
+                    <para>A parameter list for optional parameters.</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>stop</term>
+                <listitem>
+                    <para>A boolean. If %F, will stop the execution of the genetic algorithm.</para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>Description</title>
+        <para>
+            This function displays information on the current step of the genetic algorithm.
+        </para>
+        <para>
+            Use this function to implement a callback after each iteration of the genetic algorithm.
+            This can be used, for instance, to plot intermediate result or log more information on
+            the population.
+        </para>
+        <para>
+            The output parameter <varname>stop</varname> can be used to stop the genetic algorithm
+            altogether if set to %F.
+        </para>
+    </refsection>
+    <refsection role="see also">
+        <title>See Also</title>
+        <simplelist type="inline">
+            <member>
+                <link linkend="optim_moga"> optim_moga </link>
+            </member>
+            <member>
+                <link linkend="optim_nsga"> optim_nsga </link>
+            </member>
+            <member>
+                <link linkend="optim_nsga2"> optim_nsga2 </link>
+            </member>
+        </simplelist>
+    </refsection>
+</refentry>
index 4058555..61fa265 100644 (file)
@@ -1,5 +1,7 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 2008 - Yann COLLETTE <yann.collette@renault.com>
+// Copyright (C) 2014 - Michael BAUDIN <michael.baudin@contrib.scilab.org>
+// Copyright (C) Scilab Enterprises - 2014 - Pierre-Aime AGNEL
 //
 // This file must be used under the terms of the CeCILL.
 // This source file is licensed as described in the file COPYING, which
@@ -7,39 +9,82 @@
 // are also available at
 // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 
-function [Crossed_Indiv1, Crossed_Indiv2] = crossover_ga_binary(Indiv1,Indiv2,param)
+//==============================================================================
+// crossover_ga_binary
+//==============================================================================
+// INPUT
+//    Indiv1 = A string representing a binary code
+//    Indiv2 = A strings representing a binary code
+//    param  = A plist with the following parameters
+//        binary_length  = an integer, the length of the binary code (def. 8)
+//        multi_cross    = a boolean, flag for multiple crossovers (def. %f)
+//        multi_cross_nb = an integer, number of multiple crossovers (def. 2)
+//
+// OUTPUT
+//    Crossed_Indiv1 = A string,
+//                     result of the cross over for Indiv1
+//    Crossed_Indiv2 = A string,
+//                     result of the cross over for Indiv2
+//    mix            = a vector of double, the positions
+//                      where the crossover was done
+//
+// DESCRIPTION
+//    Function crossover_ga_binary generates the crossover between
+//    Indiv1 and Indiv2 taken as binary code.
+//
+//    Without any additional parameters crossover_ga_binary(Indiv1, Indiv2)
+//    returns the crossover occruring on a single random location
+//
+//    crossover_ga_binary(Indiv1, Indiv2, param) modifies its behaviour
+//    with the values of param:
+//        binary_length:
+//            length of the binary code (default 8)
+//        multi_cross:
+//            if set to %t multiple crossover can happen (default %f)
+//        multi_cross_nb:
+//            the maximal number of possible crossovers.
+//            (default 2 if
+//            multi_cross is set to %t, 1 otherwise)
+//            At least one crossover will occur.
+
+function [Crossed_Indiv1, Crossed_Indiv2, mix] = crossover_ga_binary(Indiv1,Indiv2,param)
+
+    fname = "crossover_ga_binary";
     if ~isdef("param","local") then
         param = [];
     end
 
     // We deal with some parameters to take into account the boundary of the domain and the neighborhood size
-    [BinLen,err]       = get_param(param,"binary_length",8);
-    [MultiCross,err]   = get_param(param,"multi_cross",%F);
-    [MultiCrossNb,err] = get_param(param,"multi_cross_nb",2);
+    [BinLen, errLen] = get_param(param, "binary_length", 8);
+    [MultiCross, errMultiCross] = get_param(param, "multi_cross", %F);
+    if MultiCross
+        [MultiCrossNb, errMultiCrossNb] = get_param(param, "multi_cross_nb", 2);
+    else
+        MultiCrossNb = 1;
+    end
+
+    len1 = length(Indiv1);
+    len2 = length(Indiv2);
+    BinLen = max([len1, len2, BinLen]);
+    if len1 < BinLen
+        Indiv1 = strcat(string(zeros(1, BinLen - len1))) + Indiv1; //0 padding on the right
+    end
+    if len2 < BinLen
+        Indiv2 =  strcat(string(zeros(1, BinLen - len2))) + Indiv2; //0 padding on the right
+    end
 
-    if ~MultiCross then
-        mix = ceil((length(Indiv1)-1)*grand(1,1,"def"))+1;
+    // Crossover positions selection
+    mix = unique(gsort(sample(MultiCrossNb, 1:BinLen-1), "g", "i"))';
+    Crossed_Indiv1 = Indiv1;
+    Crossed_Indiv2 = Indiv2;
 
-        part1_1 = part(Indiv1,1:mix);
-        part1_2 = part(Indiv1,mix+1:length(Indiv1));
-        part2_1 = part(Indiv2,1:mix);
-        part2_2 = part(Indiv2,mix+1:length(Indiv2));
+    for j = 1:size(mix, "*")
+        H1 = part(Crossed_Indiv1, 1:mix(j)); //Head for Indiv1
+        T1 = part(Crossed_Indiv1, (mix(j) + 1):BinLen); //Tail for Indiv1
+        H2 = part(Crossed_Indiv2, 1:mix(j)); //Head for Indiv2
+        T2 = part(Crossed_Indiv2, (mix(j) + 1):BinLen); //Tail for Indiv2
 
-        Crossed_Indiv1 = strcat([part1_1 part2_2]);
-        Crossed_Indiv2 = strcat([part1_2 part2_1]);
-    else
-        mix = ceil((length(Indiv1)-1)*grand(MultiCrossNb,1,"def"))+1;
-        mix = -unique(gsort(-mix));
-        Crossed_Indiv1 = Indiv1;
-        Crossed_Indiv2 = Indiv2;
-        for i=1:length(mix)
-            part1_1 = part(Crossed_Indiv1,1:mix(i));
-            part1_2 = part(Crossed_Indiv1,mix(i)+1:length(Crossed_Indiv1));
-            part2_1 = part(Crossed_Indiv2,1:mix(i));
-            part2_2 = part(Crossed_Indiv2,mix(i)+1:length(Crossed_Indiv2));
-
-            Crossed_Indiv1 = strcat([part1_1 part2_2]);
-            Crossed_Indiv2 = strcat([part1_2 part2_1]);
-        end
+        Crossed_Indiv1 = [H1 + T2];
+        Crossed_Indiv2 = [H2 + T1];
     end
 endfunction
index 333c94e..1f6a927 100644 (file)
@@ -1,4 +1,6 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) Scilab Enterprises - 2014 - Pierre-Aime Agnel
+// Copyright (C) 2014 - Michael Baudin <michael.baudin@contrib.scilab.org>
 // Copyright (C) 2008 - Yann COLLETTE <yann.collette@renault.com>
 //
 // This file must be used under the terms of the CeCILL.
@@ -7,35 +9,30 @@
 // are also available at
 // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 
-function Mut_Indiv = mutation_ga_binary(Indiv,param)
-    if ~isdef("param","local") then
+function [Mut_Indiv, pos] = mutation_ga_binary(Indiv, param)
+    if ~isdef("param", "local") then
         param = [];
     end
     // We deal with some parameters to take into account the boundary of the domain and the neighborhood size
-    [BinLen,err]     = get_param(param,"binary_length",8);
-    [MultiMut,err]   = get_param(param,"multi_mut",%F);
-    [MultiMutNb,err] = get_param(param,"multi_mut_nb",2);
-
-    if ~MultiMut then
-        pos = ceil((length(Indiv)-1)*grand(1,1,"def"))+1;
-        Mut_Indiv = Indiv;
-        if part(Indiv,pos)=="0" then
-            Mut_Indiv = strcat([part(Indiv,1:pos-1) "1" part(Indiv,pos+1:length(Indiv))]);
-        end
-        if part(Indiv,pos)=="1" then
-            Mut_Indiv = strcat([part(Indiv,1:pos-1) "0" part(Indiv,pos+1:length(Indiv))]);
-        end
+    [BinLen, err]     = get_param(param, "binary_length", 8);
+    [MultiMut, err]   = get_param(param, "multi_mut", %F);
+    if MultiMut
+        [MultiMutNb, err] = get_param(param, "multi_mut_nb", 2);
     else
-        pos = ceil((length(Indiv)-1)*grand(MultiMutNb,1,"def"))+1;
-        pos = -unique(gsort(-pos));
-        Mut_Indiv = Indiv;
-        for i=1:length(pos)
-            if part(Mut_Indiv,pos(i))=="0" then
-                Mut_Indiv = strcat([part(Mut_Indiv,1:pos(i)-1) "1" part(Mut_Indiv,pos(i)+1:length(Mut_Indiv))]);
-            end
-            if part(Mut_Indiv,pos(i))=="1" then
-                Mut_Indiv = strcat([part(Mut_Indiv,1:pos(i)-1) "0" part(Mut_Indiv,pos(i)+1:length(Mut_Indiv))]);
-            end
+        MultiMutNb = 1;
+    end
+
+    dim = length(Indiv);
+    pos = grand(1, MultiMutNb, "uin", 1, dim);
+    pos = unique(pos);
+    Mut_Indiv = Indiv;
+    for i = 1:size(pos, '*');
+        Mut_Indiv = [part(Mut_Indiv, 1:pos(i) - 1), part(Mut_Indiv, pos(i)), part(Mut_Indiv, pos(i) + 1:dim)];
+        if Mut_Indiv(2) == "0"
+            Mut_Indiv(2) = "1";
+        else
+            Mut_Indiv(2) = "0";
         end
+        Mut_Indiv = strcat(Mut_Indiv);
     end
 endfunction
index abeea03..7bd0f37 100644 (file)
@@ -1,5 +1,6 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 2008 - Yann COLLETTE <yann.collette@renault.com>
+// Copyright (C) 2014 - Michael Baudin <michael.baudin@contrib.scilab.org>
 //
 // This file must be used under the terms of the CeCILL.
 // This source file is licensed as described in the file COPYING, which
@@ -11,64 +12,61 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_ga(ga_f, pop_s
 
     [nargout, nargin] = argn();
 
-    if ~isdef("param","local") then
+    if ~isdef("param", "local") then
         param = [];
     end
 
-    [codage_func,err]    = get_param(param,"codage_func",coding_ga_identity);
-    [init_func,err]      = get_param(param,"init_func",init_ga_default);
-    [crossover_func,err] = get_param(param,"crossover_func",crossover_ga_default);
-    [mutation_func,err]  = get_param(param,"mutation_func",mutation_ga_default);
-    [selection_func,err] = get_param(param,"selection_func",selection_ga_elitist);
-    [nb_couples,err]     = get_param(param,"nb_couples",100);
-    [pressure,err]       = get_param(param,"pressure",0.05);
-
-    if ~isdef("ga_f","local") then
-        error(sprintf(gettext("%s: ga_f is mandatory"),"optim_ga"));
+    [codage_func, err]    = get_param(param, "codage_func", coding_ga_identity);
+    [init_func, err]      = get_param(param, "init_func", init_ga_default);
+    [crossover_func, err] = get_param(param, "crossover_func", crossover_ga_default);
+    [mutation_func, err]  = get_param(param, "mutation_func", mutation_ga_default);
+    [selection_func, err] = get_param(param, "selection_func", selection_ga_elitist);
+    [nb_couples, err]     = get_param(param, "nb_couples", 100);
+    [pressure, err]       = get_param(param, "pressure", 0.05);
+    [output_func, err] = get_param(param, "output_func", output_ga_default);
+
+    if ~isdef("ga_f", "local") then
+        error(sprintf(gettext("%s: ga_f is mandatory"), "optim_ga"));
     else
-        if typeof(ga_f)=="list" then
-            deff("y=_ga_f(x)","y=ga_f(1)(x, ga_f(2:$))");
+        if typeof(ga_f) == "list" then
+            deff("y = _ga_f(x)", "y = ga_f(1)(x, ga_f(2:$))");
         else
-            deff("y=_ga_f(x)","y=ga_f(x)");
+            deff("y = _ga_f(x)", "y = ga_f(x)");
         end
     end
 
-    if ~isdef("pop_size","local") then
+    if ~isdef("pop_size", "local") then
         pop_size = 100;
     end
-    if ~isdef("nb_generation","local") then
+    if ~isdef("nb_generation", "local") then
         nb_generation = 10;
     end
-    if ~isdef("p_mut","local") then
+    if ~isdef("p_mut", "local") then
         p_mut = 0.1;
     end
-    if ~isdef("p_cross","local") then
+    if ~isdef("p_cross", "local") then
         p_cross = 0.7;
     end
-    if ~isdef("Log","local") then
+    if ~isdef("Log", "local") then
         Log = %F;
     end
 
     // Initialization of the population
-    if (Log) then
-        printf(gettext("%s: Initialization of the population\n"),"optim_ga");
-    end
-
     Pop = list();
-    Pop = init_func(pop_size,param);
+    Pop = init_func(pop_size, param);
 
-    if (nargout>=3) then
+    if (nargout >= 3) then
         pop_init = Pop;
     end
 
     // Code the individuals
-    Pop = codage_func(Pop,"code",param);
+    Pop = codage_func(Pop, "code", param);
 
-    for i=1:length(Pop)
+    for i = 1:length(Pop)
         FObj_Pop(i) = _ga_f(Pop(i));
     end
 
-    if (nargout==4) then
+    if (nargout == 4) then
         fobj_pop_init = FObj_Pop;
     end
 
@@ -79,39 +77,31 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_ga(ga_f, pop_s
     Efficiency = (1 - pressure) * (FObj_Pop_Max - FObj_Pop) / max([FObj_Pop_Max - FObj_Pop_Min %eps]) + pressure;
 
     // The genetic algorithm
-    for i=1:nb_generation
-        if (Log) then
-            printf(gettext("%s: iteration %d / %d"), "optim_ga", i, nb_generation);
-        end
+    for i = 1:nb_generation
         //
         // Selection
         //
         Indiv1 = list();
         Indiv2 = list();
         Wheel = cumsum(Efficiency);
-        for j=1:nb_couples
+        for j = 1:nb_couples
             // Selection of the first individual in the couple
-            Shoot = grand(1,1,"def")*Wheel($);
-            Index = 1;
-            while((Wheel(Index)<Shoot)&(Index<length(Wheel)))
-                Index = Index + 1;
-            end
+            Shoot = grand(1, 1, "unf", 0, Wheel($));
+            Index = find(Shoot <= Wheel, 1);
             Indiv1(j)      = Pop(Index);
             FObj_Indiv1(j) = FObj_Pop(Index);
             // Selection of the second individual in the couple
-            Shoot = grand(1,1,"def")*Wheel($);
+            Shoot = grand(1, 1, "unf", 0, Wheel($));
             Index = 1;
-            while((Wheel(Index)<Shoot)&(Index<length(Wheel)))
-                Index = Index + 1;
-            end
+            Index = find(Shoot <= Wheel, 1);
             Indiv2(j)      = Pop(Index);
             FObj_Indiv2(j) = FObj_Pop(Index);
         end
         //
         // Crossover
         //
-        for j=1:nb_couples
-            if (p_cross>grand(1,1,"def")) then
+        for j = 1:nb_couples
+            if (p_cross>grand(1, 1, "def")) then
                 [x1, x2] = crossover_func(Indiv1(j), Indiv2(j), param);
                 Indiv1(j) = x1;
                 Indiv2(j) = x2;
@@ -125,14 +115,14 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_ga(ga_f, pop_s
         //
         // Mutation
         //
-        for j=1:nb_couples
-            if (p_mut>grand(1,1,"def")) then
-                x1 = mutation_func(Indiv1(j),param);
+        for j = 1:nb_couples
+            if (p_mut>grand(1, 1, "def")) then
+                x1 = mutation_func(Indiv1(j), param);
                 Indiv1(j) = x1;
                 ToCompute_I1(j) = %T;
             end
-            if (p_mut>grand(1,1,"def")) then
-                x2 = mutation_func(Indiv2(j),param);
+            if (p_mut>grand(1, 1, "def")) then
+                x2 = mutation_func(Indiv2(j), param);
                 Indiv2(j) = x2;
                 ToCompute_I2(j) = %T;
             end
@@ -140,7 +130,7 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_ga(ga_f, pop_s
         //
         // Computation of the objective functions
         //
-        for j=1:nb_couples
+        for j = 1:nb_couples
             if ToCompute_I1(j) then FObj_Indiv1(j) = _ga_f(Indiv1(j)); end
             if ToCompute_I2(j) then FObj_Indiv2(j) = _ga_f(Indiv2(j)); end
         end
@@ -152,15 +142,18 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_ga(ga_f, pop_s
         //
         // Recombination
         //
+        [Pop, FObj_Pop] = selection_func(Pop, Indiv1, Indiv2, FObj_Pop, FObj_Indiv1, FObj_Indiv2, [], [], [], param);
 
-        [Pop, FObj_Pop, Efficiency] = selection_func(Pop,Indiv1,Indiv2,FObj_Pop,FObj_Indiv1,FObj_Indiv2,[],[],[],param);
-
+        // Callback for plotting / printing intermediate results or stopping the algorithm
         if (Log) then
-            printf(gettext(" - min / max value found = %f / %f\n"), min(FObj_Pop), max(FObj_Pop));
+            stop = output_func(i, nb_generation, Pop, FObj_Pop, param);
+            if (stop) then
+                break
+            end
         end
     end
 
     pop_opt  = Pop;
-    pop_opt  = codage_func(pop_opt,"decode",param);
+    pop_opt  = codage_func(pop_opt, "decode", param);
     fobj_pop_opt = FObj_Pop;
 endfunction
index 91f098b..13ff5db 100644 (file)
@@ -1,5 +1,6 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 2008 - Yann COLLETTE <yann.collette@renault.com>
+// Copyright (C) 2014 - Michael Baudin <michael.baudin@contrib.scilab.org>
 //
 // This file must be used under the terms of the CeCILL.
 // This source file is licensed as described in the file COPYING, which
@@ -22,6 +23,7 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_moga(ga_f, pop
     [selection_func,err] = get_param(param,"selection_func",selection_ga_elitist);
     [nb_couples,err]     = get_param(param,"nb_couples",100);
     [pressure,err]       = get_param(param,"pressure",0.05);
+    [output_func, err] = get_param(param, "output_func", output_moga_default);
 
     if ~isdef("ga_f","local") then
         error(gettext("optim_moga: ga_f is mandatory"));
@@ -55,7 +57,7 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_moga(ga_f, pop
     end
 
     Pop = list();
-    Pop = init_func(pop_size,param);
+    Pop = init_func(pop_size, param);
 
     if (nargout>=3) then
         pop_init = Pop;
@@ -90,9 +92,6 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_moga(ga_f, pop
 
     // The genetic algorithm
     for i=1:nb_generation
-        if (Log) then
-            printf(gettext("%s: iteration %d / %d"), "optim_moga", i, nb_generation);
-        end
         //
         // Selection
         //
@@ -101,19 +100,13 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_moga(ga_f, pop
         Wheel = cumsum(Efficiency);
         for j=1:nb_couples
             // Selection of the first individual in the couple
-            Shoot = grand(1,1,"def")*Wheel($);
-            Index = 1;
-            while((Wheel(Index)<Shoot)&(Index<length(Wheel)))
-                Index = Index + 1;
-            end
+            Shoot = grand(1,1,"unf", 0, Wheel($));
+            Index = find(Shoot <= Wheel, 1);
             Indiv1(j)           = Pop(Index);
             MO_FObj_Indiv1(j,:) = MO_FObj_Pop(Index,:);
             // Selection of the second individual in the couple
-            Shoot = grand(1,1,"def")*Wheel($);
-            Index = 1;
-            while((Wheel(Index)<Shoot)&(Index<length(Wheel)))
-                Index = Index + 1;
-            end
+            Shoot = grand(1,1,"unf", 0, Wheel($));
+            Index = find(Shoot <= Wheel, 1);
             Indiv2(j)           = Pop(Index);
             MO_FObj_Indiv2(j,:) = MO_FObj_Pop(Index,:);
         end
@@ -201,13 +194,16 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_moga(ga_f, pop
         // Recombination
         //
 
-        [Pop,FObj_Pop,Efficiency,MO_FObj_Pop] = selection_func(Pop,Indiv1,Indiv2,FObj_Pop,FObj_Indiv1,FObj_Indiv2, ...
-        MO_FObj_Pop,MO_FObj_Indiv1,MO_FObj_Indiv2,param);
+        [Pop, FObj_Pop, Efficiency, MO_FObj_Pop] = selection_func(Pop, Indiv1, Indiv2, FObj_Pop, FObj_Indiv1, FObj_Indiv2, ...
+                MO_FObj_Pop, MO_FObj_Indiv1, MO_FObj_Indiv2, param);
         if (Log) then
-            printf(gettext(" - min / max value found = %f / %f\n"), min(FObj_Pop), max(FObj_Pop));
+            stop = output_func(i, nb_generation, Pop, MO_FObj_Pop, param);
+            if stop then
+                break
+            end
         end
     end
 
-    pop_opt      = codage_func(Pop,"decode",param);
+    pop_opt      = codage_func(Pop, 'decode', param);
     fobj_pop_opt = MO_FObj_Pop;
 endfunction
index e739a38..ed0e320 100644 (file)
@@ -11,57 +11,58 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga(ga_f, pop
 
     [nargout, nargin] = argn();
 
-    if ~isdef("param","local") then
+    if ~isdef("param", "local") then
         param = [];
     end
 
-    [codage_func,err]    = get_param(param,"codage_func",coding_ga_identity);
-    [init_func,err]      = get_param(param,"init_func",init_ga_default);
-    [crossover_func,err] = get_param(param,"crossover_func",crossover_ga_default);
-    [mutation_func,err]  = get_param(param,"mutation_func",mutation_ga_default);
-    [selection_func,err] = get_param(param,"selection_func",selection_ga_elitist);
-    [nb_couples,err]     = get_param(param,"nb_couples",100);
-    [pressure,err]       = get_param(param,"pressure",0.05);
+    [codage_func, err]    = get_param(param, "codage_func", coding_ga_identity);
+    [init_func, err]      = get_param(param, "init_func", init_ga_default);
+    [crossover_func, err] = get_param(param, "crossover_func", crossover_ga_default);
+    [mutation_func, err]  = get_param(param, "mutation_func", mutation_ga_default);
+    [selection_func, err] = get_param(param, "selection_func", selection_ga_elitist);
+    [nb_couples, err]     = get_param(param, "nb_couples", 100);
+    [pressure, err]       = get_param(param, "pressure", 0.05);
+    [output_func, err] = get_param(param, "output_func", output_nsga_default);
 
-    if ~isdef("ga_f","local") then
+    if ~isdef("ga_f", "local") then
         error(gettext("optim_moga: ga_f is mandatory"));
     else
         if typeof(ga_f)=="list" then
-            deff("y=_ga_f(x)","y=ga_f(1)(x, ga_f(2:$))");
+            deff("y=_ga_f(x)", "y=ga_f(1)(x, ga_f(2:$))");
         else
-            deff("y=_ga_f(x)","y=ga_f(x)");
+            deff("y=_ga_f(x)", "y=ga_f(x)");
         end
     end
 
-    if ~isdef("pop_size","local") then
+    if ~isdef("pop_size", "local") then
         pop_size = 100;
     end
-    if ~isdef("nb_generation","local") then
+    if ~isdef("nb_generation", "local") then
         nb_generation = 10;
     end
-    if ~isdef("p_mut","local") then
+    if ~isdef("p_mut", "local") then
         p_mut = 0.1;
     end
-    if ~isdef("p_cross","local") then
+    if ~isdef("p_cross", "local") then
         p_cross = 0.1;
     end
-    if ~isdef("Log","local") then
+    if ~isdef("Log", "local") then
         Log = %F;
     end
-    if ~isdef("sigma","local") then
+    if ~isdef("sigma", "local") then
         sigma = 0.01;
     end
-    if ~isdef("pow","local") then
+    if ~isdef("pow", "local") then
         pow = 2;
     end
 
     // Initialization of the population
     if (Log) then
-        printf(gettext("%s: Initialization of the population\n"),"optim_nsga");
+        printf(gettext("%s: Initialization of the population\n"), "optim_nsga");
     end
 
     Pop = list();
-    Pop = init_func(pop_size,param);
+    Pop = init_func(pop_size, param);
 
 
     if (nargout>=3) then
@@ -69,17 +70,17 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga(ga_f, pop
     end
 
     // Code the individuals
-    Pop = codage_func(Pop,"code",param);
+    Pop = codage_func(Pop, "code", param);
 
     for i=1:length(Pop)
-        MO_FObj_Pop(i,:) = _ga_f(Pop(i));
+        MO_FObj_Pop(i, :) = _ga_f(Pop(i));
     end
 
     // Compute the domination rank
-    for i=1:size(MO_FObj_Pop,1)
+    for i=1:size(MO_FObj_Pop, 1)
         Index = 0;
-        for j=1:size(MO_FObj_Pop,1)
-            Index = Index + double(and(MO_FObj_Pop(i,:)<=MO_FObj_Pop(j,:)) & or(MO_FObj_Pop(i,:)<MO_FObj_Pop(j,:)));
+        for j=1:size(MO_FObj_Pop, 1)
+            Index = Index + double(and(MO_FObj_Pop(i, :)<=MO_FObj_Pop(j, :)) & or(MO_FObj_Pop(i, :)<MO_FObj_Pop(j, :)));
         end
         FObj_Pop(i) = - (Index + 1);
     end
@@ -90,15 +91,11 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga(ga_f, pop
 
     // The genetic algorithm
     for i=1:nb_generation
-        if (Log) then
-            printf(gettext("%s: iteration %d / %d"), "optim_nsga", i, nb_generation);
-        end
-
         // Computation of the niching penality
-        for j=1:size(MO_FObj_Pop,1)
+        for j=1:size(MO_FObj_Pop, 1)
             Niching(j) = 0;
-            for k=1:size(MO_FObj_Pop,1)
-                Distance = sqrt(sum((MO_FObj_Pop(j,:) - MO_FObj_Pop(k,:)).^2));
+            for k=1:size(MO_FObj_Pop, 1)
+                Distance = sqrt(sum((MO_FObj_Pop(j, :) - MO_FObj_Pop(k, :)).^2));
                 if Distance < sigma then
                     Niching(j) = Niching(j) + (1 - Distance / sigma)^pow;
                 end
@@ -123,26 +120,26 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga(ga_f, pop
 
         for j=1:nb_couples
             // Selection of the first individual in the couple
-            Shoot = grand(1,1,"def")*Wheel($);
+            Shoot = grand(1, 1, "def")*Wheel($);
             Index = find(Wheel<=Shoot);
             if length(Index)>1 then Index = Index($); end;
             if isempty(Index)  then Index = 1; end;
             Indiv1(j)           = Pop(Index);
-            MO_FObj_Indiv1(j,:) = MO_FObj_Pop(Index,:);
+            MO_FObj_Indiv1(j, :) = MO_FObj_Pop(Index, :);
             // Selection of the second individual in the couple
-            Shoot = grand(1,1,"def")*Wheel($);
+            Shoot = grand(1, 1, "def")*Wheel($);
             Index = find(Wheel<=Shoot);
             if length(Index)>1 then Index = Index($); end;
             if isempty(Index)  then Index = 1; end;
             Indiv2(j)           = Pop(Index);
-            MO_FObj_Indiv2(j,:) = MO_FObj_Pop(Index,:);
+            MO_FObj_Indiv2(j, :) = MO_FObj_Pop(Index, :);
         end
         //
         // Crossover
         //
         for j=1:nb_couples
-            if (p_cross>grand(1,1,"def")) then
-                [x1, x2]  = crossover_func(Indiv1(j), Indiv2(j),param);
+            if (p_cross>grand(1, 1, "def")) then
+                [x1, x2]  = crossover_func(Indiv1(j), Indiv2(j), param);
                 Indiv1(j) = x1;
                 Indiv2(j) = x2;
                 ToCompute_I1(j) = %T;
@@ -156,13 +153,13 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga(ga_f, pop
         // Mutation
         //
         for j=1:nb_couples
-            if (p_mut>grand(1,1,"def")) then
-                x1 = mutation_func(Indiv1(j),param);
+            if (p_mut>grand(1, 1, "def")) then
+                x1 = mutation_func(Indiv1(j), param);
                 Indiv1(j) = x1;
                 ToCompute_I1(j) = %T;
             end
-            if (p_mut>grand(1,1,"def")) then
-                x2 = mutation_func(Indiv2(j),param);
+            if (p_mut>grand(1, 1, "def")) then
+                x2 = mutation_func(Indiv2(j), param);
                 Indiv2(j) = x2;
                 ToCompute_I2(j) = %T;
             end
@@ -171,8 +168,8 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga(ga_f, pop
         // Computation of the objective functions
         //
         for j=1:length(Indiv1)
-            if ToCompute_I1(j) then MO_FObj_Indiv1(j,:) = _ga_f(Indiv1(j)); end
-            if ToCompute_I2(j) then MO_FObj_Indiv2(j,:) = _ga_f(Indiv2(j)); end
+            if ToCompute_I1(j) then MO_FObj_Indiv1(j, :) = _ga_f(Indiv1(j)); end
+            if ToCompute_I2(j) then MO_FObj_Indiv2(j, :) = _ga_f(Indiv2(j)); end
         end
 
         // Reinit ToCompute lists
@@ -180,39 +177,39 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga(ga_f, pop
         ToCompute_I2 = ToCompute_I2 & %F;
 
         // Compute the domination rank
-        for j=1:size(MO_FObj_Indiv1,1)
+        for j=1:size(MO_FObj_Indiv1, 1)
             // We compute the rank for Indiv1
             Index1 = 0; Index2 = 0; Index3 = 0;
-            for k=1:size(MO_FObj_Indiv1,1)
-                Index1 = Index1 + double(and(MO_FObj_Indiv1(j,:)<=MO_FObj_Indiv1(k,:)) & or(MO_FObj_Indiv1(j,:)<MO_FObj_Indiv1(k,:)));
-                Index2 = Index2 + double(and(MO_FObj_Indiv1(j,:)<=MO_FObj_Indiv2(k,:)) & or(MO_FObj_Indiv1(j,:)<MO_FObj_Indiv2(k,:)));
+            for k=1:size(MO_FObj_Indiv1, 1)
+                Index1 = Index1 + double(and(MO_FObj_Indiv1(j, :)<=MO_FObj_Indiv1(k, :)) & or(MO_FObj_Indiv1(j, :)<MO_FObj_Indiv1(k, :)));
+                Index2 = Index2 + double(and(MO_FObj_Indiv1(j, :)<=MO_FObj_Indiv2(k, :)) & or(MO_FObj_Indiv1(j, :)<MO_FObj_Indiv2(k, :)));
             end
-            for k=1:size(MO_FObj_Pop,1)
-                Index3 = Index3 + and(MO_FObj_Indiv1(j,:)<=MO_FObj_Pop(k,:)) & or(MO_FObj_Indiv1(j,:)<MO_FObj_Pop(k,:));
+            for k=1:size(MO_FObj_Pop, 1)
+                Index3 = Index3 + and(MO_FObj_Indiv1(j, :)<=MO_FObj_Pop(k, :)) & or(MO_FObj_Indiv1(j, :)<MO_FObj_Pop(k, :));
             end
             FObj_Indiv1(j) = - (Index1 + Index2 + Index3 + 1);
 
             // We compute the rank for Indiv2
             Index1 = 0; Index2 = 0; Index3 = 0;
-            for k=1:size(MO_FObj_Indiv1,1)
-                Index1 = Index1 + double(and(MO_FObj_Indiv2(j,:)<=MO_FObj_Indiv1(k,:)) & or(MO_FObj_Indiv2(j,:)<MO_FObj_Indiv1(k,:)));
-                Index2 = Index2 + double(and(MO_FObj_Indiv2(j,:)<=MO_FObj_Indiv2(k,:)) & or(MO_FObj_Indiv2(j,:)<MO_FObj_Indiv2(k,:)));
+            for k=1:size(MO_FObj_Indiv1, 1)
+                Index1 = Index1 + double(and(MO_FObj_Indiv2(j, :)<=MO_FObj_Indiv1(k, :)) & or(MO_FObj_Indiv2(j, :)<MO_FObj_Indiv1(k, :)));
+                Index2 = Index2 + double(and(MO_FObj_Indiv2(j, :)<=MO_FObj_Indiv2(k, :)) & or(MO_FObj_Indiv2(j, :)<MO_FObj_Indiv2(k, :)));
             end
-            for k=1:size(MO_FObj_Pop,1)
-                Index3 = Index3 + double(and(MO_FObj_Indiv2(j,:)<=MO_FObj_Pop(k,:)) & or(MO_FObj_Indiv2(j,:)<MO_FObj_Pop(k,:)));
+            for k=1:size(MO_FObj_Pop, 1)
+                Index3 = Index3 + double(and(MO_FObj_Indiv2(j, :)<=MO_FObj_Pop(k, :)) & or(MO_FObj_Indiv2(j, :)<MO_FObj_Pop(k, :)));
             end
             FObj_Indiv2(j) = - (Index1 + Index2 + Index3 + 1);
         end
 
         // We compute the rank for Pop
-        for j=1:size(MO_FObj_Pop,1)
+        for j=1:size(MO_FObj_Pop, 1)
             Index1 = 0; Index2 = 0; Index3 = 0;
-            for k=1:size(MO_FObj_Indiv1,1)
-                Index1 = Index1 + double(and(MO_FObj_Pop(j,:)<=MO_FObj_Indiv1(k,:)) & or(MO_FObj_Pop(j,:)<MO_FObj_Indiv1(k,:)));
-                Index2 = Index2 + double(and(MO_FObj_Pop(j,:)<=MO_FObj_Indiv2(k,:)) & or(MO_FObj_Pop(j,:)<MO_FObj_Indiv2(k,:)));
+            for k=1:size(MO_FObj_Indiv1, 1)
+                Index1 = Index1 + double(and(MO_FObj_Pop(j, :)<=MO_FObj_Indiv1(k, :)) & or(MO_FObj_Pop(j, :)<MO_FObj_Indiv1(k, :)));
+                Index2 = Index2 + double(and(MO_FObj_Pop(j, :)<=MO_FObj_Indiv2(k, :)) & or(MO_FObj_Pop(j, :)<MO_FObj_Indiv2(k, :)));
             end
-            for k=1:size(FObj_Pop,1)
-                Index3 = Index3 + double(and(MO_FObj_Pop(j,:)<=MO_FObj_Pop(k,:)) & or(MO_FObj_Pop(j,:)<MO_FObj_Pop(k,:)));
+            for k=1:size(FObj_Pop, 1)
+                Index3 = Index3 + double(and(MO_FObj_Pop(j, :)<=MO_FObj_Pop(k, :)) & or(MO_FObj_Pop(j, :)<MO_FObj_Pop(k, :)));
             end
             FObj_Pop(j) = - (Index1 + Index2 + Index3 + 1);
         end
@@ -221,13 +218,16 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga(ga_f, pop
         // Recombination
         //
 
-        [Pop,FObj_Pop,Efficiency,MO_FObj_Pop] = selection_func(Pop,Indiv1,Indiv2,FObj_Pop,FObj_Indiv1,FObj_Indiv2, ...
-        MO_FObj_Pop,MO_FObj_Indiv1,MO_FObj_Indiv2,param);
+        [Pop, FObj_Pop, Efficiency, MO_FObj_Pop] = selection_func(Pop, Indiv1, Indiv2, FObj_Pop, FObj_Indiv1, FObj_Indiv2, ...
+        MO_FObj_Pop, MO_FObj_Indiv1, MO_FObj_Indiv2, param);
         if (Log) then
-            printf(gettext(" - min / max value found = %f / %f\n"), min(FObj_Pop), max(FObj_Pop));
+            stop = output_func(i, nb_generation, Pop, MO_FObj_Pop, param);
+            if stop then
+                break
+            end
         end
     end
 
-    pop_opt      = codage_func(Pop,"decode",param);
+    pop_opt      = codage_func(Pop, "decode", param);
     fobj_pop_opt = MO_FObj_Pop;
 endfunction
index a449118..a6099c2 100644 (file)
@@ -11,58 +11,59 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga2(ga_f, po
 
     [nargout, nargin] = argn();
 
-    if ~isdef("param","local") then
+    if ~isdef("param", "local") then
         param = [];
     end
 
-    [codage_func,err]        = get_param(param,"codage_func",coding_ga_identity);
-    [init_func,err]          = get_param(param,"init_func",init_ga_default);
-    [crossover_func,err]     = get_param(param,"crossover_func",crossover_ga_default);
-    [mutation_func,err]      = get_param(param,"mutation_func",mutation_ga_default);
-    [nb_couples,err]         = get_param(param,"nb_couples",100);
+    [codage_func, err] = get_param(param, "codage_func", coding_ga_identity);
+    [init_func, err] = get_param(param, "init_func", init_ga_default);
+    [crossover_func, err] = get_param(param, "crossover_func", crossover_ga_default);
+    [mutation_func, err] = get_param(param, "mutation_func", mutation_ga_default);
+    [nb_couples, err] = get_param(param, "nb_couples", 100);
+    [output_func, err] = get_param(param, 'output_func', output_nsga2_default);
 
-    if ~isdef("ga_f","local") then
+    if ~isdef("ga_f", "local") then
         error(gettext("optim_nsga2: ga_f is mandatory"));
     else
         if typeof(ga_f)=="list" then
-            deff("y=_ga_f(x)","y=ga_f(1)(x, ga_f(2:$))");
+            deff("y=_ga_f(x)", "y=ga_f(1)(x, ga_f(2:$))");
         else
-            deff("y=_ga_f(x)","y=ga_f(x)");
+            deff("y=_ga_f(x)", "y=ga_f(x)");
         end
     end
 
-    if ~isdef("pop_size","local") then
+    if ~isdef("pop_size", "local") then
         pop_size = 100;
     end
-    if ~isdef("nb_generation","local") then
+    if ~isdef("nb_generation", "local") then
         nb_generation = 10;
     end
-    if ~isdef("p_mut","local") then
+    if ~isdef("p_mut", "local") then
         p_mut = 0.1;
     end
-    if ~isdef("p_cross","local") then
+    if ~isdef("p_cross", "local") then
         p_cross = 0.1;
     end
-    if ~isdef("Log","local") then
+    if ~isdef("Log", "local") then
         Log = %F;
     end
 
     // Initialization of the population
     if (Log) then
-        printf(gettext("%s: Initialization of the population\n"),"optim_nsga2");
+        printf(gettext("%s: Initialization of the population\n"), "optim_nsga2");
     end
 
-    Pop = init_func(pop_size,param);
+    Pop = init_func(pop_size, param);
 
     if (nargout>=3) then
         pop_init = Pop;
     end
 
     // Code the individuals
-    Pop = codage_func(Pop,"code",param);
+    Pop = codage_func(Pop, "code", param);
 
     for i=1:length(Pop)
-        FObj_Pop(i,:) = _ga_f(Pop(i));
+        FObj_Pop(i, :) = _ga_f(Pop(i));
     end
 
     // Compute the domination rank
@@ -70,18 +71,18 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga2(ga_f, po
 
     // Compute the crowding distance
     MO_FObj_Pop = FObj_Pop;
-    Index    = 1:size(MO_FObj_Pop,1);
-    Crowdist = zeros(size(MO_FObj_Pop,1),1);
-    for i=1:size(FObj_Pop,2)
-        [tmp, Index_List] = gsort(MO_FObj_Pop(:,i));
-        MO_FObj_Pop       = MO_FObj_Pop(Index_List,:);
+    Index    = 1:size(MO_FObj_Pop, 1);
+    Crowdist = zeros(size(MO_FObj_Pop, 1), 1);
+    for i=1:size(FObj_Pop, 2)
+        [tmp, Index_List] = gsort(MO_FObj_Pop(:, i));
+        MO_FObj_Pop       = MO_FObj_Pop(Index_List, :);
         Index             = Index(Index_List);
         Crowdist(Index_List(1)) = %inf;
         Crowdist(Index_List($)) = %inf;
-        _Max = max(MO_FObj_Pop(:,i));
-        _Min = min(MO_FObj_Pop(:,i));
-        for j=2:size(MO_FObj_Pop,1)-1
-            Crowdist(Index(j)) = Crowdist(Index(j)) - (MO_FObj_Pop(j+1,i) - MO_FObj_Pop(j-1,i)) / (_Max - _Min);
+        _Max = max(MO_FObj_Pop(:, i));
+        _Min = min(MO_FObj_Pop(:, i));
+        for j=2:size(MO_FObj_Pop, 1)-1
+            Crowdist(Index(j)) = Crowdist(Index(j)) - (MO_FObj_Pop(j+1, i) - MO_FObj_Pop(j-1, i)) / (_Max - _Min);
         end
     end
 
@@ -91,9 +92,6 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga2(ga_f, po
 
     // The genetic algorithm
     for It=1:nb_generation
-        if (Log) then
-            printf(gettext("%s: iteration %d / %d\n"), "optim_nsga2", It, nb_generation);
-        end
         //
         // Selection
         //
@@ -101,32 +99,32 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga2(ga_f, po
         Indiv2 = list();
         for j=1:nb_couples
             // Selection of 2 individuals via binary tournament selection to fill Indiv1
-            Index1 = ceil((size(FObj_Pop,1) - 1)*grand(1,1,"def")+1);
-            Index2 = ceil((size(FObj_Pop,1) - 1)*grand(1,1,"def")+1);
+            Index1 = ceil((size(FObj_Pop, 1) - 1)*grand(1, 1, "def")+1);
+            Index2 = ceil((size(FObj_Pop, 1) - 1)*grand(1, 1, "def")+1);
             if (Rank(Index1)<Rank(Index2)) | ((Rank(Index1)==Rank(Index2)) & (Crowdist(Index1)>Crowdist(Index2))) then
                 Indiv1(j)        = Pop(Index1);
-                FObj_Indiv1(j,:) = MO_FObj_Pop(Index1,:);
+                FObj_Indiv1(j, :) = MO_FObj_Pop(Index1, :);
             else
                 Indiv1(j)        = Pop(Index2);
-                FObj_Indiv1(j,:) = MO_FObj_Pop(Index2,:);
+                FObj_Indiv1(j, :) = MO_FObj_Pop(Index2, :);
             end
             // Selection of 2 individuals via binary tournament selection to fill Indiv2
-            Index1 = ceil((size(FObj_Pop,1) - 1)*grand(1,1,"def")+1);
-            Index2 = ceil((size(FObj_Pop,1) - 1)*grand(1,1,"def")+1);
+            Index1 = ceil((size(FObj_Pop, 1) - 1)*grand(1, 1, "def")+1);
+            Index2 = ceil((size(FObj_Pop, 1) - 1)*grand(1, 1, "def")+1);
             if (Rank(Index1)<Rank(Index2)) | ((Rank(Index1)==Rank(Index2)) & (Crowdist(Index1)>Crowdist(Index2))) then
                 Indiv2(j)        = Pop(Index1);
-                FObj_Indiv2(j,:) = MO_FObj_Pop(Index1,:);
+                FObj_Indiv2(j, :) = MO_FObj_Pop(Index1, :);
             else
                 Indiv2(j)        = Pop(Index2);
-                FObj_Indiv2(j,:) = MO_FObj_Pop(Index2,:);
+                FObj_Indiv2(j, :) = MO_FObj_Pop(Index2, :);
             end
         end
         //
         // Crossover
         //
         for j=1:nb_couples
-            if (p_cross>grand(1,1,"def")) then
-                [x1, x2] = crossover_func(Indiv1(j), Indiv2(j),param);
+            if (p_cross>grand(1, 1, "def")) then
+                [x1, x2] = crossover_func(Indiv1(j), Indiv2(j), param);
                 Indiv1(j) = x1;
                 Indiv2(j) = x2;
                 ToCompute_I1(j) = %T;
@@ -140,13 +138,13 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga2(ga_f, po
         // Mutation
         //
         for j=1:nb_couples
-            if (p_mut>grand(1,1,"def")) then
-                x1 = mutation_func(Indiv1(j),param);
+            if (p_mut>grand(1, 1, "def")) then
+                x1 = mutation_func(Indiv1(j), param);
                 Indiv1(j) = x1;
                 ToCompute_I1(j) = %T;
             end
-            if (p_mut>grand(1,1,"def")) then
-                x2 = mutation_func(Indiv2(j),param);
+            if (p_mut>grand(1, 1, "def")) then
+                x2 = mutation_func(Indiv2(j), param);
                 Indiv2(j) = x2;
                 ToCompute_I2(j) = %T;
             end
@@ -155,8 +153,8 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga2(ga_f, po
         // Computation of the objective functions
         //
         for j=1:length(Indiv1)
-            if ToCompute_I1(j) then FObj_Indiv1(j,:) = _ga_f(Indiv1(j)); end
-            if ToCompute_I2(j) then FObj_Indiv2(j,:) = _ga_f(Indiv2(j)); end
+            if ToCompute_I1(j) then FObj_Indiv1(j, :) = _ga_f(Indiv1(j)); end
+            if ToCompute_I2(j) then FObj_Indiv2(j, :) = _ga_f(Indiv2(j)); end
         end
 
         // Reinit ToCompute lists
@@ -172,26 +170,26 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga2(ga_f, po
 
         // Compute the crowding distance
         MO_All_FObj = All_FObj;
-        Index    = 1:size(MO_All_FObj,1);
-        Crowdist = zeros(size(MO_All_FObj,1),1);
-        for k=1:size(MO_All_FObj,2)
-            [tmp, Index_List] = gsort(MO_All_FObj(:,k));
-            MO_All_FObj = MO_All_FObj(Index_List,:);
+        Index    = 1:size(MO_All_FObj, 1);
+        Crowdist = zeros(size(MO_All_FObj, 1), 1);
+        for k=1:size(MO_All_FObj, 2)
+            [tmp, Index_List] = gsort(MO_All_FObj(:, k));
+            MO_All_FObj = MO_All_FObj(Index_List, :);
             Index = Index(Index_List);
             Crowdist(Index_List(1)) = %inf;
             Crowdist(Index_List($)) = %inf;
-            _Max = max(MO_All_FObj(:,k));
-            _Min = min(MO_All_FObj(:,k));
-            for j=2:size(MO_All_FObj,1)-1
-                Crowdist(Index(j)) = Crowdist(Index(j)) - (MO_All_FObj(j+1,k) - MO_All_FObj(j-1,k)) / (_Max - _Min);
+            _Max = max(MO_All_FObj(:, k));
+            _Min = min(MO_All_FObj(:, k));
+            for j=2:size(MO_All_FObj, 1)-1
+                Crowdist(Index(j)) = Crowdist(Index(j)) - (MO_All_FObj(j+1, k) - MO_All_FObj(j-1, k)) / (_Max - _Min);
             end
         end
         //
         // Recombination
         //
         // We rank all the individual wrt to the partial order
-        for k=1:size(All_FObj,1)-1
-            for j=k+1:size(All_FObj,1)
+        for k=1:size(All_FObj, 1)-1
+            for j=k+1:size(All_FObj, 1)
                 if (Rank(j)<Rank(k)) | ((Rank(j)==Rank(k)) & (Crowdist(j)>Crowdist(k))) then
                     tmp           = Rank(k);
                     Rank(k)       = Rank(j);
@@ -202,21 +200,28 @@ function [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_nsga2(ga_f, po
                     tmp           = All_Pop(k);
                     All_Pop(k)    = All_Pop(j);
                     All_Pop(j)    = tmp;
-                    tmp           = All_FObj(k,:);
-                    All_FObj(k,:) = All_FObj(j,:);
-                    All_FObj(j,:) = tmp;
+                    tmp           = All_FObj(k, :);
+                    All_FObj(k, :) = All_FObj(j, :);
+                    All_FObj(j, :) = tmp;
                 end
             end
         end
         // Extraction and selection of the phenotype
-        FObj_Pop = All_FObj(1:pop_size,:);
+        FObj_Pop = All_FObj(1:pop_size, :);
         // Extraction and selection of the genotype
         Pop = list(All_Pop(1:pop_size));
         // Extraction of the ranks and Crow distance
         Rank     = Rank(1:pop_size);
         Crowdist = Crowdist(1:pop_size);
+
+        if (Log) then
+            stop = output_func(i, nb_generation, Pop, FObj_Pop, param);
+            if stop then
+                break
+            end
+        end
     end
 
-    pop_opt      = codage_func(Pop,"decode",param);
+    pop_opt      = codage_func(Pop, "decode", param);
     fobj_pop_opt = FObj_Pop;
 endfunction
diff --git a/scilab/modules/genetic_algorithms/macros/output_ga_default.sci b/scilab/modules/genetic_algorithms/macros/output_ga_default.sci
new file mode 100644 (file)
index 0000000..66c92e3
--- /dev/null
@@ -0,0 +1,16 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Michael BAUDIN <michael.baudin@contrib.scilab.org>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+// =============================================================================
+
+function stop = output_ga_default(gen_index, nb_generation, Pop, FObj_Pop, param)
+    printf(gettext("%s: iteration %d / %d \n"), "optim_ga", gen_index, nb_generation);
+    printf(gettext("    min / max value found = %f / %f\n"), min(FObj_Pop), max(FObj_Pop));
+    stop = %f
+endfunction
diff --git a/scilab/modules/genetic_algorithms/macros/output_moga_default.sci b/scilab/modules/genetic_algorithms/macros/output_moga_default.sci
new file mode 100644 (file)
index 0000000..607f2c0
--- /dev/null
@@ -0,0 +1,16 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) Scilab Enterprises - 2014 - Pierre-Aime Agnel
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+// =============================================================================
+
+function stop = output_moga_default(gen_index, nb_generation, Pop, FObj_Pop, param)
+    printf(gettext("%s: iteration %d / %d \n"), "optim_moga", gen_index, nb_generation);
+    printf(gettext("    min / max value found = %f / %f\n"), min(FObj_Pop), max(FObj_Pop));
+    stop = %f
+endfunction
diff --git a/scilab/modules/genetic_algorithms/macros/output_nsga2_default.sci b/scilab/modules/genetic_algorithms/macros/output_nsga2_default.sci
new file mode 100644 (file)
index 0000000..e38472e
--- /dev/null
@@ -0,0 +1,16 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) Scilab Enterprises - 2014 - Pierre-Aime Agnel
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+// =============================================================================
+
+function stop = output_nsga2_default(gen_index, nb_generation, Pop, FObj_Pop, param)
+    printf(gettext("%s: iteration %d / %d\n"), "optim_nsga2", It, nb_generation);
+    printf(gettext("    min / max value found = %f / %f\n"), min(FObj_Pop), max(FObj_Pop));
+    stop = %f
+endfunction
diff --git a/scilab/modules/genetic_algorithms/macros/output_nsga_default.sci b/scilab/modules/genetic_algorithms/macros/output_nsga_default.sci
new file mode 100644 (file)
index 0000000..3fc89a6
--- /dev/null
@@ -0,0 +1,17 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) Scilab Enterprises - 2014 - Pierre-Aime Agnel
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+// =============================================================================
+
+function stop = output_nsga_default(gen_index, nb_generation, Pop, FObj_Pop, param)
+    printf(gettext("%s: iteration %d / %d \n"), "optim_nsga", gen_index, nb_generation);
+    printf(gettext("    min / max value found = %f / %f\n"), min(FObj_Pop), max(FObj_Pop));
+    stop = %f
+endfunction
+
diff --git a/scilab/modules/genetic_algorithms/tests/nonreg_tests/bug_13420.dia.ref b/scilab/modules/genetic_algorithms/tests/nonreg_tests/bug_13420.dia.ref
new file mode 100644 (file)
index 0000000..734d20e
--- /dev/null
@@ -0,0 +1,26 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Pierre-Aime Agnel
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug  -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13420
+//
+// <-- Short Description -->
+// mutation_ga_binary did not properly write mutliple mutations
+//
+// <-- CLI SHELL MODE -->
+param = init_param("binary_length", 8, "multi_mut", %t, "multi_mut_nb", 6);
+for i = 1:100
+    A = "11100011";
+    [A_mut, pos] = mutation_ga_binary(A, param);
+    A = strsplit(A);
+    A_mut = strsplit(A_mut);
+    tst_mut = A(pos) <> A_mut(pos);
+    tst_notmut = A(setdiff(1:8, pos)) == A_mut(setdiff(1:8, pos));
+    assert_checktrue(and(tst_mut));
+    assert_checktrue(and(tst_notmut));
+end
diff --git a/scilab/modules/genetic_algorithms/tests/nonreg_tests/bug_13420.tst b/scilab/modules/genetic_algorithms/tests/nonreg_tests/bug_13420.tst
new file mode 100644 (file)
index 0000000..7187689
--- /dev/null
@@ -0,0 +1,31 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Pierre-Aime Agnel
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug  -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13420
+//
+// <-- Short Description -->
+// mutation_ga_binary did not properly write mutliple mutations
+//
+// <-- CLI SHELL MODE -->
+
+param = init_param("binary_length", 8, "multi_mut", %t, "multi_mut_nb", 6);
+
+for i = 1:100
+    A = "11100011";
+    [A_mut, pos] = mutation_ga_binary(A, param);
+
+    A = strsplit(A);
+    A_mut = strsplit(A_mut);
+
+    tst_mut = A(pos) <> A_mut(pos);
+    tst_notmut = A(setdiff(1:8, pos)) == A_mut(setdiff(1:8, pos));
+
+    assert_checktrue(and(tst_mut));
+    assert_checktrue(and(tst_notmut));
+end
diff --git a/scilab/modules/genetic_algorithms/tests/nonreg_tests/bug_13421.dia.ref b/scilab/modules/genetic_algorithms/tests/nonreg_tests/bug_13421.dia.ref
new file mode 100644 (file)
index 0000000..9ba2701
--- /dev/null
@@ -0,0 +1,86 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Pierre-Aime Agnel
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug  -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13421
+//
+// <-- Short Description -->
+// Callback functions for genetic algorithms were missing
+//
+// <-- CLI SHELL MODE -->
+// Objective function
+function y=f(x)
+  y = sum(x.^2)
+endfunction
+// Output function with a stop criterion
+function stop=output_ga_custom(gen_index, nb_generation, Pop, FObj_Pop, param)
+    [threshold, err] = get_param(param, "threshold", 1E-10); // default value for the threshold
+    printf(_("%s: iteration %d / %d \n"), "optim_ga", gen_index, nb_generation);
+    printf(_("    min / max value found = %.4E / %.4E\n"), min(FObj_Pop), max(FObj_Pop));
+    stop = %f
+    if abs(max(FObj_Pop) - min(FObj_Pop)) < threshold then
+        printf(_("    Stop criterion reached: Delta Max to Min under threshold"));
+        stop = %t
+    end
+endfunction
+PopSize     = 100;
+Proba_cross = 0.7;
+Proba_mut   = 0.1;
+NbGen       = 20;
+NbCouples   = 110;
+Log         = %T;
+pressure    = 0.05;
+ga_params = init_param();
+// Parameters to adapt to the shape of the optimization problem
+ga_params = add_param(ga_params,"minbound",[-2; -2]);
+ga_params = add_param(ga_params,"maxbound",[2; 2]);
+ga_params = add_param(ga_params,"dimension",2);
+ga_params = add_param(ga_params,"beta",0);
+ga_params = add_param(ga_params,"delta",0.1);
+// Parameters to fine tune the Genetic algorithm.
+// All these parameters are optional for continuous optimization
+// If you need to adapt the GA to a special problem, you
+ga_params = add_param(ga_params,"init_func",init_ga_default);
+ga_params = add_param(ga_params,"crossover_func",crossover_ga_default);
+ga_params = add_param(ga_params,"mutation_func",mutation_ga_default);
+ga_params = add_param(ga_params,"codage_func",coding_ga_identity);
+ga_params = add_param(ga_params,"selection_func",selection_ga_elitist);
+//ga_params = add_param(ga_params,"selection_func",selection_ga_random);
+ga_params = add_param(ga_params,"nb_couples",NbCouples);
+ga_params = add_param(ga_params,"pressure",pressure);
+// Customized output function with a stop criterion added
+ga_params = add_param(ga_params, "threshold", 1E-6); // User defined parameter for the output function
+ga_params = add_param(ga_params, "output_func", output_ga_custom);
+[pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = ..
+  optim_ga(f, PopSize, NbGen, Proba_mut, Proba_cross, Log, ga_params);
+optim_ga: iteration 1 / 20 
+    min / max value found = 6.4854E-03 / 1.1026E+00
+optim_ga: iteration 2 / 20 
+    min / max value found = 4.2909E-03 / 2.8682E-01
+optim_ga: iteration 3 / 20 
+    min / max value found = 3.1174E-05 / 5.6912E-02
+optim_ga: iteration 4 / 20 
+    min / max value found = 3.1174E-05 / 1.8523E-02
+optim_ga: iteration 5 / 20 
+    min / max value found = 3.1174E-05 / 4.2909E-03
+optim_ga: iteration 6 / 20 
+    min / max value found = 2.0292E-05 / 1.2683E-03
+optim_ga: iteration 7 / 20 
+    min / max value found = 9.9116E-06 / 2.9666E-04
+optim_ga: iteration 8 / 20 
+    min / max value found = 1.1124E-06 / 7.9347E-05
+optim_ga: iteration 9 / 20 
+    min / max value found = 4.0632E-07 / 3.3694E-05
+optim_ga: iteration 10 / 20 
+    min / max value found = 3.4754E-07 / 9.9116E-06
+optim_ga: iteration 11 / 20 
+    min / max value found = 3.4470E-08 / 2.2709E-06
+optim_ga: iteration 12 / 20 
+    min / max value found = 3.4470E-08 / 9.0795E-07
+    Stop criterion reached: Delta Max to Min under thresholdassert_checktrue(max(fobj_pop_opt) - min(fobj_pop_opt) <= 1E-6);
diff --git a/scilab/modules/genetic_algorithms/tests/nonreg_tests/bug_13421.tst b/scilab/modules/genetic_algorithms/tests/nonreg_tests/bug_13421.tst
new file mode 100644 (file)
index 0000000..a9e2f17
--- /dev/null
@@ -0,0 +1,70 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Pierre-Aime Agnel
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug  -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13421
+//
+// <-- Short Description -->
+// Callback functions for genetic algorithms were missing
+//
+// <-- CLI SHELL MODE -->
+
+// Objective function
+function y=f(x)
+  y = sum(x.^2)
+endfunction
+
+// Output function with a stop criterion
+function stop=output_ga_custom(gen_index, nb_generation, Pop, FObj_Pop, param)
+    [threshold, err] = get_param(param, "threshold", 1E-10); // default value for the threshold
+    printf(_("%s: iteration %d / %d \n"), "optim_ga", gen_index, nb_generation);
+    printf(_("    min / max value found = %.4E / %.4E\n"), min(FObj_Pop), max(FObj_Pop));
+    stop = %f
+    if abs(max(FObj_Pop) - min(FObj_Pop)) < threshold then
+        printf(_("    Stop criterion reached: Delta Max to Min under threshold"));
+        stop = %t
+    end
+endfunction
+
+PopSize     = 100;
+Proba_cross = 0.7;
+Proba_mut   = 0.1;
+NbGen       = 20;
+NbCouples   = 110;
+Log         = %T;
+pressure    = 0.05;
+
+ga_params = init_param();
+// Parameters to adapt to the shape of the optimization problem
+ga_params = add_param(ga_params,"minbound",[-2; -2]);
+ga_params = add_param(ga_params,"maxbound",[2; 2]);
+ga_params = add_param(ga_params,"dimension",2);
+ga_params = add_param(ga_params,"beta",0);
+ga_params = add_param(ga_params,"delta",0.1);
+// Parameters to fine tune the Genetic algorithm.
+// All these parameters are optional for continuous optimization
+// If you need to adapt the GA to a special problem, you
+ga_params = add_param(ga_params,"init_func",init_ga_default);
+ga_params = add_param(ga_params,"crossover_func",crossover_ga_default);
+ga_params = add_param(ga_params,"mutation_func",mutation_ga_default);
+ga_params = add_param(ga_params,"codage_func",coding_ga_identity);
+ga_params = add_param(ga_params,"selection_func",selection_ga_elitist);
+
+//ga_params = add_param(ga_params,"selection_func",selection_ga_random);
+ga_params = add_param(ga_params,"nb_couples",NbCouples);
+ga_params = add_param(ga_params,"pressure",pressure);
+
+// Customized output function with a stop criterion added
+ga_params = add_param(ga_params, "threshold", 1E-6); // User defined parameter for the output function
+ga_params = add_param(ga_params, "output_func", output_ga_custom);
+
+[pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = ..
+  optim_ga(f, PopSize, NbGen, Proba_mut, Proba_cross, Log, ga_params);
+
+assert_checktrue(max(fobj_pop_opt) - min(fobj_pop_opt) <= 1E-6);
index 6a7b2c0..cc39fcc 100644 (file)
@@ -39,27 +39,39 @@ ga_params = add_param(ga_params, "maxbound", ones(2, 1));
 [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = ..
 optim_moga(list(deb_2, 1, 9), PopSize, NbGen, Proba_mut, Proba_cross, Log, ga_params);
 optim_moga: Initialization of the population
-optim_moga: iteration 1 / 4 - min / max value found = -117.000000 / -59.000000
-optim_moga: iteration 2 / 4 - min / max value found = -62.000000 / -32.000000
-optim_moga: iteration 3 / 4 - min / max value found = -54.000000 / -15.000000
-optim_moga: iteration 4 / 4 - min / max value found = -59.000000 / -22.000000
+optim_moga: iteration 1 / 4 
+    min / max value found = 0.029324 / 1.259517
+optim_moga: iteration 2 / 4 
+    min / max value found = 0.098841 / 0.732534
+optim_moga: iteration 3 / 4 
+    min / max value found = 0.124679 / 0.656770
+optim_moga: iteration 4 / 4 
+    min / max value found = 0.225319 / 0.525795
 assert_checkequal(length(pop_opt), length(pop_init));
 assert_checkequal(size(fobj_pop_opt), size(fobj_pop_init));
 [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = ..
 optim_nsga(list(deb_2, 1, 9), PopSize, NbGen, Proba_mut, Proba_cross, Log, ga_params);
 optim_nsga: Initialization of the population
-optim_nsga: iteration 1 / 4 - min / max value found = -138.000000 / -57.000000
-optim_nsga: iteration 2 / 4 - min / max value found = -69.000000 / -30.000000
-optim_nsga: iteration 3 / 4 - min / max value found = -33.000000 / -16.000000
-optim_nsga: iteration 4 / 4 - min / max value found = -26.000000 / -10.000000
+optim_nsga: iteration 1 / 4 
+    min / max value found = 0.001301 / 2.440339
+optim_nsga: iteration 2 / 4 
+    min / max value found = 0.015645 / 0.948523
+optim_nsga: iteration 3 / 4 
+    min / max value found = 0.093593 / 0.695988
+optim_nsga: iteration 4 / 4 
+    min / max value found = 0.112577 / 0.665168
 assert_checkequal(length(pop_opt), length(pop_init));
 assert_checkequal(size(fobj_pop_opt), size(fobj_pop_init));
 [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = ..
 optim_nsga2(list(deb_2, 1, 9), PopSize, NbGen, Proba_mut, Proba_cross, Log, ga_params);
 optim_nsga2: Initialization of the population
 optim_nsga2: iteration 1 / 4
+    min / max value found = 0.002139 / 7.982432
 optim_nsga2: iteration 2 / 4
+    min / max value found = 0.000000 / 1.777920
 optim_nsga2: iteration 3 / 4
+    min / max value found = 0.000000 / 4.417277
 optim_nsga2: iteration 4 / 4
+    min / max value found = 0.000000 / 1.323218
 assert_checkequal(length(pop_opt), length(pop_init));
 assert_checkequal(size(fobj_pop_opt), size(fobj_pop_init));
index e4a5594..3789362 100644 (file)
@@ -1,10 +1,86 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 2008 - Yann COLLETTE <yann.collette@renault.com>
+// Copyright (C) Scilab Enterprises - 2014 - Pierre-Aime Agnel
 //
 // This file must be used under the terms of the CeCILL.
 // This source file is licensed as described in the file COPYING, which
 // you should have received as part of this distribution.  The terms
 // are also available at
 // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+// <-- CLI SHELL MODE -->
 [Crossed_Indiv1, Crossed_Indiv2] = crossover_ga_binary('11111111','00000000',[]);
 if (length(Crossed_Indiv1)~=8) | (length(Crossed_Indiv2)~=8) then bugmes();quit;end
+//==============================================================================
+// Nominal Behaviour
+//==============================================================================
+param = init_param("binary_length", 8, "multi_cross", %F, "multi_cross_nb", 1);
+A = "11111111";
+B = "00000000";
+// Reinitialize the seed
+grand("setsd", 0);
+[A_crossed, B_crossed, mix] = crossover_ga_binary(A, B);
+// Reinitialize the seed
+grand("setsd", 0);
+[A_crossed_p, B_crossed_p, mix] = crossover_ga_binary(A, B, param);
+//======================================
+// Check default behaviour of param
+//======================================
+assert_checkequal(A_crossed_p, A_crossed);
+assert_checkequal(B_crossed_p, B_crossed);
+assert_checkequal(size(mix, "*"), 1);
+//======================================
+// Check the crossover occurred
+//======================================
+// Heads
+assert_checkequal(part(A, 1:mix), part(A_crossed, 1:mix));
+assert_checkequal(part(B, 1:mix), part(B_crossed, 1:mix));
+// Tails
+assert_checkequal(part(A, (mix + 1):$), part(B_crossed, (mix + 1):$));
+assert_checkequal(part(B, (mix + 1):$), part(A_crossed, (mix + 1):$));
+//======================================
+// Binary length
+//======================================
+param = set_param(param, "binary_length", 16);
+A = dec2bin(2^16 - 1, 16); // 11111111 11111111
+B = dec2bin(0, 16); // 00000000 00000000
+[A_crossed, B_crossed, mix] = crossover_ga_binary(A, B, param);
+assert_checkequal(length(A_crossed), 16);
+assert_checkequal(length(B_crossed), 16);
+//======================================
+// Multiple Crossover
+//======================================
+param = init_param("binary_length", 16, "multi_cross", %T);
+s_mix = 0;
+iter = 0;
+// By default 2 crossovers
+while s_mix < 2 & iter <= 100
+    [A_crossed, B_crossed, mix] = crossover_ga_binary(A, B, param);
+    s_mix = size(mix, "*");
+    iter = iter + 1;
+end
+// Warning probabilistic test
+assert_checktrue(s_mix == 2); // we have reached one mix of length 2
+assert_checkfalse(iter>=100); // we have done it under 100 tries
+assert_checkequal(part(A_crossed, 1:mix(1)), part(A, 1:mix(1)));
+assert_checkequal(part(B_crossed, 1:mix(1)), part(B, 1:mix(1)));
+// Swapped
+assert_checkequal(part(A_crossed, (mix(1) + 1):mix(2)), part(B, (mix(1) + 1):mix(2)));
+assert_checkequal(part(B_crossed, (mix(1) + 1):mix(2)), part(A, (mix(1) + 1):mix(2)));
+// Same
+assert_checkequal(part(A_crossed, (mix(2) + 1):$), part(A, (mix(2) + 1):$));
+assert_checkequal(part(B_crossed, (mix(2) + 1):$), part(B, (mix(2) + 1):$));
+//======================================
+// Multiple Crossover Number
+//======================================
+param = init_param("binary_length", 16, "multi_cross", %T, "multi_cross_nb", 4);
+s_mix = 0;
+iter = 0;
+// By default 2 crossovers
+while s_mix < 4 & iter <= 100
+    [A_crossed, B_crossed, mix] = crossover_ga_binary(A, B, param);
+    s_mix = size(mix, "*");
+    iter = iter + 1;
+end
+// Warning probabilistic test
+assert_checktrue(s_mix == 4); // we have reached one mix of length 4
+assert_checkfalse(iter>=100); // we have done it under 100 tries
index 9874a15..3a97484 100644 (file)
@@ -1,6 +1,7 @@
 
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 2008 - Yann COLLETTE <yann.collette@renault.com>
+// Copyright (C) Scilab Enterprises - 2014 - Pierre-Aime Agnel
 //
 // This file must be used under the terms of the CeCILL.
 // This source file is licensed as described in the file COPYING, which
 [Crossed_Indiv1, Crossed_Indiv2] = crossover_ga_binary('11111111','00000000',[]);
 
 if (length(Crossed_Indiv1)~=8) | (length(Crossed_Indiv2)~=8) then pause,end
+
+//==============================================================================
+// Nominal Behaviour
+//==============================================================================
+param = init_param("binary_length", 8, "multi_cross", %F, "multi_cross_nb", 1);
+A = "11111111";
+B = "00000000";
+
+// Reinitialize the seed
+grand("setsd", 0);
+[A_crossed, B_crossed, mix] = crossover_ga_binary(A, B);
+
+// Reinitialize the seed
+grand("setsd", 0);
+[A_crossed_p, B_crossed_p, mix] = crossover_ga_binary(A, B, param);
+
+//======================================
+// Check default behaviour of param
+//======================================
+assert_checkequal(A_crossed_p, A_crossed);
+assert_checkequal(B_crossed_p, B_crossed);
+assert_checkequal(size(mix, "*"), 1);
+
+//======================================
+// Check the crossover occurred
+//======================================
+// Heads
+assert_checkequal(part(A, 1:mix), part(A_crossed, 1:mix));
+assert_checkequal(part(B, 1:mix), part(B_crossed, 1:mix));
+// Tails
+assert_checkequal(part(A, (mix + 1):$), part(B_crossed, (mix + 1):$));
+assert_checkequal(part(B, (mix + 1):$), part(A_crossed, (mix + 1):$));
+
+//======================================
+// Binary length
+//======================================
+param = set_param(param, "binary_length", 16);
+A = dec2bin(2^16 - 1, 16); // 11111111 11111111
+B = dec2bin(0, 16); // 00000000 00000000
+
+[A_crossed, B_crossed, mix] = crossover_ga_binary(A, B, param);
+assert_checkequal(length(A_crossed), 16);
+assert_checkequal(length(B_crossed), 16);
+
+//======================================
+// Multiple Crossover
+//======================================
+param = init_param("binary_length", 16, "multi_cross", %T);
+s_mix = 0;
+iter = 0;
+// By default 2 crossovers
+while s_mix < 2 & iter <= 100
+    [A_crossed, B_crossed, mix] = crossover_ga_binary(A, B, param);
+    s_mix = size(mix, "*");
+    iter = iter + 1;
+end
+
+// Warning probabilistic test
+assert_checktrue(s_mix == 2); // we have reached one mix of length 2
+assert_checkfalse(iter>=100); // we have done it under 100 tries
+assert_checkequal(part(A_crossed, 1:mix(1)), part(A, 1:mix(1)));
+assert_checkequal(part(B_crossed, 1:mix(1)), part(B, 1:mix(1)));
+
+// Swapped
+assert_checkequal(part(A_crossed, (mix(1) + 1):mix(2)), part(B, (mix(1) + 1):mix(2)));
+assert_checkequal(part(B_crossed, (mix(1) + 1):mix(2)), part(A, (mix(1) + 1):mix(2)));
+
+// Same
+assert_checkequal(part(A_crossed, (mix(2) + 1):$), part(A, (mix(2) + 1):$));
+assert_checkequal(part(B_crossed, (mix(2) + 1):$), part(B, (mix(2) + 1):$));
+
+//======================================
+// Multiple Crossover Number
+//======================================
+param = init_param("binary_length", 16, "multi_cross", %T, "multi_cross_nb", 4);
+s_mix = 0;
+iter = 0;
+// By default 2 crossovers
+while s_mix < 4 & iter <= 100
+    [A_crossed, B_crossed, mix] = crossover_ga_binary(A, B, param);
+    s_mix = size(mix, "*");
+    iter = iter + 1;
+end
+
+// Warning probabilistic test
+assert_checktrue(s_mix == 4); // we have reached one mix of length 4
+assert_checkfalse(iter>=100); // we have done it under 100 tries
index 240792d..fbff95a 100644 (file)
@@ -49,17 +49,26 @@ ga_params = add_param(ga_params, "nb_couples", NbCouples);
 ga_params = add_param(ga_params, "pressure", pressure);
 [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = ..
 optim_ga(f, PopSize, NbGen, Proba_mut, Proba_cross, Log, ga_params);
-optim_ga: Initialization of the population
-optim_ga: iteration 1 / 10 - min / max value found = 0.001391 / 0.995046
-optim_ga: iteration 2 / 10 - min / max value found = 0.000206 / 0.191417
-optim_ga: iteration 3 / 10 - min / max value found = 0.000126 / 0.048784
-optim_ga: iteration 4 / 10 - min / max value found = 0.000118 / 0.011398
-optim_ga: iteration 5 / 10 - min / max value found = 0.000046 / 0.001167
-optim_ga: iteration 6 / 10 - min / max value found = 0.000034 / 0.000284
-optim_ga: iteration 7 / 10 - min / max value found = 0.000004 / 0.000114
-optim_ga: iteration 8 / 10 - min / max value found = 0.000001 / 0.000036
-optim_ga: iteration 9 / 10 - min / max value found = 0.000000 / 0.000010
-optim_ga: iteration 10 / 10 - min / max value found = 0.000000 / 0.000003
+optim_ga: iteration 1 / 10 
+    min / max value found = 0.001391 / 0.995046
+optim_ga: iteration 2 / 10 
+    min / max value found = 0.000341 / 0.177816
+optim_ga: iteration 3 / 10 
+    min / max value found = 0.000133 / 0.044825
+optim_ga: iteration 4 / 10 
+    min / max value found = 0.000002 / 0.010889
+optim_ga: iteration 5 / 10 
+    min / max value found = 0.000002 / 0.001507
+optim_ga: iteration 6 / 10 
+    min / max value found = 0.000002 / 0.000310
+optim_ga: iteration 7 / 10 
+    min / max value found = 0.000001 / 0.000089
+optim_ga: iteration 8 / 10 
+    min / max value found = 0.000000 / 0.000014
+optim_ga: iteration 9 / 10 
+    min / max value found = 0.000000 / 0.000003
+optim_ga: iteration 10 / 10 
+    min / max value found = 0.000000 / 0.000001
 assert_checkequal(length(pop_opt), length(pop_init));
 assert_checkequal(size(fobj_pop_opt), size(fobj_pop_init));
 // Customizing the init function, which computes the initial population.
@@ -90,19 +99,28 @@ ga_params = add_param(ga_params, "dimension", 2);
 ga_params = add_param(ga_params, "init_func", myinitga);
 [pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = ..
 optim_ga(f, PopSize, NbGen, Proba_mut, Proba_cross, Log, ga_params);
-optim_ga: Initialization of the population
  
  Initializing the Population with grand   
-optim_ga: iteration 1 / 10 - min / max value found = 0.010016 / 0.928237
-optim_ga: iteration 2 / 10 - min / max value found = 0.006862 / 0.161421
-optim_ga: iteration 3 / 10 - min / max value found = 0.001781 / 0.037628
-optim_ga: iteration 4 / 10 - min / max value found = 0.000544 / 0.011567
-optim_ga: iteration 5 / 10 - min / max value found = 0.000039 / 0.003271
-optim_ga: iteration 6 / 10 - min / max value found = 0.000039 / 0.001117
-optim_ga: iteration 7 / 10 - min / max value found = 0.000005 / 0.000307
-optim_ga: iteration 8 / 10 - min / max value found = 0.000001 / 0.000092
-optim_ga: iteration 9 / 10 - min / max value found = 0.000000 / 0.000034
-optim_ga: iteration 10 / 10 - min / max value found = 0.000000 / 0.000010
+optim_ga: iteration 1 / 10 
+    min / max value found = 0.010016 / 0.928237
+optim_ga: iteration 2 / 10 
+    min / max value found = 0.001402 / 0.198423
+optim_ga: iteration 3 / 10 
+    min / max value found = 0.000809 / 0.045008
+optim_ga: iteration 4 / 10 
+    min / max value found = 0.000053 / 0.013969
+optim_ga: iteration 5 / 10 
+    min / max value found = 0.000053 / 0.003974
+optim_ga: iteration 6 / 10 
+    min / max value found = 0.000040 / 0.000922
+optim_ga: iteration 7 / 10 
+    min / max value found = 0.000005 / 0.000240
+optim_ga: iteration 8 / 10 
+    min / max value found = 0.000001 / 0.000057
+optim_ga: iteration 9 / 10 
+    min / max value found = 0.000000 / 0.000020
+optim_ga: iteration 10 / 10 
+    min / max value found = 0.000000 / 0.000007
 assert_checkequal(length(pop_opt), length(pop_init));
 assert_checkequal(size(fobj_pop_opt), size(fobj_pop_init));
 // Passing a list to the optim_ga function, where the first element of the list is
@@ -121,16 +139,25 @@ a2 = 7;
 myobjfun = list(f, a1, a2);
 // Optimize !
 [pop_opt, fobj_pop_opt] = optim_ga(myobjfun, PopSize, NbGen, Proba_mut, Proba_cross, Log, ga_params);
-optim_ga: Initialization of the population
-optim_ga: iteration 1 / 10 - min / max value found = 7.339791 / 29.150584
-optim_ga: iteration 2 / 10 - min / max value found = 7.199192 / 11.923950
-optim_ga: iteration 3 / 10 - min / max value found = 7.199192 / 8.613638
-optim_ga: iteration 4 / 10 - min / max value found = 7.106121 / 7.425043
-optim_ga: iteration 5 / 10 - min / max value found = 7.026332 / 7.199192
-optim_ga: iteration 6 / 10 - min / max value found = 7.002293 / 7.078284
-optim_ga: iteration 7 / 10 - min / max value found = 7.002293 / 7.032606
-optim_ga: iteration 8 / 10 - min / max value found = 7.000564 / 7.012589
-optim_ga: iteration 9 / 10 - min / max value found = 7.000280 / 7.004547
-optim_ga: iteration 10 / 10 - min / max value found = 7.000039 / 7.001819
+optim_ga: iteration 1 / 10 
+    min / max value found = 7.339791 / 29.150584
+optim_ga: iteration 2 / 10 
+    min / max value found = 7.054037 / 12.127766
+optim_ga: iteration 3 / 10 
+    min / max value found = 7.048084 / 9.120917
+optim_ga: iteration 4 / 10 
+    min / max value found = 7.025101 / 7.630176
+optim_ga: iteration 5 / 10 
+    min / max value found = 7.007453 / 7.191936
+optim_ga: iteration 6 / 10 
+    min / max value found = 7.005699 / 7.054037
+optim_ga: iteration 7 / 10 
+    min / max value found = 7.000896 / 7.020325
+optim_ga: iteration 8 / 10 
+    min / max value found = 7.000375 / 7.007070
+optim_ga: iteration 9 / 10 
+    min / max value found = 7.000156 / 7.002255
+optim_ga: iteration 10 / 10 
+    min / max value found = 7.000112 / 7.000828
 assert_checkequal(length(pop_opt), length(pop_init));
 assert_checkequal(size(fobj_pop_opt), size(fobj_pop_init));
index 8427b6a..2c20720 100644 (file)
@@ -2,11 +2,11 @@
 <!--
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) ENPC - Jean-Philippe Chancelier
- * 
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
  *
  -->
     </refsection>
     <refsection>
         <title>Examples</title>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
 plot3d() ;
 // puts the titles
 xtitle( 'My surface is blue', 'X axis', 'Y axis', 'Z axis' ) ;
 // draw a box around the titles
-xtitle( 'My surface is blue', 'X axis', 'Y axis', 'Z axis', boxed = 1 );
+xtitle( 'My surface is blue', 'X axis', 'Y axis', 'Z axis', boxed = %t );
 
 
 // With LaTeX & MathML:
index d4e4dd4..aea2ffe 100644 (file)
@@ -17,8 +17,9 @@
     </refnamediv>
     <refsynopsisdiv>
         <title>Calling Sequence</title>
-        <synopsis>drawaxis([options])
-            // options: x,y,dir,sub_int,fontsize,format_n,seg,textcolor,ticscolor,tics
+        <synopsis>
+            drawaxis([options]); // options: x,y,dir,sub_int,fontsize,format_n,seg,textcolor,ticscolor,tics
+            e = drawaxis([options]);
         </synopsis>
     </refsynopsisdiv>
     <refsection>
                     </para>
                 </listitem>
             </varlistentry>
+            <varlistentry>
+                <term>e</term>
+                <listitem>
+                    <para>
+                        handle, the handle of the created axis.
+                    </para>
+                </listitem>
+            </varlistentry>
         </variablelist>
     </refsection>
     <refsection>
         <title>Description</title>
         <para>
             <literal>drawaxis</literal> is used to draw an axis in vertical or horizontal 
-            direction. the direction of the axis is given by dir 
+            direction. This function returns the handle of the created axis. 
+            The direction of the axis is given by dir 
             <literal>dir = 'u'</literal> or <literal>'d'</literal> gives a horizontal axis 
             with tics going up (<literal>'u'</literal>) or down (<literal>'d'</literal>). 
             <literal>dir = 'r'</literal> or <literal>'l'</literal> give a vertical axis 
         <programlisting role="example"><![CDATA[ 
 plot2d(1:10,1:10,1,"020")
 // horizontal axis 
-drawaxis(x=2:7,y=4,dir='u',tics='v')
+e = drawaxis(x=2:7,y=4,dir='u',tics='v')
 // horizontal axis on top of the frame
 drawaxis(x=2:7,dir='u',tics='v') 
 // horizontal axis at the bottom of the frame
-drawaxis(x=2:7,dir='d',tics='v') 
+e = drawaxis(x=2:7,dir='d',tics='v') 
 
 // horizontal axis given by a range 
 drawaxis(x=[2,7,3],y=4,dir='d',tics='r') 
 
 // vertical axis 
-drawaxis(x=4,y=2:7,dir='r',tics='v')
-drawaxis(x=2,y=[2,7,3],dir='l',tics='r')
-drawaxis(y=2:7,dir='r',tics='v')
-drawaxis(y=2:7,dir='l',tics='v')
+e = drawaxis(x=4,y=2:7,dir='r',tics='v')
+e = drawaxis(x=2,y=[2,7,3],dir='l',tics='r')
+e = drawaxis(y=2:7,dir='r',tics='v')
+e = drawaxis(y=2:7,dir='l',tics='v')
 
 // horizontal axis with strings displayed at tics positions
 drawaxis(x=2:7,y=8,dir='u',tics='v',val='A'+string(1:6));
@@ -165,8 +175,8 @@ drawaxis(x=2:7,y=8,dir='u',tics='v',val='A'+string(1:6));
 drawaxis(x=8,y=2:7,dir='r',tics='v',val='B'+string(1:6));
 
 // horizontal axis given with a 'i' range. 
-drawaxis(x=[2,5,0,3],y=9,dir='u',tics='i');
-drawaxis(x=9,y=[2,5,0,3],dir='r',tics='i',sub_int=5);
+e = drawaxis(x=[2,5,0,3],y=9,dir='u',tics='i');
+e = drawaxis(x=9,y=[2,5,0,3],dir='r',tics='i',sub_int=5);
 
 // horizontal axis again 
 drawaxis(x=2:7,y=4,dir='u',tics='v',fontsize=10,textcolor=9,ticscolor=7,seg=0,sub_int=20) 
index 067b9c6..f333944 100644 (file)
@@ -6,8 +6,9 @@
     </refnamediv>
     <refsynopsisdiv>
         <title>Séquence d'appel</title>
-        <synopsis>drawaxis([options])
-            // options: x,y,dir,sub_int,fontsize,format_n,seg,textcolor,ticscolor,tics
+        <synopsis>
+            drawaxis([options]) // options : x,y,dir,sub_int,fontsize,format_n,seg,textcolor,ticscolor,tics
+            e = drawaxis([options])
         </synopsis>
     </refsynopsisdiv>
     <refsection>
                     </para>
                 </listitem>
             </varlistentry>
+            <varlistentry>
+                <term>e</term>
+                <listitem>
+                    <para>
+                        handle, le handle de l'axe créé.
+                    </para>
+                </listitem>
+            </varlistentry>
         </variablelist>
     </refsection>
     <refsection>
         <title>Description</title>
         <para>
-            <literal>drawaxis</literal> est utilisée pour dessiner un axe vertical ou horizontal. La direction de l'axe est donnée par dir <literal>dir = 'u'</literal> ou <literal>'d'</literal> donne un axe horizontal avec des graduations 
+            <literal>drawaxis</literal> est utilisée pour dessiner un axe vertical ou horizontal. Cette fonction renvoie le handle de l'axe créé. 
+            La direction de l'axe est donnée par dir <literal>dir = 'u'</literal> ou <literal>'d'</literal> donne un axe horizontal avec des graduations 
             dirigées vers le haut (<literal>'u'</literal>) ou le bas (<literal>'d'</literal>). 
             <literal>dir = 'r'</literal> ou <literal>'l'</literal> donne un axe vertical avec des graduations allant vers la droite (<literal>'r'</literal>) ou vers la gauche (<literal>'l'</literal>). 
         </para>
         <programlisting role="example"><![CDATA[ 
 plot2d(1:10,1:10,1,"020")
 // axe horizontal
-drawaxis(x=2:7,y=4,dir='u',tics='v')
+e = drawaxis(x=2:7,y=4,dir='u',tics='v')
 // axe horizontal en haut du cadre
 drawaxis(x=2:7,dir='u',tics='v') 
 // axe horizontal en bas du cadre
-drawaxis(x=2:7,dir='d',tics='v') 
+e = drawaxis(x=2:7,dir='d',tics='v') 
 
 // axe horizontal donné par une plage de variation 
 drawaxis(x=[2,7,3],y=4,dir='d',tics='r') 
 
 // axe vertical
-drawaxis(x=4,y=2:7,dir='r',tics='v')
-drawaxis(x=2,y=[2,7,3],dir='l',tics='r')
-drawaxis(y=2:7,dir='r',tics='v')
-drawaxis(y=2:7,dir='l',tics='v')
+e = drawaxis(x=4,y=2:7,dir='r',tics='v')
+e = drawaxis(x=2,y=[2,7,3],dir='l',tics='r')
+e = drawaxis(y=2:7,dir='r',tics='v')
+e = drawaxis(y=2:7,dir='l',tics='v')
 
 // axe horizontal avec chaînes de caractères au dessus des graduations
 drawaxis(x=2:7,y=8,dir='u',tics='v',val='A'+string(1:6));
@@ -153,8 +163,8 @@ drawaxis(x=2:7,y=8,dir='u',tics='v',val='A'+string(1:6));
 drawaxis(x=8,y=2:7,dir='r',tics='v',val='B'+string(1:6));
 
 // axe horizontal avec 'i' 
-drawaxis(x=[2,5,0,3],y=9,dir='u',tics='i');
-drawaxis(x=9,y=[2,5,0,3],dir='r',tics='i',sub_int=5);
+e = drawaxis(x=[2,5,0,3],y=9,dir='u',tics='i');
+e = drawaxis(x=9,y=[2,5,0,3],dir='r',tics='i',sub_int=5);
 
 // encore un axe horizontal
 drawaxis(x=2:7,y=4,dir='u',tics='v',fontsize=10,textcolor=9,ticscolor=7,seg=0,sub_int=20) 
index 2b8b4f1..92f2ca2 100644 (file)
 <?xml version="1.0" encoding="UTF-8"?>
-
 <!--
-
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-
  * Copyright (C) ENPC - Jean-Philippe Chancelier
-
- * 
-
+ *
  * This file must be used under the terms of the CeCILL.
-
  * This source file is licensed as described in the file COPYING, which
-
  * you should have received as part of this distribution.  The terms
-
- * are also available at    
-
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
-
  *
-
  -->
-
 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"  xml:lang="ja" xml:id="xtitle">
-    
     <refnamediv>
-        
         <refname>xtitle</refname>
-        
         <refpurpose>グラフィックスウインドにタイトルを追加する</refpurpose>
-        
     </refnamediv>
-    
     <refsynopsisdiv>
-        
         <title>呼び出し手順</title>
-        
         <synopsis>xtitle(title,[x_label,[y_label,[z_label]]],&lt;opts_args&gt;)</synopsis>
-        
     </refsynopsisdiv>
-    
     <refsection>
-        
         <title>引数</title>
-        
         <variablelist>
-            
             <varlistentry>
-                
                 <term>title,x_label,y_label, z_label</term>
-                
                 <listitem>
-                    
                     <para>文字列の行列.</para>
-                    
-                    <para>Scilab 5.2以降, 
-                        
+                    <para>Scilab 5.2以降,
                         <link linkend="math_rendering_features_in_graphic">LaTeX
-                            
                             または MathML 式
-                            
                         </link>
-                        
                         を指定することができます.
-                        
                     </para>
-                    
                 </listitem>
-                
             </varlistentry>
-            
             <varlistentry>
-                
                 <term>&lt;opt_args&gt;</term>
-                
                 <listitem>
-                    
                     <para>
-                        
                         一連の命令 <literal>key1=value1,
-                            
                             key2=value2
-                            
                         </literal>
-                        
                         ,... ,ただし,
-                        
                         キーには<literal>boxed</literal>とすることが
-                        
                         できます(下記参照).
-                        
                         この場合, 順番に特別な意味はありません.
-                        
                     </para>
-                    
                 </listitem>
-                
             </varlistentry>
-            
             <varlistentry>
-                
                 <term>boxed</term>
-                
                 <listitem>
-                    
                     <para>整数値. 1の場合, 各タイトルの周囲にボックスが
-                        
                         描画されます.
-                        
                     </para>
-                    
                 </listitem>
-                
             </varlistentry>
-            
         </variablelist>
-        
     </refsection>
-    
     <refsection>
-        
         <title>説明</title>
-        
         <para>
-            
             <literal>xtitle</literal> は 2D または 3D プロットに
-            
-            タイトルを追加します. 
-            
+            タイトルを追加します.
             <literal>title</literal>は一般的なタイトルで,
-            
-            <emphasis role="bold">x_label</emphasis>, 
-            
+            <emphasis role="bold">x_label</emphasis>,
             <emphasis role="bold">y_label</emphasis> および
-            
             <emphasis role="bold">z_label</emphasis> は
-            
             3軸のタイトルです.
-            
             引数が行列の場合,行列の各行が異なる線上に表示されます.
-            
         </para>
-        
         <para>
-            
             デモを参照には,コマンド <literal>xtitle()</literal> と入力してください.
-            
         </para>
-        
     </refsection>
-    
     <refsection>
-        
         <title>例</title>
-        
-        <programlisting role="example"><![CDATA[ 
-
+        <programlisting role="example"><![CDATA[
 plot3d() ;
-
 // タイトルを描画
-
 xtitle( 'My surface is blue', 'X axis', 'Y axis', 'Z axis' ) ;
-
 // タイトルの周囲にボックスを描画
-
-xtitle( 'My surface is blue', 'X axis', 'Y axis', 'Z axis', boxed = 1 );
-
-
-
-
+xtitle( 'My surface is blue', 'X axis', 'Y axis', 'Z axis', boxed = %t );
 
 //  LaTeX & MathMLで指定:
-
 mathml="<mrow>      <mfrac>        <mrow>          <mi>d</mi>          <mi>y</mi>        </mrow>        <mrow>          <mi>d</mi>          <mi>x</mi>        </mrow>      </mfrac>      <mo>=</mo>      <mfrac>        <mn>1</mn>        <msup>          <mi>y</mi>          <mn>2</mn>        </msup>      </mfrac>    </mrow>";
 
-
-
 xtitle( 'My surface is blue', 'X axis', '$Y axis$', mathml );
-
  ]]></programlisting>
-        
         <scilab:image>
-            
             plot3d() ;
-            
             xtitle( 'My surface is blue', 'X axis', 'Y axis', 'Z axis' ) ;
-            
         </scilab:image>
-        
     </refsection>
-    
     <refsection role="see also">
-        
         <title>参考</title>
-        
         <simplelist type="inline">
-            
             <member>
-                
                 <link linkend="titlepage">titlepage</link>
-                
             </member>
-            
             <member>
-                
                 <link linkend="label_properties">label_properties</link>
-                
             </member>
-            
         </simplelist>
-        
     </refsection>
-    
 </refentry>
-
index 45bd0ed..bcea08f 100644 (file)
@@ -2,11 +2,11 @@
 <!--
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) ENPC - Jean-Philippe Chancelier
- * 
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
  *
  -->
     </refsection>
     <refsection>
         <title>Exemplos</title>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
 // desenhando uma superfície
 plot3d() ;
 // pondo os títulos
 xtitle( 'Minha superfície é azul', 'eixo X', 'eixo Y', 'eixo Z' ) ;
 // desenhando uma caixa ao redor dos títulos
-xtitle( 'Minha superfície é azul', 'eixo X', 'eixo Y', 'eixo Z' , boxed = 1 ) ;
+xtitle( 'Minha superfície é azul', 'eixo X', 'eixo Y', 'eixo Z' , boxed = %t ) ;
  ]]></programlisting>
     </refsection>
     <refsection role="see also">
index f16a619..65bea94 100644 (file)
@@ -29,6 +29,7 @@
 #include "getGraphicObjectProperty.h"
 #include "graphicObjectProperties.h"
 #include "CurrentSubwin.h"
+#include "HandleManagement.h"
 
 /*--------------------------------------------------------------------------*/
 // get_optionals not yet managed
@@ -65,6 +66,7 @@ int sci_drawaxis(char *fname, unsigned long fname_len)
     double *x = NULL, *y = NULL;
     int nx = 0, ny = 0, ntics;
     int nb_tics_labels = -1;
+    int iRhs = nbInputArgument(pvApiCtx);
 
     nopt = NumOpt();
 
@@ -283,7 +285,8 @@ int sci_drawaxis(char *fname, unsigned long fname_len)
 
     Objdrawaxis(dir, tics, x, &nx, y, &ny, val, sub_int, format, fontsize, textcolor, ticscolor, 'n', seg_flag, nb_tics_labels);
 
-    AssignOutputVariable(pvApiCtx, 1) = 0;
+    createScalarHandle(pvApiCtx, iRhs + 1, getHandle(getCurrentObject()));
+    AssignOutputVariable(pvApiCtx, 1) = iRhs + 1;
     ReturnArguments(pvApiCtx);
     return 0;
 }
index 15b5dd6..af72436 100644 (file)
@@ -139,9 +139,10 @@ int sci_xarrows(char *fname, unsigned long fname_len)
                     Scierror(999, _("%s: Wrong size for input argument #%d: A real scalar expected.\n"), fname, 4);
                     return 1;
                 }
+
+                arsize = *dl4;
+                stylePos = 5;
             }
-            arsize = *dl4;
-            stylePos = 5;
         }
         else if (m3 == 1 && n3 == 1)
         {
index d72ea6a..9449370 100644 (file)
@@ -70,6 +70,9 @@ int sci_xfpolys(char *fname, unsigned long fname_len)
     int iVisible = 0;
     int *piVisible = &iVisible;
 
+    int iType = 0;
+    int *piType = &iType;
+
     CheckInputArgument(pvApiCtx, 2, 3);
 
     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl1);
@@ -194,7 +197,14 @@ int sci_xfpolys(char *fname, unsigned long fname_len)
     }
 
     iSubWinUID = getOrCreateDefaultSubwin();
-    iFigureUID = getParentObject(iSubWinUID);
+    iFigureUID = iSubWinUID;
+    iType = 0;
+    while (iType != __GO_FIGURE__)
+    {
+        iFigureUID = getParentObject(iFigureUID);
+        getGraphicObjectProperty(iFigureUID, __GO_TYPE__, jni_int, (void **) &piType);
+    }
+
     getGraphicObjectProperty(iFigureUID, __GO_IMMEDIATE_DRAWING__, jni_bool, (void **)&piImmediateDrawing);
     setGraphicObjectProperty(iFigureUID, __GO_IMMEDIATE_DRAWING__, &iFalse, jni_bool, 1);
 
diff --git a/scilab/modules/graphics/tests/nonreg_tests/bug_13438.dia.ref b/scilab/modules/graphics/tests/nonreg_tests/bug_13438.dia.ref
new file mode 100644 (file)
index 0000000..8a8f66f
--- /dev/null
@@ -0,0 +1,29 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Vladislav TRUBKIN
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- Non-regression test for bug 13438 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=13438
+//
+// <-- Short Description -->
+// drawaxis() did not return the handle of the current entity.
+plot2d(1:10, 1:10);
+eRef = drawaxis(x = 2:7, y = 4, dir = "u", tics = "v");
+eNew = gce();
+assert_checktrue(eRef == eNew);
+eRef = drawaxis(x = 4, y = 2:7, dir = "r", tics = "v");
+eNew = gce();
+assert_checktrue(eRef == eNew);
+eRef = drawaxis(x = 8, y = 2:9, dir = "r", tics = "v", val = "value: "+string(1:8));
+eNew = gce();
+assert_checktrue(eRef == eNew);
+eRef = drawaxis(x = 3, y = 2:9, dir = "l", tics = "v", val = "value: "+string(1:8));
+eNew = gce();
+assert_checktrue(eRef == eNew);
diff --git a/scilab/modules/graphics/tests/nonreg_tests/bug_13438.tst b/scilab/modules/graphics/tests/nonreg_tests/bug_13438.tst
new file mode 100644 (file)
index 0000000..2dab6de
--- /dev/null
@@ -0,0 +1,30 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Vladislav TRUBKIN
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- Non-regression test for bug 13438 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=13438
+//
+// <-- Short Description -->
+// drawaxis() did not return the handle of the current entity.
+
+plot2d(1:10, 1:10);
+eRef = drawaxis(x = 2:7, y = 4, dir = "u", tics = "v");
+eNew = gce();
+assert_checktrue(eRef == eNew);
+eRef = drawaxis(x = 4, y = 2:7, dir = "r", tics = "v");
+eNew = gce();
+assert_checktrue(eRef == eNew);
+eRef = drawaxis(x = 8, y = 2:9, dir = "r", tics = "v", val = "value: "+string(1:8));
+eNew = gce();
+assert_checktrue(eRef == eNew);
+eRef = drawaxis(x = 3, y = 2:9, dir = "l", tics = "v", val = "value: "+string(1:8));
+eNew = gce();
+assert_checktrue(eRef == eNew);
diff --git a/scilab/modules/graphics/tests/nonreg_tests/bug_13503.dia.ref b/scilab/modules/graphics/tests/nonreg_tests/bug_13503.dia.ref
new file mode 100644 (file)
index 0000000..3302ff6
--- /dev/null
@@ -0,0 +1,15 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+// <-- Non-regression test for bug 13503 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13503
+//
+// <-- Short Description -->
+// Segfault with xarrows
+xarrows([0 ; 1], [0 ; 0], [0 ; 0]);
diff --git a/scilab/modules/graphics/tests/nonreg_tests/bug_13503.tst b/scilab/modules/graphics/tests/nonreg_tests/bug_13503.tst
new file mode 100644 (file)
index 0000000..89be5fe
--- /dev/null
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- TEST WITH GRAPHIC -->
+
+// <-- Non-regression test for bug 13503 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13503
+//
+// <-- Short Description -->
+// Segfault with xarrows
+
+xarrows([0 ; 1], [0 ; 0], [0 ; 0]);
\ No newline at end of file
diff --git a/scilab/modules/graphics/tests/nonreg_tests/bug_8502.dia.ref b/scilab/modules/graphics/tests/nonreg_tests/bug_8502.dia.ref
new file mode 100644 (file)
index 0000000..a4101cb
--- /dev/null
@@ -0,0 +1,17 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+// <-- Non-regression test for bug 8502 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/8502
+//
+// <-- Short Description -->
+// -Axis labels use number with 3digits in the exponent like 8e+005 instead of 8e+05
+f=scf();
+plot(logspace(5,10,100));
+assert_checkequal(f.children.y_ticks.labels,["0e00";"1e09";"2e09";"3e09";"4e09";"5e09";"6e09";"7e09";"8e09";"9e09";"1e10"]);
diff --git a/scilab/modules/graphics/tests/nonreg_tests/bug_8502.tst b/scilab/modules/graphics/tests/nonreg_tests/bug_8502.tst
new file mode 100644 (file)
index 0000000..87cb3f2
--- /dev/null
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- TEST WITH GRAPHIC -->
+
+// <-- Non-regression test for bug 8502 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/8502
+//
+// <-- Short Description -->
+// -Axis labels use number with 3digits in the exponent like 8e+005 instead of 8e+05
+
+f=scf();
+plot(logspace(5,10,100));
+assert_checkequal(f.children.y_ticks.labels,["0e00";"1e09";"2e09";"3e09";"4e09";"5e09";"6e09";"7e09";"8e09";"9e09";"1e10"]);
diff --git a/scilab/modules/graphics/tests/nonreg_tests/bug_9052.dia.ref b/scilab/modules/graphics/tests/nonreg_tests/bug_9052.dia.ref
new file mode 100644 (file)
index 0000000..cc3e751
--- /dev/null
@@ -0,0 +1,52 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+// <-- Non-regression test for bug 9052 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/9052
+//
+// <-- Short Description -->
+// All demos in graphics/animations are automatically closed at the end of each one
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim1","anim1.sce");
+exec(path_demo,-1);
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim2","anim2.sce");
+exec(path_demo,-1);
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim3","anim3.sce");
+exec(path_demo,-1);
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim4","anim4.sce");
+exec(path_demo,-1);
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim5","anim5.sce");
+exec(path_demo,-1);
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim6","anim6.sce");
+exec(path_demo,-1);
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim7","anim7.sce");
+exec(path_demo,-1);
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim8","anim8.sci");
+exec(path_demo,-1);
+demo_riemann();
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","bubbleSort","bubbleSort.sci");
+exec(path_demo,-1);
+demo_bubbleSort();
+assert_checkequal(winsid(), 0);
diff --git a/scilab/modules/graphics/tests/nonreg_tests/bug_9052.tst b/scilab/modules/graphics/tests/nonreg_tests/bug_9052.tst
new file mode 100644 (file)
index 0000000..c4aea83
--- /dev/null
@@ -0,0 +1,53 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+// <-- Non-regression test for bug 9052 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/9052
+//
+// <-- Short Description -->
+// All demos in graphics/animations are automatically closed at the end of each one
+
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim1","anim1.sce");
+exec(path_demo,-1);
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim2","anim2.sce");
+exec(path_demo,-1);
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim3","anim3.sce");
+exec(path_demo,-1);
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim4","anim4.sce");
+exec(path_demo,-1);
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim5","anim5.sce");
+exec(path_demo,-1);
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim6","anim6.sce");
+exec(path_demo,-1);
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim7","anim7.sce");
+exec(path_demo,-1);
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","anim8","anim8.sci");
+exec(path_demo,-1);
+demo_riemann();
+assert_checkequal(winsid(), 100001);
+xdel(winsid());
+path_demo = fullfile(SCI,"modules","graphics","demos","anim","bubbleSort","bubbleSort.sci");
+exec(path_demo,-1);
+demo_bubbleSort();
+assert_checkequal(winsid(), 0);
index 7fa1efc..8ba18de 100644 (file)
@@ -15,7 +15,6 @@
 #ifndef _MSC_VER
 #include <errno.h>
 #include <stdio.h> /* fileno */
-#define __USE_FORTIFY_LEVEL 0 /* Avoid dependency on GLIBC_2.15 __fdelt_chk */
 #include <sys/select.h> /* fd_set */
 #include "core_math.h" /* Max */
 #include "sciprint.h"
@@ -153,12 +152,12 @@ int Xorgetchar(int interrupt)
             {
                 state = 0;
             }
-            return(i);
+            return (i);
         }
 
         if (interrupt && (ismenu() == 1))
         {
-            return(-1);
+            return (-1);
         }
 
     }
index d681bb2..31b6074 100644 (file)
@@ -626,7 +626,7 @@ acsc_1.png=4fd05d7d355266d821063c9a6c26abb0
 acscd_1.png=6e599765c5f8d0e189002d51f2d9068a
 acsch_1.png=15259a5eaa158abd0fd70e05b27d69eb
 addcolor_1.png=7e5f272c2700aafbd41da8efd8e9d8eb
-analpf_1.png=49761592911a102d7857d7e457b15f5c
+analpf_1.png=6d59d9510e91abd50fcfd04a4b129d93
 analyze_1.png=f618685a506715b35493fcc61fe78a25
 arl2_1.png=2aa2b498c2c79a58ef145a5e82349c2b
 arma_en_US_1.png=dc5f992783f4db687e23a65866dac816
@@ -1028,7 +1028,7 @@ odedc_1.png=57d86d2363e4bb2756f86162c95e1923
 odedc_2.png=e200739457adb87740d6eda59334854b
 odedc_3.png=3d3d5ac8d7a133e26039e93609be5cd0
 odeoptions_1.png=12573ee6be852c456cf883e79dbea5f6
-optim_1.png=a2d9b2e879963549e64862118514b4c8
+optim_1.png=cafe7b8b2481c1d3de07a1a83c8c00f4
 optim_sa_1.png=b2a6a1ff9fec247aba2e606e45387997
 ordmmd_en_US_1.png=65695a27c9eaf674ba4eac782ec20eba
 ordmmd_fr_FR_1.png=65695a27c9eaf674ba4eac782ec20eba
@@ -1188,9 +1188,9 @@ wavread_1.png=7f4fa7fd3215e86c6beac1b99ed5c107
 whitecolormap_1.png=5c902a640b651c5ec7bcfdeba604e3c0
 wiener_1.png=7cf1c15abff7e9f0c2ca9bd45882a5c
 wigner_1.png=f775cca252e20dd1029d24f5cc6f430a
-window_1.png=f05b8e9a82a05f23882773da0b2c3f75
+window_1.png=4de5a4eee9a8a1ef039c8c9c8e65d6bb
 window_2.png=44cddcb55562ebc6e02da35aafb9c0c0
-window_3.png=7d418f2773c98bc31c261c6f5f112913
+window_3.png=5da80737d10d701654fe8d0b5b5bc703
 wintercolormap_1.png=149a68e3ce0fc6154a1b5f9ee7c63796
 xarc_1.png=e07703b3710275fc7e1403637b6eac7f
 xarc_2.png=cc873861271071e2fdc147d8fa82617c
index e93f6de..623f0ac 100644 (file)
Binary files a/scilab/modules/helptools/images/LOGICAL_OP.png and b/scilab/modules/helptools/images/LOGICAL_OP.png differ
index 8e3b9bb..07d64fc 100644 (file)
Binary files a/scilab/modules/helptools/images/RELATIONALOP.png and b/scilab/modules/helptools/images/RELATIONALOP.png differ
index bc0470b..ed75ae8 100644 (file)
Binary files a/scilab/modules/helptools/images/analpf_1.png and b/scilab/modules/helptools/images/analpf_1.png differ
index 33ad88e..45f676c 100644 (file)
Binary files a/scilab/modules/helptools/images/optim_1.png and b/scilab/modules/helptools/images/optim_1.png differ
index 0ef59fd..05828d8 100644 (file)
Binary files a/scilab/modules/helptools/images/window_1.png and b/scilab/modules/helptools/images/window_1.png differ
index f3fd642..f72e9bb 100644 (file)
Binary files a/scilab/modules/helptools/images/window_3.png and b/scilab/modules/helptools/images/window_3.png differ
index 1202014..8fa1b17 100644 (file)
     </refnamediv>
     <refsynopsisdiv>
         <title>Calling Sequence</title>
-        <synopsis>[unit [,err]]=file('open', file-name [,status] [,access [,recl]] [,format])
-            file(action,unit)
+        <synopsis>[unit [,err]]=file("open", file-name [,status] [,access [,recl]] [,format])
+            file("close", unit)
+            file("rewind", unit)
+            file("backspace", unit)
+            file("last", unit)
             [units [,typ [,nams [,mod [,swap]]]]] = file([unit])
         </synopsis>
     </refsynopsisdiv>
                     </para>
                 </listitem>
             </varlistentry>
-            <varlistentry>
-                <term>action</term>
-                <listitem>
-                    <para>is one of the following strings:</para>
-                    <variablelist>
-                        <varlistentry>
-                            <term>"close"</term>
-                            <listitem>
-                                <para>closes the file(s) given by the logical unit descriptors
-                                    given in <literal>units</literal>
-                                </para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>"rewind"</term>
-                            <listitem>
-                                <para>puts the pointer at beginning of file</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>"backspace"</term>
-                            <listitem>
-                                <para>puts the pointer at beginning of last record.</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>"last"</term>
-                            <listitem>
-                                <para>puts the pointer after last record.</para>
-                            </listitem>
-                        </varlistentry>
-                    </variablelist>
-                </listitem>
-            </varlistentry>
         </variablelist>
     </refsection>
     <refsection>
         <title>Description</title>
         <para>
-            selects a logical unit <literal>unit</literal> and manages the file
-            <literal>file-name</literal>.
+            selects a logical unit <varname>unit</varname> and manages the file
+            <varname>file-name</varname>.
         </para>
+        <variablelist>
+            <varlistentry>
+                <term>[unit [,err]]=file("open", file-name [,status] [,access
+                    [,recl]][,format])
+                </term>
+                <listitem>
+                    <para>
+                        allows to open a file with specified
+                        properties and to get the associated unit number <varname>unit</varname>.
+                        This unit number may be used for further actions on this file or as file
+                        descriptor in <function>read</function>, <function>write</function>,
+                        <function>readb</function>,
+                        <function>writb</function>,<function>save</function>, <function>load</function>
+                        function calls.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>
+                    file("close", unit)
+                </term>
+                <listitem>
+                    <para>
+                        allows to close the file, or move the current file pointer.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>
+                    file("rewind", unit)
+                </term>
+                <listitem>
+                    <para>
+                        puts the pointer at the beginning of file.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>
+                    file("backspace", unit)
+                </term>
+                <listitem>
+                    <para>
+                        puts the pointer at the beginning of last record.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>
+                    file("last", unit)
+                </term>
+                <listitem>
+                    <para>
+                        puts the pointer after last record.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>
+                    file()
+                </term>
+                <listitem>
+                    <para>
+                        returns the logical unit descriptors of
+                        the opened files. So <literal>file("close",file())</literal> closes all
+                        user opened files (C or Fortran type).
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
         <para>
-            <literal>[unit [,err]]=file('open', file-name [,status] [,access
-                [,recl]][,format])
-            </literal>
-            allows to open a file with specified
-            properties and to get the associated unit number <literal>unit</literal>.
-            This unit number may be used for further actions on this file or as file
-            descriptor in <literal>read</literal>, <literal>write</literal>,
-            <literal>readb</literal>,
-            <literal>writb</literal>,<literal>save</literal>, <literal>load</literal>
-            function calls.
-        </para>
-        <para>This function can not open a UTF filename. In this case, please uses
+            This function can not open a UTF filename. In this case, please uses
             mopen.
         </para>
-        <para>
-            <literal>file(action,unit)</literal> allows to close the file , or
-            move the current file pointer .
-        </para>
-        <para>
-            <literal>file()</literal> returns the logical unit descriptors of
-            the opened files. So <literal>file('close',file() )</literal> closes all
-            user opened files (C or Fortran type).
-        </para>
     </refsection>
     <refsection>
         <title>Examples</title>
         <programlisting role="example"><![CDATA[
-u=file('open',TMPDIR+'/foo','unknown')
+u=file("open",TMPDIR+"/foo","unknown")
 for k=1:4
   a=rand(1,4)
   write(u,a)
 end
-file('rewind',u)
+file("rewind",u)
 x=read(u,2,4)
-file('close',u)
+file("close",u)
 //
-u1=file('open',TMPDIR+'/foo','unknown')
-u2=mopen(TMPDIR+'/foo1','wb')
+u1=file("open",TMPDIR+"/foo","unknown")
+u2=mopen(TMPDIR+"/foo1","wb")
 [units,typs,nams]=file()
-file('close',u1);
+file("close",u1);
 mclose(u2);
  ]]></programlisting>
     </refsection>
index 22497e3..ddb7b68 100644 (file)
@@ -976,9 +976,9 @@ maintainer-clean-generic:
        @echo "This command is intended for maintainers to use"
        @echo "it deletes files that may require special tools to rebuild."
        -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
-@JAVASCI_FALSE@install-html-local:
 @JAVASCI_FALSE@install-data-local:
 @JAVASCI_FALSE@clean-local:
+@JAVASCI_FALSE@install-html-local:
 @JAVASCI_FALSE@distclean-local:
 clean: clean-am
 
index 7811c76..749c90a 100644 (file)
@@ -98,6 +98,8 @@ int sci_addlocalizationdomain(char *fname, unsigned long fname_len)
         return 0;
     }
 
+    bind_textdomain_codeset (pstDomain, "UTF-8"); /*such that gettext and dgettext return UTF8 string*/
+
     if (createScalarBoolean(pvApiCtx, iRhs + 1, 1))
     {
         Scierror(999, _("%s: Unable to add new domain %s.\n"), fname, pstDomain);
diff --git a/scilab/modules/matio/tests/nonreg_tests/bug_11035.dia.ref b/scilab/modules/matio/tests/nonreg_tests/bug_11035.dia.ref
new file mode 100644 (file)
index 0000000..1a7e8dc
--- /dev/null
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 11035 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11035
+//
+// <-- Short Description -->
+// Scilab crashes when loading a mat file created with Matlab 7.12
+path_file = fullfile(SCI, "modules","matio","tests","nonreg_tests","bug_11035.mat");
+assert_checktrue(execstr("loadmatfile(path_file)","errcatch") == 0);
diff --git a/scilab/modules/matio/tests/nonreg_tests/bug_11035.mat b/scilab/modules/matio/tests/nonreg_tests/bug_11035.mat
new file mode 100644 (file)
index 0000000..c4ed1de
Binary files /dev/null and b/scilab/modules/matio/tests/nonreg_tests/bug_11035.mat differ
diff --git a/scilab/modules/matio/tests/nonreg_tests/bug_11035.tst b/scilab/modules/matio/tests/nonreg_tests/bug_11035.tst
new file mode 100644 (file)
index 0000000..8fdd777
--- /dev/null
@@ -0,0 +1,19 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 11035 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11035
+//
+// <-- Short Description -->
+// Scilab crashes when loading a mat file created with Matlab 7.12
+
+path_file = fullfile(SCI, "modules","matio","tests","nonreg_tests","bug_11035.mat");
+assert_checktrue(execstr("loadmatfile(path_file)","errcatch") == 0);
index 8a9186a..1c9e55b 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Scilab (http://www.scilab.org/) - This file is part of Scilab
  * Copyright (C) 2008 - INRIA
  * Copyright (C) 2008 - 2009 - INRIA - Michael Baudin
  * Copyright (C) 2010 - 2011 - DIGITEO - Michael Baudin
                 <listitem>
                     <para>a sequence of arguments containing the parameters controlling
                         the convergence of the algorithm. The following sequences are
-                        available: <screen>              "ar",nap
-                            "ar",nap,iter
-                            "ar",nap,iter,epsg
-                            "ar",nap,iter,epsg,epsf
-                            "ar",nap,iter,epsg,epsf,epsx
+                        available:
+                        <screen><![CDATA[
+"ar",nap
+"ar",nap,iter
+"ar",nap,iter,epsg
+"ar",nap,iter,epsg,epsf
+"ar",nap,iter,epsg,epsf,epsx]]>
                         </screen>
                     </para>
                     <para>where:</para>
                                 parameters of the <literal>nird</literal> common, which is
                                 defined as:
                             </para>
-                            <screen>common /nird/ nizs,nrzs,ndzs    </screen>
+                            <screen>common /nird/ nizs,nrzs,ndzs</screen>
                             <para>This allows Scilab to allocate memory inside its internal
                                 workspace. The second time the objective function is called,
                                 <literal>ind</literal> is set to 11 and the objective function
         <para>This function solves unconstrained nonlinear optimization
             problems:
         </para>
-        <screen>min f(x)      </screen>
+        <screen>min f(x)</screen>
         <para>
             where <literal>x</literal> is a vector and <literal>f(x)</literal>
             is a function that returns a scalar. This function can also solve bound
             constrained nonlinear optimization problems:
         </para>
-        <screen>min f(x)
-            binf &lt;= x &lt;= bsup
+        <screen><![CDATA[
+min f(x)
+binf <= x <= bsup]]>
         </screen>
         <para>
             where <literal>binf</literal> is the lower bound and
                         If <literal>costf</literal> is a Scilab function, its calling
                         sequence must be:
                     </para>
-                    <screen>[f, g, ind] = costf(x, ind)      </screen>
+                    <screen>[f, g, ind] = costf(x, ind)</screen>
                     <para>
                         where <literal>x</literal> is the current point,
                         <literal>ind</literal> is an integer flag described below,
                         <literal>costf</literal> argument can be the list
                         <literal>(real_costf, arg1,...,argn)</literal>. In this case,
                         <literal>real_costf</literal>, the first element in the list, must
-                        be a Scilab function with calling sequence: <screen>        [f,g,ind]=real_costf(x,ind,arg1,...,argn)      </screen>
+                        be a Scilab function with calling sequence:
+                        <screen><![CDATA[
+[f,g,ind]=real_costf(x,ind,arg1,...,argn)]]>
+                        </screen>
                         The <literal>x</literal>, <literal>f</literal>,
                         <literal>g</literal>, <literal>ind</literal> arguments have the same
                         meaning as before. In this case, each time the objective function is
                                 <para>The calling sequence of the Fortran subroutine computing
                                     the objective must be:
                                 </para>
-                                <screen>subroutine costf(ind,n,x,f,g,ti,tr,td)      </screen>
+                                <screen>subroutine costf(ind,n,x,f,g,ti,tr,td)</screen>
                                 <para>with the following declarations:</para>
-                                <screen>integer ind,n ti(*)
-                                    double precision x(n),f,g(n),td(*)
-                                    real tr(*)
-                                </screen>
+                                <screen><![CDATA[
+integer ind,n ti(*)
+double precision x(n),f,g(n),td(*)
+real tr(*)]]></screen>
                                 <para>
                                     The argument <literal>ind</literal> is described
                                     below.
                                 <para>The calling sequence of the C function computing the
                                     objective must be:
                                 </para>
-                                <screen>void costf(int *ind, int *n, double *x, double *f, double *g, int *ti, float *tr, double *td)      </screen>
+                                <screen>void costf(int *ind, int *n, double *x, double *f, double *g, int *ti, float *tr, double *td)</screen>
                                 <para>
                                     The argument <literal>ind</literal> is described
                                     below.
             issues so that a direct optimization may be to use the value of "ind" to
             compute "f" and "g" only when needed.
         </para>
-        <programlisting role="example">function [f, g, ind] = cost(x, ind)
-            xref = [1; 2; 3];
-            f = 0.5 * norm(x - xref)^2;
-            g = x - xref;
-            endfunction
+        <programlisting role="example"><![CDATA[
+function [f, g, ind] = cost(x, ind)
+    xref = [1; 2; 3];
+    f = 0.5 * norm(x - xref)^2;
+    g = x - xref;
+endfunction
 
-            // Simplest call
-            x0 = [1; -1; 1];
-            [fopt, xopt] = optim(cost, x0)
+// Simplest call
+x0 = [1; -1; 1];
+[fopt, xopt] = optim(cost, x0)
 
-            // Use "gc" algorithm
-            [fopt, xopt, gopt] = optim(cost, x0, "gc")
+// Use "gc" algorithm
+[fopt, xopt, gopt] = optim(cost, x0, "gc")
 
-            // Use "nd" algorithm
-            [fopt, xopt, gopt] = optim(cost, x0, "nd")
+// Use "nd" algorithm
+[fopt, xopt, gopt] = optim(cost, x0, "nd")
 
-            // Upper and lower bounds on x
-            [fopt, xopt, gopt] = optim(cost, "b", [-1;0;2], [0.5;1;4], x0)
+// Upper and lower bounds on x
+[fopt, xopt, gopt] = optim(cost, "b", [-1;0;2], [0.5;1;4], x0)
 
-            // Upper and lower bounds on x and setting up the algorithm to "gc"
-            [fopt, xopt, gopt] = optim(cost, "b", [-1; 0; 2], [0.5; 1; 4], x0, "gc")
+// Upper and lower bounds on x and setting up the algorithm to "gc"
+[fopt, xopt, gopt] = optim(cost, "b", [-1; 0; 2], [0.5; 1; 4], x0, "gc")
 
-            // Bound on the number of calls to the objective function
-            [fopt, xopt, gopt] = optim(cost, "b", [-1; 0; 2], [0.5; 1; 4], x0, "gc", "ar", 3)
+// Bound on the number of calls to the objective function
+[fopt, xopt, gopt] = optim(cost, "b", [-1; 0; 2], [0.5; 1; 4], x0, "gc", "ar", 3)
 
-            // Set max number of calls to the objective function (3)
-            // Set max number of iterations (100)
-            // Set stopping threshold on the value of f (1e-6),
-            // on the value of the norm of the gradient of the objective function (1e-6)
-            // on the improvement on the parameters x_opt (1e-6;1e-6;1e-6)
-            [fopt, xopt, gopt] = optim(cost, "b", [-1; 0; 2], [0.5; 1; 4], x0, "gc", "ar", 3, 100, 1e-6, 1e-6, [1e-3; 1e-3; 1e-3])
+// Set max number of calls to the objective function (3)
+// Set max number of iterations (100)
+// Set stopping threshold on the value of f (1e-6),
+// on the value of the norm of the gradient of the objective function (1e-6)
+// on the improvement on the parameters x_opt (1e-6;1e-6;1e-6)
+[fopt, xopt, gopt] = optim(cost, "b", [-1; 0; 2], [0.5; 1; 4], x0, "gc", "ar", 3, 100, 1e-6, 1e-6, [1e-3; 1e-3; 1e-3])
 
-            // Additional messages are printed in the console.
-            [fopt, xopt] = optim(cost, x0, imp = 3)
+// Additional messages are printed in the console.
+[fopt, xopt] = optim(cost, x0, imp = 3)
+]]>
         </programlisting>
     </refsection>
     <refsection>
         <para>In the following example, we solve the Rosenbrock test case. For
             each iteration of the algorithm, we print the value of x, f and g.
         </para>
-        <programlisting role="example">function [f, g, ind] = cost(x, ind)
-            xref = [1; 2; 3];
-            f = 0.5 * norm(x - xref)^2;
-            g = x - xref;
-            if (ind == 1) then
-            mprintf("f(x) = %s, |g(x)|=%s\n", string(f), string(norm(g)))
-            end
-            endfunction
+        <programlisting role="example"><![CDATA[
+function [f, g, ind] = cost(x, ind)
+    xref = [1; 2; 3];
+    f = 0.5 * norm(x - xref)^2;
+    g = x - xref;
+    if (ind == 1) then
+        mprintf("f(x) = %s, |g(x)|=%s\n", string(f), string(norm(g)))
+    end
+endfunction
 
-            x0 = [1; -1; 1];
-            [fopt, xopt] = optim(cost, x0, imp = -1)
+x0 = [1; -1; 1];
+[fopt, xopt] = optim(cost, x0, imp = -1)
+]]>
         </programlisting>
         <para>The previous script produces the following output.</para>
-        <screen>--&gt;[fopt, xopt] = optim(cost, x0, imp = -1)
-            f(x) = 6.5, |g(x)|=3.6055513
-            f(x) = 2.8888889, |g(x)|=2.4037009
-            f(x) = 9.861D-31, |g(x)|=1.404D-15
-            f(x) = 0, |g(x)|=0
-            Norm of projected gradient lower than   0.0000000D+00.
-            xopt  =
-            1.
-            2.
-            3.
-            fopt  =
-            0.
+        <screen><![CDATA[
+-->[fopt, xopt] = optim(cost, x0, imp = -1)
+f(x) = 6.5, |g(x)|=3.6055513
+f(x) = 2.8888889, |g(x)|=2.4037009
+f(x) = 9.861D-31, |g(x)|=1.404D-15
+f(x) = 0, |g(x)|=0
+Norm of projected gradient lower than   0.0000000D+00.
+
+ xopt  =
+
+    1.
+    2.
+    3.
+ fopt  =
+
+    0.
+]]>
         </screen>
         <para>In the following example, we solve the Rosenbrock test case. For
             each iteration of the algorithm, we plot the current value of x into a 2D
             the progress of the algorithm while the algorithm is performing. We could
             as well write the value of x, f and g into a log file if needed.
         </para>
-        <programlisting role="example">// 1. Define Rosenbrock for optimization
-            function [f , g , ind] = rosenbrock (x , ind)
-            f = 100.0 *(x(2) - x(1)^2)^2 + (1 - x(1))^2;
-            g(1) = - 400. * ( x(2) - x(1)**2 ) * x(1) -2. * ( 1. - x(1) )
-            g(2) = 200. * ( x(2) - x(1)**2 )
-            endfunction
+        <programlisting role="example"><![CDATA[
+// 1. Define Rosenbrock for optimization
+function [f, g, ind] = rosenbrock (x, ind)
+    f = 100.0 *(x(2) - x(1)^2)^2 + (1 - x(1))^2;
+    g(1) = - 400. * (x(2) - x(1)**2) * x(1) -2. * (1. - x(1))
+    g(2) = 200. * (x(2) - x(1)**2)
+endfunction
 
-            // 2. Define rosenbrock for contouring
-            function f = rosenbrockC ( x1 , x2 )
-            x = [x1 x2]
-            ind = 4
-            [ f , g , ind ] = rosenbrock ( x , ind )
-            endfunction
+// 2. Define rosenbrock for contouring
+function f = rosenbrockC (x1, x2)
+    x = [x1 x2]
+    ind = 4
+    [f, g, ind] = rosenbrock (x, ind)
+endfunction
 
-            // 3. Define Rosenbrock for plotting
-            function [ f , g , ind ] = rosenbrockPlot ( x , ind )
-            [ f , g , ind ] = rosenbrock ( x , ind )
-            if (ind == 1) then
-            plot ( x(1) , x(2) , "g." )
-            end
-            endfunction
+// 3. Define Rosenbrock for plotting
+function [f, g, ind] = rosenbrockPlot (x, ind)
+    [f, g, ind] = rosenbrock (x, ind)
+    if (ind == 1) then
+        plot (x(1), x(2), "g.")
+    end
+endfunction
 
-            // 4. Draw the contour of Rosenbrock's function
-            x0 = [-1.2 1.0];
-            xopt = [1.0 1.0];
-            xdata = linspace(-2,2,100);
-            ydata = linspace(-2,2,100);
-            contour ( xdata , ydata , rosenbrockC , [1 10 100 500 1000])
-            plot(x0(1) , x0(2) , "b.")
-            plot(xopt(1) , xopt(2) , "r*")
+// 4. Draw the contour of Rosenbrock's function
+x0 = [-1.2 1.0];
+xopt = [1.0 1.0];
+xdata = linspace(-2,2,100);
+ydata = linspace(-2,2,100);
+contour (xdata, ydata, rosenbrockC, [1 10 100 500 1000])
+plot(x0(1), x0(2), "b.")
+plot(xopt(1), xopt(2), "r*")
 
-            // 5. Plot the optimization process, during optimization
-            [fopt, xopt] = optim ( rosenbrockPlot , x0 , imp = -1)
+// 5. Plot the optimization process, during optimization
+[fopt, xopt] = optim (rosenbrockPlot, x0, imp = -1)
+]]>
         </programlisting>
         <scilab:image>
             function [f, g, ind]=rosenbrock(x, ind)
             f = 100.0 *(x(2) - x(1)^2)^2 + (1 - x(1))^2;
-            g(1) = - 400. * ( x(2) - x(1)**2 ) * x(1) -2. * ( 1. - x(1) )
-            g(2) = 200. * ( x(2) - x(1)**2 )
+            g(1) = - 400. * (x(2) - x(1)**2) * x(1) -2. * (1. - x(1))
+            g(2) = 200. * (x(2) - x(1)**2)
             endfunction
-
+            
             function f=rosenbrockC(x1, x2)
             x = [x1 x2]
             ind = 4
-            [ f , g , ind ] = rosenbrock ( x , ind )
+            [f, g, ind] = rosenbrock (x, ind)
             endfunction
-
+