summaryrefslogtreecommitdiff
path: root/nlpsolver/ThirdParty/EvolutionarySolver
diff options
context:
space:
mode:
Diffstat (limited to 'nlpsolver/ThirdParty/EvolutionarySolver')
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/build.xml74
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/nbproject/build-impl.xml642
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/nbproject/genfiles.properties8
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/nbproject/project.properties59
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/nbproject/project.xml16
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java127
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java36
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java81
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java117
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalElement.java70
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalStruct.java60
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/IEncodeEngine.java24
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicArray.java31
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicBound.java94
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicTag.java40
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/CompareValue.java20
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalCompare.java46
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalFile.java277
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalString.java149
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/IUpdateCycleEngine.java24
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/OutputMethods.java50
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/RandomGenerator.java162
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/ACRComparator.java90
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/BCHComparator.java47
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/IGoodnessCompareEngine.java38
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/PenaltyComparator.java41
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/SRComparator.java41
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/ILibEngine.java30
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/Library.java106
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/SearchPoint.java79
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/ProblemEncoder.java123
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/UnconstrainedProblemEncoder.java39
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java132
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/BasicPoint.java42
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignDim.java52
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignSpace.java141
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/ILocationEngine.java25
37 files changed, 3233 insertions, 0 deletions
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/build.xml b/nlpsolver/ThirdParty/EvolutionarySolver/build.xml
new file mode 100755
index 000000000000..73ee22085284
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/build.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See commented blocks below for -->
+<!-- some examples of how to customize the build. -->
+<!-- (If you delete it and reopen the project it will be recreated.) -->
+<!-- By default, only the Clean and Build commands use this build script. -->
+<!-- Commands such as Run, Debug, and Test only use this build script if -->
+<!-- the Compile on Save feature is turned off for the project. -->
+<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
+<!-- in the project's Project Properties dialog box.-->
+<project name="EvolutionarySolver" default="default" basedir=".">
+ <description>Builds, tests, and runs the project EvolutionarySolver.</description>
+ <import file="nbproject/build-impl.xml"/>
+ <!--
+
+ There exist several targets which are by default empty and which can be
+ used for execution of your tasks. These targets are usually executed
+ before and after some main targets. They are:
+
+ -pre-init: called before initialization of project properties
+ -post-init: called after initialization of project properties
+ -pre-compile: called before javac compilation
+ -post-compile: called after javac compilation
+ -pre-compile-single: called before javac compilation of single file
+ -post-compile-single: called after javac compilation of single file
+ -pre-compile-test: called before javac compilation of JUnit tests
+ -post-compile-test: called after javac compilation of JUnit tests
+ -pre-compile-test-single: called before javac compilation of single JUnit test
+ -post-compile-test-single: called after javac compilation of single JUunit test
+ -pre-jar: called before JAR building
+ -post-jar: called after JAR building
+ -post-clean: called after cleaning build products
+
+ (Targets beginning with '-' are not intended to be called on their own.)
+
+ Example of inserting an obfuscator after compilation could look like this:
+
+ <target name="-post-compile">
+ <obfuscate>
+ <fileset dir="${build.classes.dir}"/>
+ </obfuscate>
+ </target>
+
+ For list of available properties check the imported
+ nbproject/build-impl.xml file.
+
+
+ Another way to customize the build is by overriding existing main targets.
+ The targets of interest are:
+
+ -init-macrodef-javac: defines macro for javac compilation
+ -init-macrodef-junit: defines macro for junit execution
+ -init-macrodef-debug: defines macro for class debugging
+ -init-macrodef-java: defines macro for class execution
+ -do-jar-with-manifest: JAR building (if you are using a manifest)
+ -do-jar-without-manifest: JAR building (if you are not using a manifest)
+ run: execution of project
+ -javadoc-build: Javadoc generation
+ test-report: JUnit report generation
+
+ An example of overriding the target for project execution could look like this:
+
+ <target name="run" depends="EvolutionarySolver-impl.jar">
+ <exec dir="bin" executable="launcher.exe">
+ <arg file="${dist.jar}"/>
+ </exec>
+ </target>
+
+ Notice that the overridden target depends on the jar target and not only on
+ the compile target as the regular run target does. Again, for a list of available
+ properties which you can use, check the target you are overriding in the
+ nbproject/build-impl.xml file.
+
+ -->
+</project>
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/nbproject/build-impl.xml b/nlpsolver/ThirdParty/EvolutionarySolver/nbproject/build-impl.xml
new file mode 100755
index 000000000000..dd95469f4910
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/nbproject/build-impl.xml
@@ -0,0 +1,642 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT ***
+*** EDIT ../build.xml INSTEAD ***
+
+For the purpose of easier reading the script
+is divided into following sections:
+
+ - initialization
+ - compilation
+ - jar
+ - execution
+ - debugging
+ - javadoc
+ - junit compilation
+ - junit execution
+ - junit debugging
+ - applet
+ - cleanup
+
+ -->
+<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="EvolutionarySolver-impl">
+ <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
+ <!--
+ ======================
+ INITIALIZATION SECTION
+ ======================
+ -->
+ <target name="-pre-init">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="-pre-init" name="-init-private">
+ <property file="nbproject/private/config.properties"/>
+ <property file="nbproject/private/configs/${config}.properties"/>
+ <property file="nbproject/private/private.properties"/>
+ </target>
+ <target depends="-pre-init,-init-private" name="-init-user">
+ <property file="${user.properties.file}"/>
+ <!-- The two properties below are usually overridden -->
+ <!-- by the active platform. Just a fallback. -->
+ <property name="default.javac.source" value="1.4"/>
+ <property name="default.javac.target" value="1.4"/>
+ </target>
+ <target depends="-pre-init,-init-private,-init-user" name="-init-project">
+ <property file="nbproject/configs/${config}.properties"/>
+ <property file="nbproject/project.properties"/>
+ </target>
+ <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
+ <available file="${manifest.file}" property="manifest.available"/>
+ <condition property="manifest.available+main.class">
+ <and>
+ <isset property="manifest.available"/>
+ <isset property="main.class"/>
+ <not>
+ <equals arg1="${main.class}" arg2="" trim="true"/>
+ </not>
+ </and>
+ </condition>
+ <condition property="manifest.available+main.class+mkdist.available">
+ <and>
+ <istrue value="${manifest.available+main.class}"/>
+ <isset property="libs.CopyLibs.classpath"/>
+ </and>
+ </condition>
+ <condition property="have.tests">
+ <or>
+ <available file="${test.src.dir}"/>
+ </or>
+ </condition>
+ <condition property="have.sources">
+ <or>
+ <available file="${src.dir}"/>
+ </or>
+ </condition>
+ <condition property="netbeans.home+have.tests">
+ <and>
+ <isset property="netbeans.home"/>
+ <isset property="have.tests"/>
+ </and>
+ </condition>
+ <condition property="no.javadoc.preview">
+ <and>
+ <isset property="javadoc.preview"/>
+ <isfalse value="${javadoc.preview}"/>
+ </and>
+ </condition>
+ <property name="run.jvmargs" value=""/>
+ <property name="javac.compilerargs" value=""/>
+ <property name="work.dir" value="${basedir}"/>
+ <condition property="no.deps">
+ <and>
+ <istrue value="${no.dependencies}"/>
+ </and>
+ </condition>
+ <property name="javac.debug" value="true"/>
+ <property name="javadoc.preview" value="true"/>
+ <property name="application.args" value=""/>
+ <property name="source.encoding" value="${file.encoding}"/>
+ <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
+ <and>
+ <isset property="javadoc.encoding"/>
+ <not>
+ <equals arg1="${javadoc.encoding}" arg2=""/>
+ </not>
+ </and>
+ </condition>
+ <property name="javadoc.encoding.used" value="${source.encoding}"/>
+ <property name="includes" value="**"/>
+ <property name="excludes" value=""/>
+ <property name="do.depend" value="false"/>
+ <condition property="do.depend.true">
+ <istrue value="${do.depend}"/>
+ </condition>
+ <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
+ <and>
+ <isset property="jaxws.endorsed.dir"/>
+ <available file="nbproject/jaxws-build.xml"/>
+ </and>
+ </condition>
+ </target>
+ <target name="-post-init">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
+ <fail unless="src.dir">Must set src.dir</fail>
+ <fail unless="test.src.dir">Must set test.src.dir</fail>
+ <fail unless="build.dir">Must set build.dir</fail>
+ <fail unless="dist.dir">Must set dist.dir</fail>
+ <fail unless="build.classes.dir">Must set build.classes.dir</fail>
+ <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
+ <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
+ <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
+ <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
+ <fail unless="dist.jar">Must set dist.jar</fail>
+ </target>
+ <target name="-init-macrodef-property">
+ <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute name="name"/>
+ <attribute name="value"/>
+ <sequential>
+ <property name="@{name}" value="${@{value}}"/>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-macrodef-javac">
+ <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
+ <attribute default="${src.dir}" name="srcdir"/>
+ <attribute default="${build.classes.dir}" name="destdir"/>
+ <attribute default="${javac.classpath}" name="classpath"/>
+ <attribute default="${includes}" name="includes"/>
+ <attribute default="${excludes}" name="excludes"/>
+ <attribute default="${javac.debug}" name="debug"/>
+ <attribute default="/does/not/exist" name="sourcepath"/>
+ <element name="customize" optional="true"/>
+ <sequential>
+ <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
+ <customize/>
+ </javac>
+ </sequential>
+ </macrodef>
+ <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
+ <attribute default="${src.dir}" name="srcdir"/>
+ <attribute default="${build.classes.dir}" name="destdir"/>
+ <attribute default="${javac.classpath}" name="classpath"/>
+ <sequential>
+ <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ </depend>
+ </sequential>
+ </macrodef>
+ <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
+ <attribute default="${build.classes.dir}" name="destdir"/>
+ <sequential>
+ <fail unless="javac.includes">Must set javac.includes</fail>
+ <pathconvert pathsep="," property="javac.includes.binary">
+ <path>
+ <filelist dir="@{destdir}" files="${javac.includes}"/>
+ </path>
+ <globmapper from="*.java" to="*.class"/>
+ </pathconvert>
+ <delete>
+ <files includes="${javac.includes.binary}"/>
+ </delete>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-macrodef-junit">
+ <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
+ <attribute default="${includes}" name="includes"/>
+ <attribute default="${excludes}" name="excludes"/>
+ <attribute default="**" name="testincludes"/>
+ <sequential>
+ <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
+ <batchtest todir="${build.test.results.dir}">
+ <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+ <filename name="@{testincludes}"/>
+ </fileset>
+ </batchtest>
+ <classpath>
+ <path path="${run.test.classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="test-sys-prop."/>
+ <mapper from="test-sys-prop.*" to="*" type="glob"/>
+ </syspropertyset>
+ <formatter type="brief" usefile="false"/>
+ <formatter type="xml"/>
+ <jvmarg line="${run.jvmargs}"/>
+ </junit>
+ </sequential>
+ </macrodef>
+ </target>
+ <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
+ <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute default="${main.class}" name="name"/>
+ <attribute default="${debug.classpath}" name="classpath"/>
+ <attribute default="" name="stopclassname"/>
+ <sequential>
+ <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ </nbjpdastart>
+ </sequential>
+ </macrodef>
+ <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute default="${build.classes.dir}" name="dir"/>
+ <sequential>
+ <nbjpdareload>
+ <fileset dir="@{dir}" includes="${fix.classes}">
+ <include name="${fix.includes}*.class"/>
+ </fileset>
+ </nbjpdareload>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-debug-args">
+ <property name="version-output" value="java version &quot;${ant.java.version}"/>
+ <condition property="have-jdk-older-than-1.4">
+ <or>
+ <contains string="${version-output}" substring="java version &quot;1.0"/>
+ <contains string="${version-output}" substring="java version &quot;1.1"/>
+ <contains string="${version-output}" substring="java version &quot;1.2"/>
+ <contains string="${version-output}" substring="java version &quot;1.3"/>
+ </or>
+ </condition>
+ <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
+ <istrue value="${have-jdk-older-than-1.4}"/>
+ </condition>
+ <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
+ <os family="windows"/>
+ </condition>
+ <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
+ <isset property="debug.transport"/>
+ </condition>
+ </target>
+ <target depends="-init-debug-args" name="-init-macrodef-debug">
+ <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+ <attribute default="${main.class}" name="classname"/>
+ <attribute default="${debug.classpath}" name="classpath"/>
+ <element name="customize" optional="true"/>
+ <sequential>
+ <java classname="@{classname}" dir="${work.dir}" fork="true">
+ <jvmarg line="${debug-args-line}"/>
+ <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+ <jvmarg line="${run.jvmargs}"/>
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="run-sys-prop."/>
+ <mapper from="run-sys-prop.*" to="*" type="glob"/>
+ </syspropertyset>
+ <customize/>
+ </java>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-macrodef-java">
+ <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute default="${main.class}" name="classname"/>
+ <element name="customize" optional="true"/>
+ <sequential>
+ <java classname="@{classname}" dir="${work.dir}" fork="true">
+ <jvmarg line="${run.jvmargs}"/>
+ <classpath>
+ <path path="${run.classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="run-sys-prop."/>
+ <mapper from="run-sys-prop.*" to="*" type="glob"/>
+ </syspropertyset>
+ <customize/>
+ </java>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-presetdef-jar">
+ <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <jar compress="${jar.compress}" jarfile="${dist.jar}">
+ <j2seproject1:fileset dir="${build.classes.dir}"/>
+ </jar>
+ </presetdef>
+ </target>
+ <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/>
+ <!--
+ ===================
+ COMPILATION SECTION
+ ===================
+ -->
+ <target depends="init" name="deps-jar" unless="no.deps"/>
+ <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
+ <target depends="init" name="-check-automatic-build">
+ <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
+ </target>
+ <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
+ <antcall target="clean"/>
+ </target>
+ <target depends="init,deps-jar" name="-pre-pre-compile">
+ <mkdir dir="${build.classes.dir}"/>
+ </target>
+ <target name="-pre-compile">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target if="do.depend.true" name="-compile-depend">
+ <j2seproject3:depend/>
+ </target>
+ <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
+ <j2seproject3:javac/>
+ <copy todir="${build.classes.dir}">
+ <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+ </copy>
+ </target>
+ <target name="-post-compile">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
+ <target name="-pre-compile-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
+ <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+ <j2seproject3:force-recompile/>
+ <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
+ </target>
+ <target name="-post-compile-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
+ <!--
+ ====================
+ JAR BUILDING SECTION
+ ====================
+ -->
+ <target depends="init" name="-pre-pre-jar">
+ <dirname file="${dist.jar}" property="dist.jar.dir"/>
+ <mkdir dir="${dist.jar.dir}"/>
+ </target>
+ <target name="-pre-jar">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
+ <j2seproject1:jar/>
+ </target>
+ <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
+ <j2seproject1:jar manifest="${manifest.file}"/>
+ </target>
+ <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
+ <j2seproject1:jar manifest="${manifest.file}">
+ <j2seproject1:manifest>
+ <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
+ </j2seproject1:manifest>
+ </j2seproject1:jar>
+ <echo>To run this application from the command line without Ant, try:</echo>
+ <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+ <property location="${dist.jar}" name="dist.jar.resolved"/>
+ <pathconvert property="run.classpath.with.dist.jar">
+ <path path="${run.classpath}"/>
+ <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
+ </pathconvert>
+ <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
+ </target>
+ <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
+ <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+ <pathconvert property="run.classpath.without.build.classes.dir">
+ <path path="${run.classpath}"/>
+ <map from="${build.classes.dir.resolved}" to=""/>
+ </pathconvert>
+ <pathconvert pathsep=" " property="jar.classpath">
+ <path path="${run.classpath.without.build.classes.dir}"/>
+ <chainedmapper>
+ <flattenmapper/>
+ <globmapper from="*" to="lib/*"/>
+ </chainedmapper>
+ </pathconvert>
+ <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
+ <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
+ <fileset dir="${build.classes.dir}"/>
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}"/>
+ <attribute name="Class-Path" value="${jar.classpath}"/>
+ </manifest>
+ </copylibs>
+ <echo>To run this application from the command line without Ant, try:</echo>
+ <property location="${dist.jar}" name="dist.jar.resolved"/>
+ <echo>java -jar "${dist.jar.resolved}"</echo>
+ </target>
+ <target name="-post-jar">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
+ <!--
+ =================
+ EXECUTION SECTION
+ =================
+ -->
+ <target depends="init,compile" description="Run a main class." name="run">
+ <j2seproject1:java>
+ <customize>
+ <arg line="${application.args}"/>
+ </customize>
+ </j2seproject1:java>
+ </target>
+ <target name="-do-not-recompile">
+ <property name="javac.includes.binary" value=""/>
+ </target>
+ <target depends="init,-do-not-recompile,compile-single" name="run-single">
+ <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+ <j2seproject1:java classname="${run.class}"/>
+ </target>
+ <!--
+ =================
+ DEBUGGING SECTION
+ =================
+ -->
+ <target depends="init" if="netbeans.home" name="-debug-start-debugger">
+ <j2seproject1:nbjpdastart name="${debug.class}"/>
+ </target>
+ <target depends="init,compile" name="-debug-start-debuggee">
+ <j2seproject3:debug>
+ <customize>
+ <arg line="${application.args}"/>
+ </customize>
+ </j2seproject3:debug>
+ </target>
+ <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
+ <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
+ <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
+ </target>
+ <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
+ <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
+ <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+ <j2seproject3:debug classname="${debug.class}"/>
+ </target>
+ <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
+ <target depends="init" name="-pre-debug-fix">
+ <fail unless="fix.includes">Must set fix.includes</fail>
+ <property name="javac.includes" value="${fix.includes}.java"/>
+ </target>
+ <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
+ <j2seproject1:nbjpdareload/>
+ </target>
+ <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
+ <!--
+ ===============
+ JAVADOC SECTION
+ ===============
+ -->
+ <target depends="init" name="-javadoc-build">
+ <mkdir dir="${dist.javadoc.dir}"/>
+ <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
+ <classpath>
+ <path path="${javac.classpath}"/>
+ </classpath>
+ <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+ <filename name="**/*.java"/>
+ </fileset>
+ </javadoc>
+ </target>
+ <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
+ <nbbrowse file="${dist.javadoc.dir}/index.html"/>
+ </target>
+ <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
+ <!--
+ =========================
+ JUNIT COMPILATION SECTION
+ =========================
+ -->
+ <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
+ <mkdir dir="${build.test.classes.dir}"/>
+ </target>
+ <target name="-pre-compile-test">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target if="do.depend.true" name="-compile-test-depend">
+ <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
+ </target>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
+ <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
+ <copy todir="${build.test.classes.dir}">
+ <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+ </copy>
+ </target>
+ <target name="-post-compile-test">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
+ <target name="-pre-compile-test-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
+ <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+ <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
+ <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
+ <copy todir="${build.test.classes.dir}">
+ <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+ </copy>
+ </target>
+ <target name="-post-compile-test-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
+ <!--
+ =======================
+ JUNIT EXECUTION SECTION
+ =======================
+ -->
+ <target depends="init" if="have.tests" name="-pre-test-run">
+ <mkdir dir="${build.test.results.dir}"/>
+ </target>
+ <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
+ <j2seproject3:junit testincludes="**/*Test.java"/>
+ </target>
+ <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
+ <fail if="tests.failed">Some tests failed; see details above.</fail>
+ </target>
+ <target depends="init" if="have.tests" name="test-report"/>
+ <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
+ <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
+ <target depends="init" if="have.tests" name="-pre-test-run-single">
+ <mkdir dir="${build.test.results.dir}"/>
+ </target>
+ <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
+ <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
+ <j2seproject3:junit excludes="" includes="${test.includes}"/>
+ </target>
+ <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
+ <fail if="tests.failed">Some tests failed; see details above.</fail>
+ </target>
+ <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
+ <!--
+ =======================
+ JUNIT DEBUGGING SECTION
+ =======================
+ -->
+ <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
+ <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
+ <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
+ <delete file="${test.report.file}"/>
+ <mkdir dir="${build.test.results.dir}"/>
+ <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
+ <customize>
+ <syspropertyset>
+ <propertyref prefix="test-sys-prop."/>
+ <mapper from="test-sys-prop.*" to="*" type="glob"/>
+ </syspropertyset>
+ <arg value="${test.class}"/>
+ <arg value="showoutput=true"/>
+ <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
+ <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
+ </customize>
+ </j2seproject3:debug>
+ </target>
+ <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
+ <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
+ </target>
+ <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
+ <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
+ <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
+ </target>
+ <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
+ <!--
+ =========================
+ APPLET EXECUTION SECTION
+ =========================
+ -->
+ <target depends="init,compile-single" name="run-applet">
+ <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
+ <j2seproject1:java classname="sun.applet.AppletViewer">
+ <customize>
+ <arg value="${applet.url}"/>
+ </customize>
+ </j2seproject1:java>
+ </target>
+ <!--
+ =========================
+ APPLET DEBUGGING SECTION
+ =========================
+ -->
+ <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
+ <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
+ <j2seproject3:debug classname="sun.applet.AppletViewer">
+ <customize>
+ <arg value="${applet.url}"/>
+ </customize>
+ </j2seproject3:debug>
+ </target>
+ <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
+ <!--
+ ===============
+ CLEANUP SECTION
+ ===============
+ -->
+ <target depends="init" name="deps-clean" unless="no.deps"/>
+ <target depends="init" name="-do-clean">
+ <delete dir="${build.dir}"/>
+ <delete dir="${dist.dir}"/>
+ </target>
+ <target name="-post-clean">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
+</project>
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/nbproject/genfiles.properties b/nlpsolver/ThirdParty/EvolutionarySolver/nbproject/genfiles.properties
new file mode 100755
index 000000000000..824bfa29c003
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=ea0a88ad
+build.xml.script.CRC32=22c5d290
+build.xml.stylesheet.CRC32=958a1d3e
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=ea0a88ad
+nbproject/build-impl.xml.script.CRC32=8e195e02
+nbproject/build-impl.xml.stylesheet.CRC32=65b8de21
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/nbproject/project.properties b/nlpsolver/ThirdParty/EvolutionarySolver/nbproject/project.properties
new file mode 100755
index 000000000000..3903d346a67f
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/nbproject/project.properties
@@ -0,0 +1,59 @@
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/EvolutionarySolver.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.source=1.5
+javac.target=1.5
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${libs.junit.classpath}:\
+ ${libs.junit_4.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+meta.inf.dir=${src.dir}/META-INF
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project
+# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
+# or test-sys-prop.name=value to set system properties for unit tests):
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/nbproject/project.xml b/nlpsolver/ThirdParty/EvolutionarySolver/nbproject/project.xml
new file mode 100755
index 000000000000..a97876ee41f9
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/nbproject/project.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.java.j2seproject</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
+ <name>EvolutionarySolver</name>
+ <minimum-ant-version>1.6.5</minimum-ant-version>
+ <source-roots>
+ <root id="src.dir"/>
+ </source-roots>
+ <test-roots>
+ <root id="test.src.dir"/>
+ </test-roots>
+ </data>
+ </configuration>
+</project>
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
new file mode 100755
index 000000000000..02043f5b89f2
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
@@ -0,0 +1,127 @@
+package net.adaptivebox.deps;
+
+/**
+ * Description: The description of agent with hybrid differential evolution and particle swarm.
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Jun 10, 2004
+ * Xiaofeng Xie Jul 01, 2008
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @version 1.0
+ * @Since MAOS1.0
+ *
+ * @References:
+ * [1] Zhang W J, Xie X F. DEPSO: hybrid particle swarm with differential
+ * evolution operator. IEEE International Conference on Systems, Man & Cybernetics,
+ * Washington D C, USA, 2003: 3816-3821
+ * [2] X F Xie, W J Zhang. SWAF: swarm algorithm framework for numerical
+ * optimization. Genetic and Evolutionary Computation Conference (GECCO),
+ * Seattle, WA, USA, 2004: 238-250
+ * -> an agent perspective
+ */
+
+import net.adaptivebox.deps.behavior.*;
+import net.adaptivebox.goodness.IGoodnessCompareEngine;
+import net.adaptivebox.knowledge.*;
+import net.adaptivebox.problem.*;
+import net.adaptivebox.space.*;
+
+public class DEPSAgent implements ILibEngine {
+
+ //Describes the problem to be solved
+ protected ProblemEncoder problemEncoder;
+ //Forms the goodness landscape
+ protected IGoodnessCompareEngine qualityComparator;
+
+ //store the point that generated in current learning cycle
+ protected SearchPoint trailPoint;
+
+ //temp variable
+ private AbsGTBehavior selectGTBehavior;
+
+ //The referred library
+ protected Library socialLib;
+ //the own memory: store the point that generated in old learning cycle
+ protected BasicPoint pold_t;
+ //the own memory: store the point that generated in last learning cycle
+ protected BasicPoint pcurrent_t;
+ //the own memory: store the personal best point
+ protected SearchPoint pbest_t;
+
+ //Generate-and-test Behaviors
+ protected DEGTBehavior deGTBehavior;
+ protected PSGTBehavior psGTBehavior;
+ public double switchP = 0.5;
+
+ public void setLibrary(Library lib) {
+ socialLib = lib;
+ deGTBehavior.setLibrary(socialLib);
+ psGTBehavior.setLibrary(socialLib);
+ }
+
+ public void setProblemEncoder(ProblemEncoder encoder) {
+ problemEncoder = encoder;
+ trailPoint = problemEncoder.getFreshSearchPoint();
+ pold_t = problemEncoder.getFreshSearchPoint();
+ pcurrent_t = problemEncoder.getFreshSearchPoint();
+ }
+
+ public void setSpecComparator(IGoodnessCompareEngine comparer) {
+ qualityComparator = comparer;
+ }
+
+ public void setPbest(SearchPoint pbest) {
+ pbest_t = pbest;
+ }
+
+ protected AbsGTBehavior getGTBehavior() {
+ if (Math.random()<switchP) {
+ return deGTBehavior;
+ } else {
+ return psGTBehavior;
+ }
+ }
+
+ public void setGTBehavior(AbsGTBehavior gtBehavior) {
+ if (gtBehavior instanceof DEGTBehavior) {
+ deGTBehavior = ((DEGTBehavior)gtBehavior);
+ deGTBehavior.setPbest(pbest_t);
+ return;
+ }
+ if (gtBehavior instanceof PSGTBehavior) {
+ psGTBehavior = ((PSGTBehavior)gtBehavior);
+ psGTBehavior.setMemPoints(pbest_t, pcurrent_t, pold_t);
+ return;
+ }
+ }
+
+ public void generatePoint() {
+ // generates a new point in the search space (S) based on
+ // its memory and the library
+ selectGTBehavior = this.getGTBehavior();
+ selectGTBehavior.generateBehavior(trailPoint, problemEncoder);
+ //evaluate into goodness information
+ problemEncoder.evaluate(trailPoint);
+ }
+
+ public void learn() {
+ selectGTBehavior.testBehavior(trailPoint, qualityComparator);
+ }
+
+ public SearchPoint getMGState() {
+ return trailPoint;
+ }
+}
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java
new file mode 100755
index 000000000000..159ce7c73328
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java
@@ -0,0 +1,36 @@
+/**
+ * Description: The description of generate-and-test behavior.
+ *
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie May 17, 2004
+ * Xiaofeng Xie Jul 01, 2008
+ *
+ * @version 1.0
+ * @Since MAOS1.0
+ *
+ * @References:
+ * [1] X F Xie, W J Zhang. SWAF: swarm algorithm framework for numerical
+ * optimization. Genetic and Evolutionary Computation Conference (GECCO),
+ * Seattle, WA, USA, 2004: 238-250
+ * -> a generate-and-test behavior
+ */
+package net.adaptivebox.deps.behavior;
+
+import net.adaptivebox.goodness.*;
+import net.adaptivebox.knowledge.*;
+import net.adaptivebox.problem.*;
+
+abstract public class AbsGTBehavior {
+ //The referred social library
+ protected Library socialLib;
+
+ public void setLibrary(Library lib) {
+ socialLib = lib;
+ }
+
+ abstract public void generateBehavior(SearchPoint trailPoint, ProblemEncoder problemEncoder);
+
+ abstract public void testBehavior(SearchPoint trailPoint, IGoodnessCompareEngine qualityComparator);
+}
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java
new file mode 100755
index 000000000000..cb0693616d4e
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java
@@ -0,0 +1,81 @@
+/**
+ * Description: The description of differential evolution Generate-and-Test Behavior.
+
+ #Supported parameters:
+ NAME VALUE_type Range DefaultV Description
+ FACTOR real (0, 1.2] 0.5 DEAgent: scale constant
+ CR real [0, 1] 0.9 DEAgent: crossover constant
+ //Other choices for FACTOR and CR: (0.5, 0.1)
+
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie May 11, 2004
+ * Xiaofeng Xie Jul 01, 2008
+ *
+ * @version 1.0
+ * @Since MAOS1.0
+ *
+ * @References:
+ * [1] Storn R, Price K. Differential evolution - a simple and efficient
+ * heuristic for global optimization over continuous spaces. Journal of
+ * Global Optimization, 1997, 11: 341�C359
+ * @ The original differential evolution idea
+ * [2] X F Xie, W J Zhang. SWAF: swarm algorithm framework for numerical
+ * optimization. Genetic and Evolutionary Computation Conference (GECCO),
+ * Seattle, WA, USA, 2004: 238-250
+ * -> a generate-and-test behavior
+ */
+
+package net.adaptivebox.deps.behavior;
+
+import net.adaptivebox.goodness.*;
+import net.adaptivebox.global.*;
+import net.adaptivebox.knowledge.*;
+import net.adaptivebox.problem.*;
+import net.adaptivebox.space.*;
+
+public class DEGTBehavior extends AbsGTBehavior implements ILibEngine {
+ public int DVNum = 2; //Number of differential vectors, normally be 1 or 2
+ public double FACTOR = 0.5; //scale constant: (0, 1.2], normally be 0.5
+ public double CR = 0.9; //crossover constant: [0, 1], normally be 0.1 or 0.9
+
+ //the own memory: store the point that generated in last learning cycle
+ protected SearchPoint pbest_t;
+
+ public void setPbest(SearchPoint pbest) {
+ pbest_t = pbest;
+ }
+
+ public void generateBehavior(SearchPoint trailPoint, ProblemEncoder problemEncoder) {
+ SearchPoint gbest_t = socialLib.getGbest();
+
+ BasicPoint[] referPoints = getReferPoints();
+ int DIMENSION = problemEncoder.getDesignSpace().getDimension();
+ int rj = RandomGenerator.intRangeRandom(0, DIMENSION-1);
+ for (int k=0; k<DIMENSION; k++) {
+ if (Math.random()<CR || k == DIMENSION-1) {
+ double Dabcd = 0;
+ for(int i=0; i<referPoints.length; i++) {
+ Dabcd += Math.pow(-1, i%2)*referPoints[i].getLocation()[rj];
+ }
+ trailPoint.getLocation()[rj] = gbest_t.getLocation()[rj]+FACTOR*Dabcd;
+ } else {
+ trailPoint.getLocation()[rj] = pbest_t.getLocation()[rj];
+ }
+ rj = (rj+1)%DIMENSION;
+ }
+ }
+
+ public void testBehavior(SearchPoint trailPoint, IGoodnessCompareEngine qualityComparator) {
+ Library.replace(qualityComparator, trailPoint, pbest_t);
+ }
+
+ protected SearchPoint[] getReferPoints() {
+ SearchPoint[] referPoints = new SearchPoint[DVNum*2];
+ for(int i=0; i<referPoints.length; i++) {
+ referPoints[i] = socialLib.getSelectedPoint(RandomGenerator.intRangeRandom(0, socialLib.getPopSize()-1));
+ }
+ return referPoints;
+ }
+}
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java
new file mode 100755
index 000000000000..b4ae0017eb69
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java
@@ -0,0 +1,117 @@
+/**
+ * Description: The description of particle swarm (PS) Generate-and-test Behavior.
+ *
+ #Supported parameters:
+ NAME VALUE_type Range DefaultV Description
+ c1 real [0, 2] 1.494 PSAgent: learning factor for pbest
+ c2 real [0, 2] 1.494 PSAgent: learning factor for gbest
+ w real [0, 1] 0.729 PSAgent: inertia weight
+ CL real [0, 0.1] 0 PSAgent: chaos factor
+ //Other choices for c1, c2, w, and CL: (2, 2, 0.4, 0.001)
+
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie May 11, 2004
+ * Xiaofeng Xie Jul 01, 2008
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @version 1.0
+ * @Since MAOS1.0
+ *
+ * @References:
+ * [1] Kennedy J, Eberhart R C. Particle swarm optimization. IEEE Int. Conf. on
+ * Neural Networks, Perth, Australia, 1995: 1942-1948
+ * @ For original particle swarm idea
+ * [2] Shi Y H, Eberhart R C. A Modified Particle Swarm Optimizer. IEEE Inter. Conf.
+ * on Evolutionary Computation, Anchorage, Alaska, 1998: 69-73
+ * @ For the inertia weight: adjust the trade-off between exploitation & exploration
+ * [3] Clerc M, Kennedy J. The particle swarm - explosion, stability, and
+ * convergence in a multidimensional complex space. IEEE Trans. on Evolutionary
+ * Computation. 2002, 6 (1): 58-73
+ * @ Constriction factor: ensures the convergence
+ * [4] Xie X F, Zhang W J, Yang Z L. A dissipative particle swarm optimization.
+ * Congress on Evolutionary Computation, Hawaii, USA, 2002: 1456-1461
+ * @ The CL parameter
+ * [5] Xie X F, Zhang W J, Bi D C. Optimizing semiconductor devices by self-
+ * organizing particle swarm. Congress on Evolutionary Computation, Oregon, USA,
+ * 2004: 2017-2022
+ * @ Further experimental analysis on the convergence of PSO
+ * [6] X F Xie, W J Zhang. SWAF: swarm algorithm framework for numerical
+ * optimization. Genetic and Evolutionary Computation Conference (GECCO),
+ * Seattle, WA, USA, 2004: 238-250
+ * -> a generate-and-test behavior
+ *
+ */
+
+package net.adaptivebox.deps.behavior;
+
+import net.adaptivebox.goodness.*;
+import net.adaptivebox.knowledge.*;
+import net.adaptivebox.problem.*;
+import net.adaptivebox.space.*;
+
+public class PSGTBehavior extends AbsGTBehavior {
+ // Two normally choices for (c1, c2, weight), i.e., (2, 2, 0.4), or (1.494, 1.494, 0.729)
+ // The first is used in dissipative PSO (cf. [4]) as CL>0, and the second is achieved by using
+ // constriction factors (cf. [3])
+ public double c1=2;
+ public double c2=2;
+ public double weight = 0.4; //inertia weight
+
+ public double CL=0; //See ref[4], normally be 0.001~0.005
+
+ //the own memory: store the point that generated in old learning cycle
+ protected BasicPoint pold_t;
+ //the own memory: store the point that generated in last learning cycle
+ protected BasicPoint pcurrent_t;
+ //the own memory: store the personal best point
+ protected SearchPoint pbest_t;
+
+ public void setMemPoints(SearchPoint pbest, BasicPoint pcurrent, BasicPoint pold) {
+ pcurrent_t = pcurrent;
+ pbest_t = pbest;
+ pold_t = pold;
+ }
+
+ public void generateBehavior(SearchPoint trailPoint, ProblemEncoder problemEncoder) {
+ SearchPoint gbest_t = socialLib.getGbest();
+ DesignSpace designSpace = problemEncoder.getDesignSpace();
+ int DIMENSION = designSpace.getDimension();
+ double deltaxb, deltaxbm;
+ for (int b=0;b<DIMENSION;b++) {
+ if (Math.random()<CL) {
+ designSpace.mutationAt(trailPoint.getLocation(), b);
+ } else {
+ deltaxb = weight*(pcurrent_t.getLocation()[b]-pold_t.getLocation()[b])
+ + c1*Math.random()*(pbest_t.getLocation()[b]-pcurrent_t.getLocation()[b])
+ + c2*Math.random()*(gbest_t.getLocation()[b]-pcurrent_t.getLocation()[b]);
+ //limitation for delta_x
+ deltaxbm = 0.5*designSpace.getMagnitudeIn(b);
+ if(deltaxb<-deltaxbm) {
+ deltaxb = -deltaxbm;
+ } else if (deltaxb>deltaxbm) {
+ deltaxb = deltaxbm;
+ }
+ trailPoint.getLocation()[b] = pcurrent_t.getLocation()[b]+deltaxb;
+ }
+ }
+ }
+
+ public void testBehavior(SearchPoint trailPoint, IGoodnessCompareEngine qualityComparator) {
+ Library.replace(qualityComparator, trailPoint, pbest_t);
+ pold_t.importLocation(pcurrent_t);
+ pcurrent_t.importLocation(trailPoint);
+ }
+
+}
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalElement.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalElement.java
new file mode 100755
index 000000000000..82e4073ee4e8
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalElement.java
@@ -0,0 +1,70 @@
+/**
+ * Description: provide the information for evaluating of a response (target)
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Mar 1, 2003
+ * Xiaofeng Xie May 11, 2004
+*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ */
+
+package net.adaptivebox.encode;
+
+import net.adaptivebox.global.*;
+
+public class EvalElement {
+
+ //The weight for each response (target)
+ public double weight = 1;
+ /**
+ * The expected range of the response value, forms the following objective:
+ *
+ * NO minValue maxValue : THE ELEMENT OF BasicBound
+ * 1 MINDOUBLE, MINDOUBLE: the minimize objective
+ * 2 MAXDOUBLE, MAXDOUBLE: the maximize objective
+ * 3 MINDOUBLE, v : the lessthan constraint (<v)
+ * 4 v , MAXDOUBLE: the largethan constraint (>v)
+ * 5 v1 , v2 : the region constraint, i.e. belongs to [v1, v2]
+ *
+ * OPTIM type: the No.1 and No.2
+ * CONS type: the last three
+ *
+ */
+ public BasicBound targetBound = new BasicBound();
+
+ public EvalElement() {};
+
+ public boolean isOptType() {
+ return ((targetBound.minValue==BasicBound.MINDOUBLE&&targetBound.maxValue==BasicBound.MINDOUBLE)||
+ (targetBound.minValue==BasicBound.MAXDOUBLE&&targetBound.maxValue==BasicBound.MAXDOUBLE));
+ }
+
+ public double evaluateCONS(double targetValue) {
+ if(targetValue<targetBound.minValue) {
+ return weight*(targetBound.minValue-targetValue);
+ }
+ if(targetValue>targetBound.maxValue) {
+ return weight*(targetValue-targetBound.maxValue);
+ }
+ return 0;
+ }
+
+ public double evaluateOPTIM(double targetValue) {
+ if(targetBound.maxValue==BasicBound.MINDOUBLE) { //min mode
+ return weight*targetValue;
+ } else { //max
+ return -weight*targetValue;
+ }
+ }
+}
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalStruct.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalStruct.java
new file mode 100755
index 000000000000..ad44df1dc2d2
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalStruct.java
@@ -0,0 +1,60 @@
+/**
+ * Description: provide the information for evaluating a set of targets values
+ * into encoded information (For formation the goodness landscape by comparing)
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Mar 1, 2003
+ * Xiaofeng Xie May 11, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @References:
+ * [1] Deb K. An efficient constraint handling method for genetic algorithms.
+ * Computer Methods in Applied Mechanics and Engineering, 2000, 186(2-4): 311-338
+ */
+
+package net.adaptivebox.encode;
+
+public class EvalStruct {
+ // The information for evaluating all the responses
+ public EvalElement[] evalElems = null;
+
+ public EvalStruct(int elemsNum) {
+ evalElems = new EvalElement[elemsNum];
+ }
+ public int getSize() {
+ return evalElems.length;
+ }
+
+ public void setElemAt(EvalElement dim, int index) {
+ evalElems[index] = dim;
+ }
+
+ //convert response values into encoded information double[2]
+ public void evaluate(double[] evalRes, double[] targetValues) {
+ evalRes[0] = evalRes[1] = 0;
+ for(int i=0; i<evalElems.length; i++) {
+ if (evalElems[i].isOptType()) {
+ //The objectives (OPTIM type)
+ //The multi-objective will be translated into single-objective
+ evalRes[1] += evalElems[i].evaluateOPTIM(targetValues[i]);
+ } else {
+ //The constraints (CONS type)
+ //If evalRes[0] equals to 0, then be a feasible point, i.e. satisfies
+ // all the constraints
+ evalRes[0] += evalElems[i].evaluateCONS(targetValues[i]);
+ }
+ }
+ }
+}
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/IEncodeEngine.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/IEncodeEngine.java
new file mode 100755
index 000000000000..9ca77d32ca8f
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/IEncodeEngine.java
@@ -0,0 +1,24 @@
+/**
+ * Description: provide the encoded information for objectives
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Feb 10, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ */
+
+package net.adaptivebox.encode;
+
+public interface IEncodeEngine{
+ abstract public double[] getEncodeInfo();
+}
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicArray.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicArray.java
new file mode 100755
index 000000000000..4071cf8c7540
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicArray.java
@@ -0,0 +1,31 @@
+/**
+ * Description: basic operations on Arrays
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Oct. 9, 2002
+ *
+ */
+
+package net.adaptivebox.global;
+
+public class BasicArray {
+ public static double getMinValue(double[] v) {
+ double mv = Double.MAX_VALUE;
+ for (int i=0; i<v.length; i++) {
+ if (v[i]<mv) {
+ mv=v[i];
+ }
+ }
+ return mv;
+ }
+ public static double getMaxValue(double[] v) {
+ double mv = -Double.MAX_VALUE;
+ for (int i=0; i<v.length; i++) {
+ if (v[i]>mv) {
+ mv=v[i];
+ }
+ }
+ return mv;
+ }
+
+} \ No newline at end of file
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicBound.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicBound.java
new file mode 100755
index 000000000000..e0953d12d655
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicBound.java
@@ -0,0 +1,94 @@
+/**
+ * Description: provide an bound, and the corresponding operations
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Oct. 9, 2002
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ */
+
+package net.adaptivebox.global;
+
+public class BasicBound {
+ public static final double MINDOUBLE= -1e308;
+ public static final double MAXDOUBLE= 1e308;
+
+ public double minValue = MINDOUBLE;
+ public double maxValue = MAXDOUBLE;
+ public BasicBound() {
+ }
+
+ public BasicBound(double min, double max) {
+ minValue = Math.min(min, max);
+ maxValue = Math.max(min, max);
+ }
+
+ public double getLength() {
+ return Math.abs(maxValue-minValue);
+ }
+
+ public boolean isSatisfyCondition(double child){
+ if(child > maxValue || child < minValue) {
+ return(false);
+ }
+ return(true);
+ }
+
+ public double boundAdjust(double value){
+ if(value > maxValue) {
+ value = maxValue;
+ } else if (value < minValue) {
+ value = minValue;
+ }
+ return value;
+ }
+
+ public double annulusAdjust (double value) {
+ if(value > maxValue) {
+ double extendsLen = (value-maxValue)%getLength();
+ value = minValue+extendsLen;
+ } else if (value < minValue) {
+ double extendsLen = (minValue-value)%getLength();
+ value = maxValue-extendsLen;
+ }
+ return value;
+ }
+
+ public static BasicBound getBound(double[] data) {
+ BasicBound bound = new BasicBound();
+ if(data!=null) {
+ double minV, maxV;
+ if(data.length>0) {
+ bound.minValue = data[0];
+ bound.maxValue = data[0];
+ for(int i=1; i<data.length; i++) {
+ bound.minValue = Math.min(bound.minValue, data[i]);
+ bound.maxValue = Math.max(bound.maxValue, data[i]);
+ }
+
+ }
+ }
+ return bound;
+ }
+
+ public double randomAdjust (double value){
+ if(value > maxValue || value < minValue) {
+ value = getRandomValue();
+ }
+ return value;
+ }
+
+ public double getRandomValue(){
+ return RandomGenerator.doubleRangeRandom(minValue, maxValue);
+ }
+} \ No newline at end of file
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicTag.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicTag.java
new file mode 100755
index 000000000000..29ee77fd47e0
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicTag.java
@@ -0,0 +1,40 @@
+/**
+ * Description: defines some static constant values.
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Sep 22, 2000 xiaofengxie@tsinghua.org.cn
+ *
+ * @version 1.0
+ * @Since MAOS1.0
+ */
+
+package net.adaptivebox.global;
+
+
+public class BasicTag {
+ public static final String COMMAND_TAG = "%";
+ public static final String TAB_TAG = "\t";
+ public static final String LEFT_SMALL_BRACKET_TAG = "(";
+ public static final String RIGHT_SMALL_BRACKET_TAG = ")";
+ public static final String LEFT_LARGE_BRACKET_TAG = "{";
+ public static final String RIGHT_LARGE_BRACKET_TAG = "}";
+ public static final String LEFT_BRACKET_TAG = "[";
+ public static final String RIGHT_BRACKET_TAG = "]";
+ public static final String EQUAL_TAG = "=";
+ public static final String SPACE_TAG = " ";
+ public static final String SEMICOLON_TAG = ";";
+ public static final String COLON_TAG = ":";
+ public static final String COMMA_TAG = ",";
+ public static final String DOT_TAG = ".";
+ public static final String NULL_SEPERATE_TAG = " \t";
+ public static final String SEPERATE_TAG = "|";
+ public static final String UNDERLINE_TAG = "_";
+ public static final String INC_TAG = "+";
+ public static final String DEC_TAG = "-";
+ public static final String ZERO_TAG = "0";
+ public static final String EXP_TAG = "E";
+ public static final String S_EXP_TAG = "e";
+ public static final String FILE_SEP_TAG = System.getProperty("file.separator");
+ public static final String RETURN_TAG = System.getProperty("line.separator");
+}
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/CompareValue.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/CompareValue.java
new file mode 100755
index 000000000000..1cd783f54404
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/CompareValue.java
@@ -0,0 +1,20 @@
+/**
+ * Description: Global value for comparison.
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Jun 15, 2002
+ * Xiaofeng Xie Feb 18, 2004
+ *
+ * @version 1.0
+ * @Since MAOS1.0
+ */
+
+
+package net.adaptivebox.global;
+
+public class CompareValue {
+ public static final int LARGER_THAN = 2;
+ public static final int EQUAL_TO = 1;
+ public static final int LESS_THAN = 0;
+ public static final int INVALID = -1;
+}
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalCompare.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalCompare.java
new file mode 100755
index 000000000000..57fef7beb0df
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalCompare.java
@@ -0,0 +1,46 @@
+/**
+ * Description: Global package for comparison.
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Jun 15, 2002 xiaofengxie@tsinghua.org.cn
+ *
+ *
+ * @version 1.0
+ * @Since MAOS1.0
+ */
+
+
+package net.adaptivebox.global;
+
+import java.util.*;
+
+public class GlobalCompare {
+
+/* compare the data1 and data2, if data1=data2, return 0
+ * if data1 < data2, return LESS_THAN, else if data1 > data2, LARGER_THAN
+ **/
+ static public int compare(double data1, double data2) {
+ if (data1 < data2)
+ return CompareValue.LESS_THAN;
+ else if (data1 > data2)
+ return CompareValue.LARGER_THAN;
+ else
+ return CompareValue.EQUAL_TO;
+ }
+
+/* check the magnitude of two array, the frontial is more important
+ **/
+ public static int compareArray(double[] fit1, double[] fit2) {
+ if (fit1.length!=fit2.length) {
+ return CompareValue.INVALID; //error
+ }
+ for (int i=0; i<fit1.length; i++) {
+ if (fit1[i]>fit2[i]) {
+ return CompareValue.LARGER_THAN; //Large than
+ } else if (fit1[i]<fit2[i]){
+ return CompareValue.LESS_THAN; //Less than
+ }
+ }
+ return CompareValue.EQUAL_TO; //same
+ }
+}
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalFile.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalFile.java
new file mode 100755
index 000000000000..3dc20c6266d9
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalFile.java
@@ -0,0 +1,277 @@
+/**
+ * Description: Global package for file operations.
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Jun 15, 2002
+ *
+ * @version 1.0
+ * @Since MAOS1.0
+ */
+
+
+package net.adaptivebox.global;
+
+import java.io.*;
+import java.util.*;
+
+public class GlobalFile {
+
+// used by the createTempDir to give an index of temp number.
+ private static int counter = -1;
+
+/**
+ * Create a temp directory in the given directory.
+ * @param prefix the prefix for the directory.
+ * @param directory the directory that the temp dirctory placed.
+ * @return If a temp directory is created, return a File Object, else
+ * return null.
+ */
+ public static File createTempDir(String prefix, String directory) throws IOException {
+ File f = null;
+ String tempDir;
+ boolean isCreated = false;
+ do {
+ if (counter == -1) {
+ counter = new Random().nextInt() & 0xffff;
+ }
+ counter++;
+ if (prefix == null) throw new NullPointerException();
+ if (prefix.length() < 3)
+ throw new IllegalArgumentException("Prefix string too short");
+ if (directory == null) {
+ tempDir = prefix+counter;
+ } else {
+ tempDir = getFileLocation(directory,prefix+counter);
+ }
+ f = new File(tempDir);
+ isCreated = f.mkdir();
+ } while (!isCreated);
+ return f;
+ }
+
+/**
+ * Add the given text string to the end of a given file.
+ * @param inStr The string to be added.
+ * @param fileStr the name of the file to be added.
+ */
+ public static void addStringToFile(String inStr, String fileStr) throws Exception {
+
+ RandomAccessFile raFile = new RandomAccessFile(fileStr,"rw");
+ raFile.seek(raFile.length());
+ raFile.writeBytes(inStr);
+ raFile.close();
+
+
+// String oldFileStr = getStringFromFile(fileStr);
+// String newFileStr = inStr;
+// if (oldFileStr != null) {
+// newFileStr = oldFileStr+inStr;
+// }
+// saveStringToFile(newFileStr,fileStr);
+
+ }
+
+ public static Object loadObjectFromFile(String fileName) throws Exception {
+ FileInputStream fis = new FileInputStream(fileName);
+ ObjectInputStream ois = new ObjectInputStream(fis);
+ Object obj = ois.readObject();
+ ois.close();
+ return obj;
+ }
+
+ public static void saveObjectToFile(String fileName, Object obj) throws Exception {
+ FileOutputStream ostream = new FileOutputStream(fileName);
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
+ p.writeObject(obj);
+ p.flush();
+ ostream.close();
+ }
+
+/**
+ * Save the given text string to a given file.
+ * @param inStr The string to be saved.
+ * @param fileStr the name of the file to be saved.
+ */
+ public static void saveStringToFile(String inStr, String fileStr) throws Exception{
+ new File(new File(fileStr).getParent()).mkdirs();
+ FileOutputStream pspOutputStream = new FileOutputStream(new File(fileStr));
+ pspOutputStream.write(inStr.getBytes());
+ pspOutputStream.close();
+ }
+
+/**
+ * Load text string from a given file.
+ * @param fileStr the name of the file to be loaded.
+ * @return A text string that is the content of the file. if the given file is
+ * not exist, then return null.
+ */
+ public static String getStringFromFile(String fileStr) throws Exception {
+ String getStr = null;
+ FileInputStream pspInputStream = new FileInputStream(fileStr);
+ byte[] pspFileBuffer = new byte[pspInputStream.available()];
+ pspInputStream.read(pspFileBuffer);
+ pspInputStream.close();
+ getStr = new String(pspFileBuffer);
+ return(getStr);
+ }
+
+/**
+ * Load curve data from a specified file.
+ * @param fileStr the name of the file to be loaded.
+ * @return A Vector that include the curve data.
+ */
+ public static Vector getCurveDataFromFile(String fileName) {
+ File file = new File(fileName);
+ if(!file.exists()){
+ //showMessage();
+ return null;
+ }
+ //open data file
+ FileInputStream inStream = null;
+ BufferedReader inReader = null;
+ try{
+ inStream = new FileInputStream(file);
+ inReader = new BufferedReader(new InputStreamReader(inStream));
+ }catch(Exception e){
+ //showMessage();
+ return null;//Data file open error.
+ }
+ Vector xaxes = new Vector(1,1);
+ Vector yaxes = new Vector(1,1);
+ try{
+ StringTokenizer st;
+ String s;
+ boolean start = false;
+ while(inReader.ready()!=false){
+ st = new StringTokenizer(inReader.readLine());
+ over:{
+ while(!st.hasMoreTokens()){//Justify blank lines.
+ if(inReader.ready()!=false){
+ st = new StringTokenizer(inReader.readLine());
+ }else
+ break over;
+ }
+ s = st.nextToken();
+ if((!start)&&(!s.startsWith("@")))
+ break over;
+ if(!start){
+ start = true;
+ break over;
+ }
+ if(s.startsWith("#")||s.startsWith("$")||s.startsWith("/")) break over;//Justify comment line.
+ Double xaxis = null;
+ Double yaxis = null;
+ try{
+ xaxis = Double.valueOf(s);
+ xaxes.addElement(xaxis);
+ }catch(Exception e){
+ //showMessage();
+ inReader.close();
+ inStream.close();
+ return null;//Data file data format error.
+ }
+ s = st.nextToken();
+ try{
+ yaxis = Double.valueOf(s);
+ yaxes.addElement(yaxis);
+ }catch(Exception e){
+ //showMessage();
+ inReader.close();
+ inStream.close();
+ return null;//Data file data format error.
+ }
+ }
+ }
+ }catch(Exception e){
+ //showMessage();
+ return null;//Uncertain data file error.
+ }
+ Vector curveData = new Vector();
+ curveData.addElement(xaxes);
+ curveData.addElement(yaxes);
+ return(curveData);
+ }
+
+/**
+ * Get a full path of a given file name and a directory name.
+ * @param fileName the name of the file.
+ * @param dir the name of directory.
+ * @return The full path.
+ */
+ public static String getFileLocation(String dir, String fileName) {
+ String realDir = dir;
+ while (realDir.length()>0 && (realDir.endsWith("/")||realDir.endsWith("\\"))) {
+ realDir = dir.substring(0, dir.length()-1);
+ }
+ return realDir+BasicTag.FILE_SEP_TAG+fileName;
+ }
+
+ public static String getFileName(String nameBody, String suffix) {
+ if (suffix==null || suffix.trim().length()==0) {
+ return nameBody;
+ }
+ String fileName = nameBody;
+ if(nameBody.endsWith(".")) {
+ return fileName+suffix;
+ } else {
+ return nameBody+"."+suffix;
+ }
+ }
+
+ public static String getFileLocation(String dir, String fileNameBody, String fileNameSuffix) {
+ String filename = getFileName(fileNameBody, fileNameSuffix);
+ return getFileLocation(dir, filename);
+ }
+
+ public static void clear(String fileStr) throws Exception {
+ File file = new File(fileStr);
+ if(file.isFile()) {
+ file.delete();
+ return;
+ }
+ String[] fileNames = file.list();
+ if (fileNames==null) {
+ return;
+ }
+ for (int i=0; i<fileNames.length; i++) {
+ String newFileName = GlobalFile.getFileLocation(fileStr,fileNames[i]);
+ clear(newFileName);
+ }
+ file.delete();
+ }
+
+ public static String getFilePrefix(String fileStr) {
+ int index = fileStr.lastIndexOf(BasicTag.DOT_TAG);
+ if(index==-1) index = fileStr.length();
+ return fileStr.substring(0, index);
+ }
+
+ public static String getFileSuffix(String fileStr) {
+ String[] subNames = GlobalString.tokenize(fileStr, BasicTag.DOT_TAG);
+ int subNameLen = subNames.length;
+ if(subNameLen==1) return "";
+ else return subNames[subNameLen-1];
+ }
+
+ public static String createTempImageFile(String origFile) throws Exception {
+ return createTempImageFile(origFile, "img", ".inf");
+ }
+
+ public static String createTempImageFile(String origFile, String prefix, String suffix) throws Exception {
+ File outputFile = createTempFile(prefix, suffix);
+ outputFile.deleteOnExit();
+ copyFile(outputFile.getAbsolutePath(), origFile);
+ return outputFile.getAbsolutePath();
+ }
+
+ public static void copyFile(String imgFile, String origFile) throws Exception {
+ String fileContent = GlobalFile.getStringFromFile(origFile);
+ GlobalFile.saveStringToFile(fileContent, imgFile);
+ }
+
+ public static File createTempFile(String prefix, String suffix) throws Exception {
+ String realSuffix = suffix;
+ if (!realSuffix.startsWith(".")) realSuffix = "."+suffix;
+ return File.createTempFile(prefix, realSuffix);
+ }
+}
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalString.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalString.java
new file mode 100755
index 000000000000..7ca0e2973c66
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalString.java
@@ -0,0 +1,149 @@
+/**
+ * Description: operations for the a text string.
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Feb 22, 2001
+ * Xiaofeng Xie May 12, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @version 1.0
+ * @Since MAOS1.0
+ */
+
+package net.adaptivebox.global;
+
+import java.io.*;
+import java.util.*;
+
+public class GlobalString {
+ public static final String NEGLECT_TAG = "#$@";
+ public static final String EQUAL_TAG = "=";
+
+/**
+ * Tokenize a String with given key.
+ * @param input the String to be tokenized.
+ * @param tokenKey the delimiters.
+ * @return a String array that include the elements of input string that
+ * divided by the tokenKey.
+ */
+ public static String[] tokenize(String input , String tokenKey) {
+ Vector v = new Vector();
+ StringTokenizer t = new StringTokenizer(input, tokenKey);
+ String cmd[];
+ while (t.hasMoreTokens())
+ v.addElement(t.nextToken());
+ cmd = new String[v.size()];
+ for (int i = 0; i < cmd.length; i++)
+ cmd[i] = (String) v.elementAt(i);
+ return cmd;
+ }
+
+ public static String[] getMeaningfulLines(String srcStr) throws Exception {
+ return getMeaningfulLines(srcStr, NEGLECT_TAG);
+ }
+
+ public static String getMeaningfulLine(BufferedReader outReader) throws Exception {
+ return getMeaningfulLine(outReader, NEGLECT_TAG);
+ }
+
+ public static int getCharLoc(char data, String str) {
+ for(int i=0; i<str.length(); i++) {
+ if(str.charAt(i)==data) return i;
+ }
+ return -1;
+ }
+ public static String trim(String origStr, String discardStr) {
+ String str = origStr;
+ do {
+ if(str.length()==0) return str;
+ if(getCharLoc(str.charAt(0), discardStr)!=-1) str = str.substring(1);
+ else if(getCharLoc(str.charAt(str.length()-1), discardStr)!=-1) str = str.substring(0, str.length()-1);
+ else {return str;}
+ } while(true);
+ }
+
+ public static boolean getFirstCharExist(String str, String chars) throws Exception {
+ int neglectFirstCharLength = chars.length();
+ for(int i=0; i<neglectFirstCharLength; i++) {
+ if(str.startsWith(chars.substring(i, i+1))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static String getMeaningfulLine(BufferedReader outReader, String neglectFirstChars) throws Exception {
+ String str;
+ boolean isNeglect = true;
+ int i = 0;
+ do {
+ str = outReader.readLine();
+ if (str==null) {
+ return null;
+ }
+ str = trim(str, " \t");
+ if(str.length()>0) {
+ isNeglect = getFirstCharExist(str, neglectFirstChars);
+ }
+ } while (isNeglect);
+ return str;
+ }
+
+ public static String[] getMeaningfulLines(String srcStr, String neglectFirstChars) throws Exception {
+ StringReader outStringReader = new StringReader(srcStr);
+ BufferedReader outReader = new BufferedReader(outStringReader);
+ Vector origData = new Vector();
+ String str = null;
+ while(true) {
+ str = getMeaningfulLine(outReader, neglectFirstChars);
+ if (str==null) {
+ break;
+ }
+ origData.add(str);
+ }
+ return convert1DVectorToStringArray(origData);
+ }
+
+ /**
+ * convert vector to 1D String array
+ */
+ public static String[] convert1DVectorToStringArray(Vector toToConvert) {
+ if (toToConvert==null) return null;
+ String[] objs = new String[toToConvert.size()];
+ for (int i=0; i<toToConvert.size(); i++) {
+ objs[i] =getObjString(toToConvert.elementAt(i));
+ }
+ return(objs);
+ }
+
+ public static String getObjString(Object nObj) {
+ if(nObj instanceof String) return (String)nObj;
+ return nObj.toString();
+ }
+
+ static public int toInteger(Object oVal) throws Exception {
+ if(oVal==null) throw new Exception("Null string");
+ return new Integer(oVal.toString()).intValue();
+ }
+
+ static public double toDouble(Object oVal) throws Exception {
+ if(oVal==null) throw new Exception("Null string");
+ return new Double(oVal.toString()).doubleValue();
+ }
+
+ public static Object toObject(String key) throws Exception{
+ Class cls = Class.forName(key);
+ return cls.newInstance();
+ }
+} \ No newline at end of file
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/IUpdateCycleEngine.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/IUpdateCycleEngine.java
new file mode 100755
index 000000000000..18e9832e31bc
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/IUpdateCycleEngine.java
@@ -0,0 +1,24 @@
+/**
+ * Description: provide the inteface for updating according to the cycle number
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Feb 18, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ */
+
+package net.adaptivebox.global;
+
+public interface IUpdateCycleEngine {
+ public void updateCycle(int t);
+} \ No newline at end of file
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/OutputMethods.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/OutputMethods.java
new file mode 100755
index 000000000000..b2177b8dfdb8
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/OutputMethods.java
@@ -0,0 +1,50 @@
+/**
+ * Description: Output methods for Array
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Feb 22, 2001
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @version 1.0
+ * @Since MAOS1.0
+ */
+
+package net.adaptivebox.global;
+
+
+public class OutputMethods {
+
+ public OutputMethods() {
+ }
+
+ public static String outputVectorAsStr(double[] vector){
+ if(vector==null) return "NULL";
+ String totalStr = "";
+ for(int i=0;i<vector.length;i++){
+ totalStr += vector[i];
+ if(i!=vector.length-1) {
+ totalStr += "\t";
+ }
+ }
+ totalStr+="\r\n";
+ return totalStr;
+ }
+
+ public static void outputVector(double[] vector){
+ for(int i=0;i<vector.length;i++){
+ System.out.print(vector[i]+" \t");
+ }
+ System.out.println("");
+ }
+} \ No newline at end of file
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/RandomGenerator.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/RandomGenerator.java
new file mode 100755
index 000000000000..b9f17ce4e045
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/RandomGenerator.java
@@ -0,0 +1,162 @@
+/**
+ * Description: For generating random numbers.
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Feb 22, 2001
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @version 1.0
+ * @Since MAOS1.0
+ */
+
+package net.adaptivebox.global;
+
+import java.util.*;
+
+public class RandomGenerator {
+
+/**This function returns a random integer number between the lowLimit and upLimit.
+ * @param lowLimit lower limits
+ * upLimit The upper limits (between which the random number is to be generated)
+ * @return int return value
+ * Example: for find [0,1,2]
+*/
+public static int intRangeRandom(int lowLimit,int upLimit){
+// int num = (int)Math.rint(doubleRangeRandom(lowLimit,upLimit));
+ int num = (int)Math.floor(doubleRangeRandom(lowLimit,upLimit+1)-1E-10);
+ return(num);
+}
+
+/**This function returns a random float number between the lowLimit and upLimit.
+ * @param lowLimit lower limits
+ * upLimit The upper limits (between which the random number is to be generated)
+ * @return double return value
+*/
+public static double doubleRangeRandom(double lowLimit,double upLimit){
+ double num = lowLimit + Math.random()*(upLimit-lowLimit);
+ return(num);
+}
+
+/**This function returns true or false with a random probability.
+ * @return int return value
+ */
+ public static boolean booleanRandom(){
+ boolean value = true;
+ double temp=Math.random();
+ if (temp<0.5) value=false;
+ return value;
+ }
+
+ public static int[] randomSelection(boolean[] types, int times) {
+ int validNum = 0;
+ for(int i=0; i<types.length; i++) {
+ if(!types[i]) {
+ validNum++;
+ }
+ }
+ int[] totalIndices = new int[validNum];
+ validNum = 0;
+ for(int i=0; i<types.length; i++) {
+ if(!types[i]) {
+ totalIndices[validNum] = i;
+ validNum++;
+ if(validNum==totalIndices.length) break;
+ }
+ }
+ return randomSelection(totalIndices, times);
+ }
+
+// public static int[] randomSelection(boolean[] types, int times) {
+// int realTimes = times;
+// if(realTimes>types.length) realTimes = types.length;
+// boolean[] internalTypes = (boolean[])types.clone();
+// int upper = types.length-1;
+// int[] indices = new int[realTimes];
+// if(realTimes==types.length) {
+// for(int i=0; i<indices.length; i++) {
+// indices[i] = i;
+// }
+// return indices;
+// }
+// int i = 0;
+// while(i<realTimes) {
+// indices[i] = intRangeRandom(0, upper);
+// if(!internalTypes[indices[i]]) {
+// internalTypes[indices[i]] = true;
+// i++;
+// }
+// }
+// return indices;
+// }
+
+ public static int[] randomSelection(int low, int up, int times){
+ int[] totalIndices = new int[up-low];
+ for (int i=low; i<up; i++) {
+ totalIndices[i] = i;
+ }
+ return randomSelection(totalIndices, times);
+ }
+
+ public static int getRealV(double randTypeV) {
+ if(randTypeV<=0) return 0;
+ int realV = (int)Math.ceil(randTypeV);
+ if(Math.random()<(randTypeV-realV)) realV++;
+ return realV;
+ }
+
+ public static int[] randomSelection(int[] totalIndices, int times) {
+ if (times>=totalIndices.length) {
+ return totalIndices;
+ }
+ int[] indices = randomSelection(totalIndices.length, times);
+ for(int i=0; i<indices.length; i++) {
+ indices[i] = totalIndices[indices[i]];
+ }
+ return indices;
+ }
+
+ public static int[] randomSelection(int maxNum, int times) {
+ if(times<=0) return new int[0];
+ int realTimes = Math.min(maxNum, times);
+ boolean[] flags = new boolean[maxNum];
+// Arrays.fill(flags, false);
+ boolean isBelowHalf = times<maxNum*0.5;
+ int virtualTimes = realTimes;
+ if(!isBelowHalf) {
+ virtualTimes = maxNum-realTimes;
+ }
+ int i = 0;
+ int upper = maxNum-1;
+ int[] indices = new int[realTimes];
+
+ while(i<virtualTimes) {
+ indices[i] = intRangeRandom(0, upper);
+ if(!flags[indices[i]]) {
+ flags[indices[i]] = true;
+ i++;
+ }
+ }
+ if(!isBelowHalf) {
+ int j=0;
+ for(i=0; i<maxNum; i++) {
+ if(flags[i]==isBelowHalf) {
+ indices[j] = i;
+ j++;
+ if(j==realTimes) break;
+ }
+ }
+ }
+ return indices;
+ }
+} \ No newline at end of file
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/ACRComparator.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/ACRComparator.java
new file mode 100755
index 000000000000..1efd3c7ac8af
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/ACRComparator.java
@@ -0,0 +1,90 @@
+/**
+ * Description: For comparison of goodness in landscape with loosed constraints
+ * which varied adaptively according to the social information.
+ *
+ * @Applied domain: efficiently for ridge class feasible space (SF), such as
+ * the problem with eqaulity constraints
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Jun 24, 2003 Created
+ * Xiaofeng Xie May 11, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @version 1.0
+ * @Since MAOS1.2
+ *
+ * [1] Xie X F, Zhang W J, Bi D C. Handling equality constraints by adaptive
+ * relaxing rule for swarm algorithms. Congress on Evolutionary Computation,
+ * Oregon, USA, 2004
+ */
+
+package net.adaptivebox.goodness;
+
+import net.adaptivebox.knowledge.*;
+import net.adaptivebox.global.*;
+
+
+public class ACRComparator implements IGoodnessCompareEngine, IUpdateCycleEngine {
+ private Library socialPool;
+ private double epsilon_t = 0;
+
+ private double RU = 0.75;
+ private double RL = 0.25;
+ private double BETAF = 0.618;
+ private double BETAL = 0.618;
+ private double BETAU = 1.382;
+
+ private double T = -1;
+
+ private double TthR = 0.5;
+
+ public ACRComparator(Library lib, int T) {
+ socialPool = lib;
+ this.T = T;
+ //set the (epsilon_t|t=0) as the maximum CONS value among the SearchPoints in the library
+ epsilon_t = lib.getExtremalVcon(true);
+ }
+
+ static public int compare(double data1, double data2) {
+ if (data1 < data2)
+ return LESS_THAN;
+ else if (data1 > data2)
+ return LARGER_THAN;
+ else
+ return EQUAL_TO;
+ }
+
+ public int compare(double[] fit1, double[] fit2) {
+ if(Math.max(fit1[0], fit2[0])<=Math.max(0, epsilon_t)) { //epsilon>0
+ return compare(fit1[1], fit2[1]);
+ } else {
+ return compare(fit1[0], fit2[0]);
+ }
+ }
+
+ public void updateCycle(int t) {
+ //calculates the ratio
+ double rn = (double)socialPool.getVconThanNum(epsilon_t)/(double)socialPool.getPopSize();
+ if(t>TthR*T &&T!=-1) { //Forcing sub-rule
+ epsilon_t *= BETAF;
+ } else { //Ratio-keeping sub-rules
+ if(rn>RU) {
+ epsilon_t *= BETAL; //Shrink
+ }
+ if(rn<RL) {
+ epsilon_t *= BETAU; //Relax
+ }
+ }
+ }
+}
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/BCHComparator.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/BCHComparator.java
new file mode 100755
index 000000000000..695fb6fe8894
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/BCHComparator.java
@@ -0,0 +1,47 @@
+/**
+ * Description: For formation the basic goodness landscape.
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Jun 24, 2003 Created
+ * Xiaofeng Xie May 11, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @version 1.0
+ * @Since MAOS1.2
+ *
+ * [1] Deb K. An efficient constraint handling method for genetic algorithms.
+ * Computer Methods in Applied Mechanics and Engineering, 2000, 186(2-4): 311-338
+ */
+
+package net.adaptivebox.goodness;
+
+public class BCHComparator implements IGoodnessCompareEngine {
+
+/* check the magnitude of two array, the frontial is more important
+ **/
+ public static int compareArray(double[] fit1, double[] fit2) {
+ for (int i=0; i<fit1.length; i++) {
+ if (fit1[i]>fit2[i]) {
+ return LARGER_THAN; //Large than
+ } else if (fit1[i]<fit2[i]){
+ return LESS_THAN; //Less than
+ }
+ }
+ return IGoodnessCompareEngine.EQUAL_TO; //same
+ }
+
+ public int compare(double[] fit1, double[] fit2) {
+ return compareArray(fit1, fit2);
+ }
+}
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/IGoodnessCompareEngine.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/IGoodnessCompareEngine.java
new file mode 100755
index 000000000000..1ff1dfb01923
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/IGoodnessCompareEngine.java
@@ -0,0 +1,38 @@
+/**
+ * Description: For comparison of goodness.
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Feb 19, 2004
+ * Xiaofeng Xie May 11, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @version 1.0
+ * @Since MAOS1.2
+ */
+
+package net.adaptivebox.goodness;
+
+public abstract interface IGoodnessCompareEngine {
+ public static final int LARGER_THAN = 2;
+ public static final int EQUAL_TO = 1;
+ public static final int LESS_THAN = 0;
+
+ /**
+ * check the magnitude of two IEncodeEngine
+ * LARGER_THAN: goodness1 is worse than goodness2
+ * LESS_THAN: goodness1 is better than goodness2
+ * EQUAL_TO : goodness1 is eqaul to goodness2
+ **/
+ public abstract int compare(double[] goodness1, double[] goodness2);
+}
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/PenaltyComparator.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/PenaltyComparator.java
new file mode 100755
index 000000000000..f0f8da3a2ff6
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/PenaltyComparator.java
@@ -0,0 +1,41 @@
+/**
+ * Description: For comparison of goodness in landscape with penalty method.
+ *
+ * @Applied domain: efficiently for ridge class feasible space (SF), such as
+ * the problem with eqaulity constraints
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie May 29, 2004
+ *
+ * @version 1.0
+ *
+ * [1] Runarsson T P, Yao X. Stochastic ranking for constrained evolutionary
+ * optimization. IEEE Trans. on Evolutionary Computation. 2000, 4 (3): 284-294
+ *
+ */
+
+package net.adaptivebox.goodness;
+
+import net.adaptivebox.global.*;
+
+public class PenaltyComparator implements IGoodnessCompareEngine {
+ public double Rg = 0;
+
+ public PenaltyComparator() {}
+
+ public PenaltyComparator(double rg) {
+ this.Rg = rg;
+ }
+
+ public double calcPenaltyValue(double fit1, double fit2) {
+ return fit1+Rg*fit2;
+ }
+ /**
+ * check the magnitude of two array, the frontial is more important
+ * Stoch ranking: array size = 2
+ **/
+ public int compare(double[] fit1, double[] fit2) {
+ return GlobalCompare.compare(calcPenaltyValue(fit1[1], fit1[0]), calcPenaltyValue(fit2[1], fit2[0]));
+ }
+
+}
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/SRComparator.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/SRComparator.java
new file mode 100755
index 000000000000..7a8e59d74f59
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/SRComparator.java
@@ -0,0 +1,41 @@
+/**
+ * Description: For comparison of goodness in landscape with stoch. ranking.
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie May 29, 2004
+ *
+ * [1] Runarsson T P, Yao X. Stochastic ranking for constrained evolutionary
+ * optimization. IEEE Trans. on Evolutionary Computation. 2000, 4 (3): 284-294
+ *
+ */
+
+package net.adaptivebox.goodness;
+
+import net.adaptivebox.global.*;
+
+public class SRComparator implements IGoodnessCompareEngine, IUpdateCycleEngine {
+ public double Pf = 0.5;
+
+ public SRComparator() {}
+
+ public SRComparator(double pf) {
+ this.Pf = pf;
+ }
+
+ public void updateCycle(int t) {
+ Pf *=0.995;
+ }
+
+ /**
+ * check the magnitude of two array, the frontial is more important
+ * Stoch ranking: array size = 2
+ **/
+ public int compare(double[] fit1, double[] fit2) {
+ if((fit1[0]==fit2[0])||Pf>Math.random()) {
+ return GlobalCompare.compare(fit1[1], fit2[1]);
+ } else {
+ return GlobalCompare.compare(fit1[0], fit2[0]);
+ }
+ }
+
+}
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/ILibEngine.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/ILibEngine.java
new file mode 100755
index 000000000000..741cba313495
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/ILibEngine.java
@@ -0,0 +1,30 @@
+
+/**
+ * Description: set the library.
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie May 14, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @version 1.1
+ * @Since MAOS1.0
+ */
+package net.adaptivebox.knowledge;
+
+public interface ILibEngine {
+ public void setLibrary(Library lib);
+}
+
+
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/Library.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/Library.java
new file mode 100755
index 000000000000..eb2045765594
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/Library.java
@@ -0,0 +1,106 @@
+
+/**
+ * Description: Contains a set of points.
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Mar 7, 2003
+ * Xiaofeng Xie May 3, 2003
+ * Xiaofeng Xie May 11, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @version 1.1
+ * @Since MAOS1.0
+ */
+package net.adaptivebox.knowledge;
+
+import net.adaptivebox.global.*;
+import net.adaptivebox.goodness.*;
+import net.adaptivebox.problem.*;
+
+public class Library {
+ private SearchPoint[] libPoints = new SearchPoint[0];
+ protected int gIndex = -1;
+
+ public Library(SearchPoint[] points){
+ this.libPoints = points;
+ }
+
+ public Library(int number, ProblemEncoder problemEncoder){
+ libPoints = new SearchPoint[number];
+ for (int i=0; i<number; i++) {
+ libPoints[i] = problemEncoder.getEncodedSearchPoint();
+ }
+ }
+
+ public SearchPoint getGbest() {
+ return getSelectedPoint(gIndex);
+ }
+
+ public void refreshGbest(IGoodnessCompareEngine qualityComparator) {
+ gIndex = tournamentSelection(qualityComparator, getPopSize()-1, true);
+ }
+
+ public int getPopSize() {
+ return libPoints.length;
+ }
+
+ public SearchPoint getSelectedPoint(int index) {
+ return libPoints[index];
+ }
+
+ public static boolean replace(IGoodnessCompareEngine comparator, SearchPoint outPoint, SearchPoint tobeReplacedPoint) {
+ boolean isBetter = false;
+ if(comparator.compare(outPoint.getEncodeInfo(), tobeReplacedPoint.getEncodeInfo())<IGoodnessCompareEngine.LARGER_THAN) {
+ tobeReplacedPoint.importPoint(outPoint);
+ isBetter = true;
+ }
+ return isBetter;
+ }
+
+ public int tournamentSelection(IGoodnessCompareEngine comparator, int times, boolean isBetter) {
+ int[] indices = RandomGenerator.randomSelection(getPopSize(), times);
+ int currentIndex = indices[0];
+ for (int i=1; i<indices.length; i++) {
+ int compareValue = comparator.compare(libPoints[indices[i]].getEncodeInfo(), libPoints[currentIndex].getEncodeInfo());
+ if (isBetter == (compareValue<IGoodnessCompareEngine.LARGER_THAN)) {
+ currentIndex = indices[i];
+ }
+ }
+ return currentIndex;
+ }
+
+ public double getExtremalVcon(boolean isMAX) {
+ double val=BasicBound.MINDOUBLE;
+ for(int i=0; i<libPoints.length; i++) {
+ if(libPoints[i].getEncodeInfo()[0]>val==isMAX) {
+ val = libPoints[i].getEncodeInfo()[0];
+ }
+ }
+ return val;
+ }
+
+ public int getVconThanNum(double allowedCons) {
+ int num=0;
+ for(int i=0; i<libPoints.length; i++) {
+ if(libPoints[i].getEncodeInfo()[0]<=allowedCons) {
+ num++;
+ }
+ }
+ return num;
+ }
+
+}
+
+
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/SearchPoint.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/SearchPoint.java
new file mode 100755
index 000000000000..0085ff7e481e
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/SearchPoint.java
@@ -0,0 +1,79 @@
+/**
+ * Description: provide the location and encoded goodness information
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Mar 1, 2003
+ * Xiaofeng Xie May 11, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ */
+package net.adaptivebox.knowledge;
+
+import net.adaptivebox.global.*;
+import net.adaptivebox.space.*;
+import net.adaptivebox.encode.*;
+
+public class SearchPoint extends BasicPoint implements IEncodeEngine {
+ //store the encode information for goodness evaluation
+ //encodeInfo[0]: the sum of constraints (if it equals to 0, then be a feasible point)
+ //encodeInfo[1]: the value of objective function
+ private double[] encodeInfo = new double[2];
+ private double objectiveValue;
+
+ public SearchPoint(int dim) {
+ super(dim);
+ for(int i=0; i<encodeInfo.length; i++) {
+ encodeInfo[i] = BasicBound.MAXDOUBLE;
+ }
+ }
+
+ public double[] getEncodeInfo() {
+ return encodeInfo;
+ }
+
+ private void importEncodeInfo(double[] info) {
+ for(int i=0; i<encodeInfo.length; i++) {
+ encodeInfo[i] = info[i];
+ }
+ }
+
+ private void importEncodeInfo(IEncodeEngine point) {
+ importEncodeInfo(point.getEncodeInfo());
+ }
+
+ //Replace self by given point
+ public void importPoint(SearchPoint point) {
+ importLocation(point);
+ importEncodeInfo(point);
+ setObjectiveValue(point.getObjectiveValue());
+ }
+
+ public double getObjectiveValue() {
+ return objectiveValue;
+ }
+
+ public void setObjectiveValue(double objectiveValue) {
+ this.objectiveValue = objectiveValue;
+ }
+
+ public boolean isFeasible() {
+ return encodeInfo[0] == 0; //no constraint violations
+ }
+
+ public void outputSelf() {
+ System.out.println("#--> Location:");
+ OutputMethods.outputVector(getLocation());
+ System.out.println("#--> (CON & OPTIM):");
+ OutputMethods.outputVector(getEncodeInfo());
+ }
+} \ No newline at end of file
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/ProblemEncoder.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/ProblemEncoder.java
new file mode 100755
index 000000000000..a5deb6315954
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/ProblemEncoder.java
@@ -0,0 +1,123 @@
+/**
+ * Description: Encodes the specified problem into encoded information for
+ * forming the goodness landscape.
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie May 31, 2000
+ * Xiaofeng Xie Sep. 19, 2002
+ * Xiaofeng Xie Mar. 01, 2003
+ * Xiaofeng Xie May 11, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @version 1.0
+ * @Since MAOS1.0
+ */
+
+package net.adaptivebox.problem;
+
+import net.adaptivebox.global.*;
+import net.adaptivebox.space.*;
+import net.adaptivebox.encode.*;
+import net.adaptivebox.knowledge.*;
+
+public abstract class ProblemEncoder {
+ //Store the calculated results for the responses
+ double[] tempResponseSet; //temp values
+ double[] tempLocation; //temp values
+
+ //the search space (S)
+ protected DesignSpace designSpace = null;
+
+ // For evaluate the response vector into encoded vector double[2]
+ protected EvalStruct evalStruct = null;
+
+ protected ProblemEncoder(int paramNum, int targetNum) throws Exception {
+ designSpace = new DesignSpace(paramNum);
+ evalStruct = new EvalStruct(targetNum);
+ tempLocation = new double[paramNum];
+ tempResponseSet = new double[targetNum];
+ }
+
+ public DesignSpace getDesignSpace() {
+ return designSpace;
+ }
+
+ public EvalStruct getEvalStruct() {
+ return evalStruct;
+ }
+
+ //set the default information for each dimension of search space (S)
+ protected void setDefaultXAt(int i, double min, double max, double grain) {
+ DesignDim dd = new DesignDim();
+ dd.grain = grain;
+ dd.paramBound = new BasicBound(min, max);
+ designSpace.setElemAt(dd, i);
+ }
+
+ protected void setDefaultXAt(int i, double min, double max) {
+ DesignDim dd = new DesignDim();
+ dd.paramBound = new BasicBound(min, max);
+ designSpace.setElemAt(dd, i);
+ }
+
+ //set the default information for evaluation each response
+ protected void setDefaultYAt(int i, double min, double max) {
+ EvalElement ee = new EvalElement();
+ ee.targetBound = new BasicBound(min, max);
+ evalStruct.setElemAt(ee, i);
+ }
+
+ protected void setDefaultYAt(int i, double min, double max, double weight) {
+ EvalElement ee = new EvalElement();
+ ee.targetBound = new BasicBound(min, max);
+ ee.weight = weight;
+ evalStruct.setElemAt(ee, i);
+ }
+
+ //get a fresh point
+ public SearchPoint getFreshSearchPoint() {
+ return new SearchPoint(designSpace.getDimension());
+ }
+
+ //get an encoded point
+ public SearchPoint getEncodedSearchPoint() {
+ SearchPoint point = getFreshSearchPoint();
+ designSpace.initializeGene(point.getLocation());
+ evaluate(point);
+ return point;
+ }
+
+ //evaluate the point into encoded information
+ public void evaluate(SearchPoint point) {
+ //copy to temp point
+ System.arraycopy(point.getLocation(), 0, this.tempLocation, 0, tempLocation.length);
+ //mapping the temp point to original search space S
+ designSpace.getMappingPoint(tempLocation);
+ //calculate based on the temp point
+ calcTargets(tempResponseSet, tempLocation);
+ evalStruct.evaluate(point.getEncodeInfo(), tempResponseSet);
+ point.setObjectiveValue(tempResponseSet[0]);
+ }
+
+ //calcuate each response, must be implemented
+ abstract protected double calcTargetAt(int index, double[] VX);
+
+ // calculate all the responses VY[] based on given point VX[]
+ private void calcTargets(double[] VY, double[] VX) {
+ for(int i=0; i<VY.length; i++) {
+ VY[i] = calcTargetAt(i, VX);
+ }
+ }
+}
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/UnconstrainedProblemEncoder.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/UnconstrainedProblemEncoder.java
new file mode 100755
index 000000000000..c06db87d83b7
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/UnconstrainedProblemEncoder.java
@@ -0,0 +1,39 @@
+/**
+ * Description: For unconstrained function
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Dec 28, 2001
+ * Xiaofeng Xie Mar 02, 2003
+ * Xiaofeng Xie May 11, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @version 1.0
+ * @Since MAOS1.0
+ */
+
+package net.adaptivebox.problem;
+
+import net.adaptivebox.global.*;
+
+public abstract class UnconstrainedProblemEncoder extends ProblemEncoder {
+ protected UnconstrainedProblemEncoder(int NX) throws Exception {
+ super(NX, 1);
+ setDefaultYAt(0, BasicBound.MINDOUBLE, BasicBound.MINDOUBLE);
+ }
+
+ protected double calcTargetAt(int index, double[] VX) {
+ return calcTarget(VX);
+ }
+ abstract public double calcTarget(double[] VX);
+}
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java
new file mode 100755
index 000000000000..910270e9e2da
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java
@@ -0,0 +1,132 @@
+package net.adaptivebox.sco;
+
+/**
+ * Description: The description of social cognitive agent.
+ *
+ * @Information source: a) external library (L); b) the own memory: a point that
+ * generated in the last learning cycle
+ *
+ * @Coefficients: TaoB and TaoW
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Mar 11, 2003
+ * Xiaofeng Xie May 11, 2004
+ * Xiaofeng Xie May 20, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @version 1.0
+ * @Since MAOS1.0
+ *
+ * @References:
+ * [1] Xie X F, Zhang W J. Solving engineering design problems by social cognitive
+ * optimization. Genetic and Evolutionary Computation Conference, 2004: 261-262
+ */
+
+
+import net.adaptivebox.global.*;
+import net.adaptivebox.space.*;
+import net.adaptivebox.goodness.*;
+import net.adaptivebox.problem.*;
+import net.adaptivebox.knowledge.*;
+
+public class SCAgent {
+
+ //Describes the problem to be solved (encode the point into intermediate information)
+ private ProblemEncoder problemEncoder;
+ //Forms the goodness landscape
+ private IGoodnessCompareEngine specComparator;
+
+ //the coefficients of SCAgent
+ protected int TaoB = 2;
+ //The early version set TaoW as the size of external library (NL), but 4 is often enough
+ protected int TaoW = 4;
+
+ //The referred external library
+ protected Library externalLib;
+ //store the point that generated in current learning cycle
+ protected SearchPoint trailPoint;
+ //the own memory: store the point that generated in last learning cycle
+ protected SearchPoint pcurrent_t;
+
+ public void setExternalLib(Library lib) {
+ externalLib = lib;
+ }
+
+ public void setProblemEncoder(ProblemEncoder encoder) {
+ problemEncoder = encoder;
+ trailPoint = problemEncoder.getFreshSearchPoint();
+ pcurrent_t = problemEncoder.getEncodedSearchPoint();
+ }
+
+ public void setSpecComparator(IGoodnessCompareEngine comparer) {
+ specComparator = comparer;
+ }
+
+ public SearchPoint generatePoint() {
+ //generate a new point
+ generatePoint(trailPoint);
+ //evalute the generated point
+ problemEncoder.evaluate(trailPoint);
+ return trailPoint;
+ }
+
+ protected void generatePoint(ILocationEngine tempPoint) {
+ SearchPoint Xmodel, Xrefer, libBPoint;
+
+ // choose Selects a better point (libBPoint) from externalLib (L) based
+ // on tournament selection
+ int xb = externalLib.tournamentSelection(specComparator, TaoB, true);
+ libBPoint = externalLib.getSelectedPoint(xb);
+ // Compares pcurrent_t with libBPoint
+ // The better one becomes model point (Xmodel)
+ // The worse one becomes refer point (Xrefer)
+ if(specComparator.compare(pcurrent_t.getEncodeInfo(), libBPoint.getEncodeInfo())==IGoodnessCompareEngine.LARGER_THAN) {
+ Xmodel = libBPoint;
+ Xrefer = pcurrent_t;
+ } else {
+ Xmodel = pcurrent_t;
+ Xrefer = libBPoint;
+ }
+ // observational learning: generates a new point near the model point, which
+ // the variation range is decided by the difference of Xmodel and Xrefer
+ inferPoint(tempPoint, Xmodel, Xrefer, problemEncoder.getDesignSpace());
+ }
+
+ //1. Update the current point into the external library
+ //2. Replace the current point by the generated point
+ public void updateInfo() {
+ //Selects a bad point kw from TaoW points in Library
+ int xw = externalLib.tournamentSelection(specComparator, TaoW, false);
+ //Repaces kw with pcurrent_t
+ externalLib.getSelectedPoint(xw).importPoint(pcurrent_t);
+ //Repaces pcurrent_t (x(t)) with trailPoint (x(t+1))
+ pcurrent_t.importPoint(trailPoint);
+ }
+
+ // 1---model point, 2---refer point
+ public boolean inferPoint(ILocationEngine newPoint, ILocationEngine point1,ILocationEngine point2, DesignSpace space){
+ double[] newLoc = newPoint.getLocation();
+ double[] real1 = point1.getLocation();
+ double[] real2 = point2.getLocation();
+
+ for (int i=0; i<newLoc.length; i++) {
+ newLoc[i] = real1[i]*2-real2[i];
+ //boundary handling
+ newLoc[i] = space.boundAdjustAt(newLoc[i], i);
+ newLoc[i] = RandomGenerator.doubleRangeRandom(newLoc[i], real2[i]);
+ }
+ return true;
+ }
+}
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/BasicPoint.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/BasicPoint.java
new file mode 100755
index 000000000000..aba52de303a1
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/BasicPoint.java
@@ -0,0 +1,42 @@
+/**
+ * Description: provide the location information of a point
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Mar 1, 2003
+ * Xiaofeng Xie May 11, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ */
+
+package net.adaptivebox.space;
+
+public class BasicPoint implements Cloneable, ILocationEngine {
+ //store the location information in the search space (S)
+ private double[] location;
+
+ public BasicPoint(int dim) {
+ location = new double[dim];
+ }
+
+ public double[] getLocation() {
+ return location;
+ }
+
+ public void importLocation(double[] pointLoc) {
+ System.arraycopy(pointLoc, 0, location, 0, pointLoc.length);
+ }
+
+ public void importLocation(ILocationEngine point) {
+ importLocation(point.getLocation());
+ }
+} \ No newline at end of file
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignDim.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignDim.java
new file mode 100755
index 000000000000..aa9988c1b3a9
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignDim.java
@@ -0,0 +1,52 @@
+/**
+ * Description: provide the information for goodness evaluation of a target
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Mar 1, 2003
+ * Xiaofeng Xie May 3, 2004 Add grain value
+ * Xiaofeng Xie May 11, 2004 Add crowd distance
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ */
+
+package net.adaptivebox.space;
+import net.adaptivebox.global.*;
+
+public class DesignDim {
+ // To discrete space with the given step. For example, for an integer variable,
+ // The grain value can be set as 1.
+ public double grain = 0;
+ public BasicBound paramBound = new BasicBound(); //the range of a parameter
+
+
+ public void importData(DesignDim ipr) {
+ this.grain = ipr.grain;
+ this.paramBound = ipr.paramBound;
+ }
+
+ public boolean isDiscrete() {
+ return grain!=0;
+ }
+
+ public double getGrainedValue(double value) {
+ if(grain==0) {
+ return value;
+ } else if(grain>0) {
+ return paramBound.minValue+Math.rint((value-paramBound.minValue)/grain)*grain;
+ } else {
+ return paramBound.maxValue-Math.rint((paramBound.maxValue-value)/grain)*grain;
+ }
+ }
+
+}
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignSpace.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignSpace.java
new file mode 100755
index 000000000000..6a493f37ae74
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignSpace.java
@@ -0,0 +1,141 @@
+/**
+ * Description: provide the information for the search space (S)
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Mar 2, 2003
+ * Xiaofeng Xie May 11, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ *
+ * @References:
+ * [1] Zhang W J, Xie X F, Bi D C. Handling boundary constraints for numerical
+ * optimization by particle swarm flying in periodic search space. Congress
+ * on Evolutionary Computation, Oregon, USA, 2004
+ * @ especially for particle swarm agent
+ */
+
+package net.adaptivebox.space;
+import net.adaptivebox.global.*;
+
+public class DesignSpace {
+ //The information of all the dimension
+ private DesignDim[] dimProps;
+
+ public DesignSpace(int dim) {
+ dimProps = new DesignDim[dim];
+ }
+
+ public DesignDim getDimAt(int index) {
+ return dimProps[index];
+ }
+
+ public void setElemAt(DesignDim elem, int index) {
+ dimProps[index] = elem;
+ }
+
+ public int getDimension() {
+ if (dimProps==null) {
+ return -1;
+ }
+ return dimProps.length;
+ }
+
+ public double boundAdjustAt(double val, int dim){
+ return dimProps[dim].paramBound.boundAdjust(val);
+ }
+
+ public void annulusAdjust (double[] location){
+ for (int i=0; i<getDimension(); i++) {
+ location[i] = dimProps[i].paramBound.annulusAdjust(location[i]);
+ }
+ }
+
+ public void randomAdjust (double[] location){
+ for (int i=0; i<getDimension(); i++) {
+ location[i] = dimProps[i].paramBound.randomAdjust(location[i]);
+ }
+ }
+
+ public boolean satisfyCondition(double[] location){
+ for (int i=0; i<getDimension(); i++) {
+ if (!dimProps[i].paramBound.isSatisfyCondition(location[i])) {
+ return false;
+ }
+ }
+ /*If the limits are not violated, return TRUE*/
+ return(true);
+ }
+
+ public void mutationAt(double[] location, int i){
+ location[i] = dimProps[i].paramBound.getRandomValue();
+ }
+
+ public double mutationUniformAtPointAsCenter (double pointX, int i){
+ double length = this.getMagnitudeIn(i)/2;
+ pointX += RandomGenerator.doubleRangeRandom(-1*length, length);
+
+ return pointX;
+ }
+
+ public double getUpValueAt(int dimensionIndex) {
+ return dimProps[dimensionIndex].paramBound.maxValue;
+ }
+
+ public double getLowValueAt(int dimensionIndex) {
+ return dimProps[dimensionIndex].paramBound.minValue;
+ }
+
+ public double getMagnitudeIn(int dimensionIndex) {
+ return dimProps[dimensionIndex].paramBound.getLength();
+ }
+
+
+ public boolean initilizeGeneAtPointAsCenter(double[] tempX){
+ if (tempX.length!=this.getDimension()) {
+ return false;
+ }
+ for(int i=0;i<tempX.length;i++) {
+ double length = this.getMagnitudeIn(i)/2;
+ tempX[i]+=RandomGenerator.doubleRangeRandom(-1*length, length);
+ }
+ return true;
+ }
+
+ public void initializeGene(double[] tempX){
+ for(int i=0;i<tempX.length;i++) tempX[i] = dimProps[i].paramBound.getRandomValue(); //Global.RandomGenerator.doubleRangeRandom(9.8, 10);
+ }
+
+ public double[] getFreshGene() {
+ double[] tempX = new double[this.getDimension()];
+ initializeGene(tempX);
+ return tempX;
+ }
+ public void getMappingPoint(double[] point) {
+ for(int i=0; i<getDimension(); i++) {
+ point[i] = dimProps[i].paramBound.annulusAdjust(point[i]);
+ if(dimProps[i].isDiscrete()) {
+ point[i] = dimProps[i].getGrainedValue(point[i]);
+ }
+ }
+ }
+
+ public double[] getRealLoc(double[] imageLoc) {
+ double[] realLoc = new double[imageLoc.length];
+ for (int i=0; i<imageLoc.length; i++) {
+ realLoc[i] = imageLoc[i];
+ }
+ annulusAdjust(realLoc);
+ return realLoc;
+ }
+}
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/ILocationEngine.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/ILocationEngine.java
new file mode 100755
index 000000000000..fa5375b7608d
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/ILocationEngine.java
@@ -0,0 +1,25 @@
+/**
+ * Description: provide the information for location
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie May 3, 2003
+ * Xiaofeng Xie May 11, 2004
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Please acknowledge the author(s) if you use this code in any way.
+ */
+
+package net.adaptivebox.space;
+
+public interface ILocationEngine{
+ abstract public double[] getLocation();
+}