summaryrefslogtreecommitdiff
path: root/nlpsolver
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2011-11-25 12:41:39 +0000
committerMichael Meeks <michael.meeks@suse.com>2011-11-28 11:06:59 +0000
commit17ff286751454dcd5aa86bef41a8e53cfb109c70 (patch)
tree615db0eda5afe21aa7c5b9db57416d34ed11c464 /nlpsolver
parente46454b676bedc5585456cc37c63c9e4ff7deaad (diff)
Flatten un-maintained ex. Sun/Oracle nlpsolver extension into the repo
This should make it easier to hack, and also to separate out the tangled in third party EvolutionarySolver as/when we can.
Diffstat (limited to 'nlpsolver')
-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
-rw-r--r--nlpsolver/build.xml72
-rwxr-xr-xnlpsolver/description/extensiondescription.txt2
-rwxr-xr-xnlpsolver/help/en/com.sun.star.comp.Calc.NLPSolver/Options.xhp197
-rwxr-xr-xnlpsolver/help/en/com.sun.star.comp.Calc.NLPSolver/Usage.xhp51
-rwxr-xr-xnlpsolver/licenses/lgpl-3.0.txt165
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java387
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java580
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/CentralRegistrationClass.java146
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java215
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java105
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/ResourceManager.java101
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/SCOSolverImpl.java169
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/BaseDialog.java169
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/DummyEvolutionarySolverStatusDialog.java80
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/EvolutionarySolverStatusUno.java306
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/IEvolutionarySolverStatusDialog.java55
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/ModalState.java43
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/BaseControl.java154
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/Button.java80
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/Label.java85
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/LabeledControl.java57
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/ProgressBar.java81
-rwxr-xr-xnlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/TextAlign.java51
-rw-r--r--nlpsolver/src/description.xml23
-rwxr-xr-xnlpsolver/src/locale/NLPSolverCommon_en_US.default0
-rwxr-xr-xnlpsolver/src/locale/NLPSolverStatusDialog_en_US.default0
-rwxr-xr-xnlpsolver/src/uno-extension-manifest.xml9
64 files changed, 6616 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();
+}
diff --git a/nlpsolver/build.xml b/nlpsolver/build.xml
new file mode 100644
index 000000000000..8f5e2cdfb909
--- /dev/null
+++ b/nlpsolver/build.xml
@@ -0,0 +1,72 @@
+<?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.) -->
+<project name="NLPSolver" default="default" basedir=".">
+ <description>Builds, tests, and runs the project extension project.</description>
+ <import file="nbproject/build-uno-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
+ -pre-uno-package: called before OXT creation
+ -post-uno-package: called after OXT creation
+ -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="TypeBrowser2-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/description/extensiondescription.txt b/nlpsolver/description/extensiondescription.txt
new file mode 100755
index 000000000000..5a9fbed0f73d
--- /dev/null
+++ b/nlpsolver/description/extensiondescription.txt
@@ -0,0 +1,2 @@
+This extension integrates into Calc and offers new Solver engines
+to use for optimizing nonlinear programming models. \ No newline at end of file
diff --git a/nlpsolver/help/en/com.sun.star.comp.Calc.NLPSolver/Options.xhp b/nlpsolver/help/en/com.sun.star.comp.Calc.NLPSolver/Options.xhp
new file mode 100755
index 000000000000..bbe58889cb77
--- /dev/null
+++ b/nlpsolver/help/en/com.sun.star.comp.Calc.NLPSolver/Options.xhp
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<helpdocument version="1.0">
+
+<!--
+***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: Options.xhp,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************
+ -->
+
+
+<meta>
+ <topic id="nlpsolveroptions" indexer="include">
+ <title xml-lang="en-US" id="tit">Options</title>
+ <filename>/com.sun.star.comp.Calc.NLPSolver/Options.xhp</filename>
+ </topic>
+ </meta>
+ <body>
+<bookmark xml-lang="en-US" branch="index" id="bm_id0503200917110375_scalc"><bookmark_value>Solver for Nonlinear Problems;Options</bookmark_value>
+</bookmark>
+<paragraph xml-lang="en-US" id="hd_id0503200917103593" role="heading" level="1" l10n="NEW">General Options</paragraph>
+ <table id="">
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103780" role="tablecontent" l10n="NEW">Size of Swarm</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103723" role="tablecontent" l10n="NEW">… defines the number of individuals to participate in the learning process. Each individual finds its own solutions and contributes to the overall knowledge.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103771" role="tablecontent" l10n="NEW">Learning Cycles</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103720" role="tablecontent" l10n="NEW">… defines the number of iterations, the algorithm should take. In each iteration, all individuals make a guess on the best solution and share their knowledge.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103732" role="tablecontent" l10n="NEW">Variable Bounds Guessing</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id050320091710378" role="tablecontent" l10n="NEW">If enabled (default), the algorithm tries to find variable bounds by looking at the starting values.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103794" role="tablecontent" l10n="NEW">Variable Bounds Threshold</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103710" role="tablecontent" l10n="NEW">When guessing variable bounds, this threshold specifies, how the initial values are shifted to build the bounds. For an example how these values are calculated, please refer to the Manual in the Wiki.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103740" role="tablecontent" l10n="NEW">Use ACR Comparator</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103766" role="tablecontent" l10n="NEW">If <emph>disabled</emph> (default), the BCH Comparator is used. It compares two individuals by first looking at their constraint violations and only if those are equal, it measures their current solution.</paragraph>
+ <paragraph xml-lang="en-US" id="par_id0503200917103744" role="tablecontent" l10n="NEW">If <emph>enabled</emph>, the ACR Comparator is used. It compares two individuals dependent on the current iteration and measures their goodness with knowledge about the libraries worst known solutions (in regard to their constraint violations).</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103792" role="tablecontent" l10n="NEW">Use Random Starting Point</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103790" role="tablecontent" l10n="NEW">If <emph>enabled</emph>, the library is simply filled up with randomly chosen points.</paragraph>
+ <paragraph xml-lang="en-US" id="par_id0503200917103765" role="tablecontent" l10n="NEW">If <emph>disabled</emph>, the currently present values (as given by the user) are inserted in the library as reference point.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103794" role="tablecontent" l10n="NEW">Stagnation Limit</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id050320091710377" role="tablecontent" l10n="NEW">If this number of individuals found solutions within a close range, the iteration is stopped and the best of these values is chosen as optimal.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103762" role="tablecontent" l10n="NEW">Stagnation Tolerance</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103834" role="tablecontent" l10n="NEW">Defines in what range solutions are considered “similar”.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103891" role="tablecontent" l10n="NEW">Show Enhanced Solver Status</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0503200917103832" role="tablecontent" l10n="NEW">If <emph>enabled</emph>, an additional dialog is shown during the solving process which gives informations about the current progress, the level of stagnation, the currently best known solution as well as the possibility, to stop or resume the solver.</paragraph>
+ </tablecell>
+ </tablerow>
+ </table>
+
+ <paragraph xml-lang="en-US" id="hd_id0603200910392151" role="heading" level="2" l10n="NEW">DEPS-specific Options</paragraph>
+ <table id="">
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0603200910394232" role="tablecontent" l10n="NEW">Agent Switch Rate</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0603200910394248" role="tablecontent" l10n="NEW">Specifies the probability for an individual to choose the Differential Evolution strategy.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0603200910394277" role="tablecontent" l10n="NEW">DE: Crossover Probability</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0603200910394280" role="tablecontent" l10n="NEW">… defines the probability of the individual being combined with the globally best point. If crossover is not used, the point is assembled from the own memory of the individual.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0603200910394216" role="tablecontent" l10n="NEW">DE: Scaling Factor</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id060320091039424" role="tablecontent" l10n="NEW">During crossover, the scaling factor decides about the “speed” of movement.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id060320091039421" role="tablecontent" l10n="NEW">PS: Constriction Coefficient</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0603200910394225" role="tablecontent" l10n="NEW">… defines the speed at which the particles/individuals move towards each other.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0603200910394222" role="tablecontent" l10n="NEW">PS: Cognitive Constant</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0603200910394212" role="tablecontent" l10n="NEW">… sets the importance of the own memory (in particular the best reached point so far).</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0603200910394232" role="tablecontent" l10n="NEW">PS: Social Constant</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0603200910394284" role="tablecontent" l10n="NEW">… sets the importance of the global best point between all particles/individuals.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id060320091039425" role="tablecontent" l10n="NEW">PS: Mutation Probability</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0603200910394272" role="tablecontent" l10n="NEW">… defines the probability, that instead of moving a component of the particle towards the best point, it randomly chooses a new value from the valid range for that variable.</paragraph>
+ </tablecell>
+ </tablerow>
+ </table>
+
+ <paragraph xml-lang="en-US" id="hd_id0603200910401383" role="heading" level="2" l10n="NEW">SCO-specific Options</paragraph>
+ <table id="">
+ <tablerow>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id0603200910401382" role="tablecontent" l10n="NEW">Size of Library</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph xml-lang="en-US" id="par_id060320091040136" role="tablecontent" l10n="NEW">… defines the amount of informations to store in the public library. Each individual stores knowledge there and asks for informations.</paragraph>
+ </tablecell>
+ </tablerow>
+ </table>
+
+ </body>
+</helpdocument> \ No newline at end of file
diff --git a/nlpsolver/help/en/com.sun.star.comp.Calc.NLPSolver/Usage.xhp b/nlpsolver/help/en/com.sun.star.comp.Calc.NLPSolver/Usage.xhp
new file mode 100755
index 000000000000..d5b825816d3b
--- /dev/null
+++ b/nlpsolver/help/en/com.sun.star.comp.Calc.NLPSolver/Usage.xhp
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<helpdocument version="1.0">
+
+<!--
+***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: Usage.xhp,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************
+ -->
+
+
+<meta>
+ <topic id="nlpsolverusage" indexer="include">
+ <title xml-lang="en-US" id="tit">Usage</title>
+ <filename>/com.sun.star.comp.Calc.NLPSolver/Usage.xhp</filename>
+ </topic>
+ </meta>
+ <body>
+<bookmark xml-lang="en-US" branch="index" id="bm_id0603200910434044_scalc"><bookmark_value>Solver for Nonlinear Problems;Usage</bookmark_value>
+</bookmark>
+<paragraph xml-lang="en-US" id="hd_id0603200910430882" role="heading" level="1" l10n="NEW">Usage</paragraph>
+ <paragraph xml-lang="en-US" id="par_id0603200910430845" role="paragraph" l10n="NEW">Regardless whether you use DEPS or SCO, you start by going to Tools → Solver and set the Cell to be optimized, the direction to go (minimization, maximization) and the cells to be modified to reach the goal. Then you go to the Options and specify the solver to be used and if necessary adjust the according <link href="com.sun.star.comp.Calc.NLPSolver/Options.xhp">parameters</link>.</paragraph>
+ <paragraph xml-lang="en-US" id="par_id0603200910430821" role="paragraph" l10n="NEW">There is also a list of constraints you can use to restrict the possible range of solutions or to penalize certain conditions. However, in case of the evolutionary solvers DEPS and SCO, these constraints are also used to specify bounds on the variables of the problem. Due to the random nature of the algorithms, it is <emph>highly recommended</emph> to do so and give upper (and in case "Assume Non-Negative Variables" is turned off also lower) bounds for all variables. They don't have to be near the actual solution (which is probably unknown) but should give a rough indication of the expected size (0 ≤ var ≤ 1 or maybe -1000000 ≤ var ≤ 1000000).</paragraph>
+ <paragraph xml-lang="en-US" id="par_id0603200910430873" role="paragraph" l10n="NEW">Bounds are specified by selecting one or more variables (as range) on the left side and entering a numerical value (not a cell or a formula) on the right side. That way you can also choose one or more variables to be <emph>Integer</emph> or <emph>Binary</emph> only.</paragraph>
+ </body>
+</helpdocument> \ No newline at end of file
diff --git a/nlpsolver/licenses/lgpl-3.0.txt b/nlpsolver/licenses/lgpl-3.0.txt
new file mode 100755
index 000000000000..fc8a5de7edf4
--- /dev/null
+++ b/nlpsolver/licenses/lgpl-3.0.txt
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
new file mode 100755
index 000000000000..1f1fd4aca4cf
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
@@ -0,0 +1,387 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BaseEvolutionarySolver.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver;
+
+import com.sun.star.comp.Calc.NLPSolver.dialogs.DummyEvolutionarySolverStatusDialog;
+import com.sun.star.comp.Calc.NLPSolver.dialogs.EvolutionarySolverStatusUno;
+import com.sun.star.comp.Calc.NLPSolver.dialogs.IEvolutionarySolverStatusDialog;
+import com.sun.star.sheet.SolverConstraintOperator;
+import com.sun.star.uno.XComponentContext;
+import java.util.ArrayList;
+import net.adaptivebox.global.BasicBound;
+import net.adaptivebox.goodness.ACRComparator;
+import net.adaptivebox.goodness.BCHComparator;
+import net.adaptivebox.goodness.IGoodnessCompareEngine;
+import net.adaptivebox.knowledge.Library;
+import net.adaptivebox.knowledge.SearchPoint;
+import net.adaptivebox.problem.ProblemEncoder;
+
+/**
+ *
+ * @author Andreas Schneider <Andreas.Schneider@Sun.COM>
+ */
+public abstract class BaseEvolutionarySolver extends BaseNLPSolver {
+
+ public BaseEvolutionarySolver(XComponentContext xContext, String name) {
+ super(xContext, name);
+
+ registerProperty(m_swarmSize);
+ registerProperty(m_learningCycles);
+ registerProperty(m_guessVariableRange);
+ registerProperty(m_variableRangeThreshold);
+ registerProperty(m_useACRComperator);
+
+ registerProperty(m_useRandomStartingPoint);
+
+ registerProperty(m_required);
+ registerProperty(m_tolerance);
+
+ registerProperty(m_enhancedSolverStatus);
+ }
+
+ protected class Variable {
+ protected CellMap CellMap;
+ protected int OriginalVariable;
+ protected double MinValue;
+ protected double MaxValue;
+ protected double Granularity;
+
+ protected Variable(CellMap cellMap, int originalVariable) {
+ this.CellMap = cellMap;
+ this.OriginalVariable = originalVariable;
+ this.MinValue = BasicBound.MINDOUBLE;
+ this.MaxValue = BasicBound.MAXDOUBLE;
+ this.Granularity = 0.0;
+ }
+ }
+
+ protected class CalcProblemEncoder extends ProblemEncoder {
+
+ private ArrayList<Variable> m_variables;
+ private ArrayList<ExtSolverConstraint> m_constraints;
+
+ protected CalcProblemEncoder(ArrayList<Variable> variables,
+ ArrayList<ExtSolverConstraint> constraints) throws Exception {
+ //m_variableCount variables to solve, target function + constraints to match
+ super(variables.size(), 1 + constraints.size());
+
+ m_variables = variables;
+ m_constraints = constraints;
+
+ double objective = m_maximize ? BasicBound.MAXDOUBLE : BasicBound.MINDOUBLE;
+ setDefaultYAt(0, objective, objective);
+
+ for (int i = 0; i < constraints.size(); i++) {
+ ExtSolverConstraint constraint = constraints.get(i);
+
+ switch (constraint.Operator.getValue()) {
+ case SolverConstraintOperator.EQUAL_value:
+ setDefaultYAt(i + 1, constraint.Data, constraint.Data);
+ break;
+ case SolverConstraintOperator.GREATER_EQUAL_value:
+ setDefaultYAt(i + 1, constraint.Data, BasicBound.MAXDOUBLE);
+ break;
+ case SolverConstraintOperator.LESS_EQUAL_value:
+ setDefaultYAt(i + 1, BasicBound.MINDOUBLE, constraint.Data);
+ break;
+ }
+ }
+
+ for (int i = 0; i < m_variables.size(); i++) {
+ Variable variable = m_variables.get(i);
+ setDefaultXAt(i, variable.MinValue, variable.MaxValue, variable.Granularity);
+ }
+ }
+
+ @Override
+ protected double calcTargetAt(int index, double[] VX) {
+ if (index == 0) {
+ //calcTargetAt is called in a loop over all functions, so it's
+ //enough to set the variables in the first step only
+ for (int i = 0; i < m_variables.size(); i++) {
+ CellMap variableMap = m_variables.get(i).CellMap;
+ m_variableData[variableMap.Range][variableMap.Row][variableMap.Col] = VX[i];
+ //m_variableCells[i].setValue(VX[i]);
+ }
+ for (int i = 0; i < m_cellRangeCount; i++)
+ m_cellRangeData[i].setData(m_variableData[i]);
+
+ //errors are punished
+ if (m_objectiveCell.getError() != 0)
+ return m_maximize ? BasicBound.MINDOUBLE : BasicBound.MAXDOUBLE;
+
+ double result = m_objectiveCell.getValue();
+
+ if (result >= m_toleratedMin && result <= m_toleratedMax && checkConstraints())
+ m_toleratedCount++;
+
+ return result;
+ } else
+ return m_constraints.get(index - 1).getLeftValue();
+ }
+
+ }
+
+ protected CalcProblemEncoder m_problemEncoder;
+ protected Library m_library;
+ protected IGoodnessCompareEngine m_envCompareEngine;
+ protected IGoodnessCompareEngine m_specCompareEngine;
+ protected SearchPoint m_totalBestPoint;
+
+ protected int m_toleratedCount;
+ protected double m_toleratedMin;
+ protected double m_toleratedMax;
+
+ protected ArrayList<Variable> m_variables = new ArrayList<Variable>();
+
+ //properties
+ protected PropertyInfo<Integer> m_swarmSize = new PropertyInfo<Integer>("SwarmSize", 70, "Size of Swam");
+ protected PropertyInfo<Integer> m_librarySize = new PropertyInfo<Integer>("LibrarySize", 210, "Size of Library");
+ protected PropertyInfo<Integer> m_learningCycles = new PropertyInfo<Integer>("LearningCycles", 2000, "Learning Cycles");
+ protected PropertyInfo<Boolean> m_guessVariableRange = new PropertyInfo<Boolean>("GuessVariableRange", true, "Variable Bounds Guessing");
+ protected PropertyInfo<Double> m_variableRangeThreshold = new PropertyInfo<Double>("VariableRangeThreshold", 3.0, "Variable Bounds Threshold (when guessing)"); //to approximate the variable bounds
+ protected PropertyInfo<Boolean> m_useACRComperator = new PropertyInfo<Boolean>("UseACRComparator", false, "Use ACR Comparator (instead of BCH)");
+ protected PropertyInfo<Boolean> m_useRandomStartingPoint = new PropertyInfo<Boolean>("UseRandomStartingPoint", false, "Use Random starting point");
+ protected PropertyInfo<Integer> m_required = new PropertyInfo<Integer>("StagnationLimit", 70, "Stagnation Limit");
+ protected PropertyInfo<Double> m_tolerance = new PropertyInfo<Double>("Tolerance", 1e-6, "Stagnation Tolerance");
+ protected PropertyInfo<Boolean> m_enhancedSolverStatus = new PropertyInfo<Boolean>("EnhancedSolverStatus", true, "Show enhanced solver status");
+
+ protected IEvolutionarySolverStatusDialog m_solverStatusDialog;
+
+ protected void prepareVariables(double[][] variableBounds) {
+ m_variables.clear();
+ for (int i = 0; i < m_variableCount; i++) {
+ Variable var = new Variable(m_variableMap[i], i);
+ var.MinValue = variableBounds[i][0];
+ var.MaxValue = variableBounds[i][1];
+ var.Granularity = variableBounds[i][2];
+ m_variables.add(var);
+ }
+ }
+
+ @Override
+ protected void initializeSolve() {
+ super.initializeSolve();
+
+ if (m_enhancedSolverStatus.getValue())
+ m_solverStatusDialog = new EvolutionarySolverStatusUno(m_xContext);
+ else
+ m_solverStatusDialog = new DummyEvolutionarySolverStatusDialog();
+
+ //Init:
+ double[][] variableBounds = new double[m_variableCount][3];
+ //approximate variable bounds
+ for (int i = 0; i < m_variableCount; i++) {
+ if (m_guessVariableRange.getValue()) {
+ double value = m_variableCells[i].getValue();
+
+ //0 is a bad starting point, so just pick some other.
+ //That is certainly not optimal but the user should specify
+ //bounds or at least a good starting point anyway.
+ if (value == 0.0)
+ value = 1000;
+
+ double b1;
+ double b2;
+
+ if (m_assumeNonNegative.getValue()) {
+ b1 = 0;
+ b2 = value + value * 2 * m_variableRangeThreshold.getValue();
+ } else {
+ b1 = value + value * m_variableRangeThreshold.getValue();
+ b2 = value - value * m_variableRangeThreshold.getValue();
+ }
+
+ variableBounds[i][0] = Math.min(b1, b2);
+ variableBounds[i][1] = Math.max(b1, b2);
+ } else {
+ //that almost always leads to bad or no solutions at all
+ if (m_assumeNonNegative.getValue())
+ variableBounds[i][0] = 0.0;
+ else
+ variableBounds[i][0] = BasicBound.MINDOUBLE;
+ variableBounds[i][1] = BasicBound.MAXDOUBLE;
+ }
+ variableBounds[i][2] = 0.0;
+ }
+
+ //prepare constraints and parse them for variable bounds
+ ArrayList<ExtSolverConstraint> constraints = new ArrayList<ExtSolverConstraint>();
+ for (int i = 0; i < m_constraintCount; i++) {
+ Double doubleValue;
+
+ if (m_extConstraints[i].Right != null)
+ doubleValue = null;
+ else
+ doubleValue = m_extConstraints[i].Data;
+
+ boolean isVariableBound = false;
+ //If it refers to a cell, it has to be treated as constraint, not as
+ //bound.
+ if (m_extConstraints[i].Right == null) {
+ for (int j = 0; j < m_variableCount && !isVariableBound; j++) {
+ if (m_constraints[i].Left.Sheet == super.m_variables[j].Sheet &&
+ m_constraints[i].Left.Column == super.m_variables[j].Column &&
+ m_constraints[i].Left.Row == super.m_variables[j].Row) {
+ isVariableBound = true;
+
+ //Therefore we try to use it as bounds for this variable.
+
+ switch (m_extConstraints[i].Operator.getValue()) {
+ case SolverConstraintOperator.EQUAL_value:
+ if (doubleValue == null)
+ continue;
+ variableBounds[j][0] = doubleValue;
+ variableBounds[j][1] = doubleValue;
+ break;
+ case SolverConstraintOperator.GREATER_EQUAL_value:
+ if (doubleValue == null)
+ continue;
+ variableBounds[j][0] = doubleValue;
+ break;
+ case SolverConstraintOperator.LESS_EQUAL_value:
+ if (doubleValue == null)
+ continue;
+ variableBounds[j][1] = doubleValue;
+ break;
+ case SolverConstraintOperator.INTEGER_value:
+ variableBounds[j][2] = 1.0;
+ break;
+ case SolverConstraintOperator.BINARY_value:
+ variableBounds[j][0] = 0.0;
+ variableBounds[j][1] = 1.0;
+ variableBounds[j][2] = 1.0;
+ break;
+ default:
+ //If it is neither <=, nor =, nor >=, we treat
+ //it as normal constraint.
+ isVariableBound = false;
+ }
+ }
+ }
+ }
+
+ if (!isVariableBound) {
+ constraints.add(m_extConstraints[i]);
+ }
+ }
+
+ prepareVariables(variableBounds);
+
+ try {
+ m_problemEncoder = new CalcProblemEncoder(m_variables, constraints);
+ } catch (Exception e) {
+ m_problemEncoder = null;
+ return;
+ }
+
+ m_library = new Library(m_librarySize.getValue(), m_problemEncoder);
+
+ if (m_useRandomStartingPoint.getValue()) {
+ m_totalBestPoint = m_problemEncoder.getEncodedSearchPoint();
+ } else {
+ m_totalBestPoint = m_problemEncoder.getFreshSearchPoint();
+ double[] currentValues = new double[m_variables.size()];
+ for (int i = 0; i < m_variables.size(); i++)
+ currentValues[i] = m_currentParameters[m_variables.get(i).OriginalVariable];
+ m_totalBestPoint.importLocation(currentValues);
+ m_problemEncoder.evaluate(m_totalBestPoint);
+ }
+ //input the chosen point into the library as reference for the individuals
+ m_library.getSelectedPoint(0).importPoint(m_totalBestPoint);
+
+ m_solverStatusDialog.setBestSolution(m_totalBestPoint.getObjectiveValue(), checkConstraints());
+
+ m_envCompareEngine = new BCHComparator();
+ m_specCompareEngine = m_useACRComperator.getValue() ? new ACRComparator(m_library, m_learningCycles.getValue()) : new BCHComparator();
+ }
+
+ protected void applySolution() {
+ double[] location = m_totalBestPoint.getLocation();
+
+ //make sure, the "Integer" variable type is met
+ m_problemEncoder.getDesignSpace().getMappingPoint(location);
+
+ //get the function value for our optimal point
+ for (int i = 0; i < m_variableCount; i++) {
+ m_variableCells[i].setValue(location[i]);
+ m_currentParameters[i] = location[i];
+ }
+ m_functionValue = m_objectiveCell.getValue();
+ }
+
+ @Override
+ protected void finalizeSolve() {
+ applySolution();
+
+ m_success = (m_objectiveCell.getError() == 0 && checkConstraints());
+
+ m_solverStatusDialog.setVisible(false);
+ m_solverStatusDialog.dispose();
+
+ super.finalizeSolve();
+ }
+
+ protected boolean checkConstraints() {
+ boolean result = true;
+ for (int i = 0; i < m_constraintCount && result; i++) {
+ if (m_extConstraints[i].Left.getError() == 0) {
+ Double value, targetValue;
+
+ value = m_extConstraints[i].getLeftValue();
+ targetValue = m_extConstraints[i].Data;
+
+ switch (m_extConstraints[i].Operator.getValue()) {
+ case SolverConstraintOperator.EQUAL_value:
+ result = (targetValue != null && value.equals(targetValue));
+ break;
+ case SolverConstraintOperator.GREATER_EQUAL_value:
+ result = (targetValue != null && value >= targetValue);
+ break;
+ case SolverConstraintOperator.LESS_EQUAL_value:
+ result = (targetValue != null && value <= targetValue);
+ break;
+ case SolverConstraintOperator.INTEGER_value:
+ result = (Math.rint(value) == value);
+ break;
+ case SolverConstraintOperator.BINARY_value:
+ result = (value == 0.0 || value == 1.0);
+ break;
+ }
+ } else {
+ result = false;
+ }
+ }
+
+ return result;
+ }
+
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java
new file mode 100755
index 000000000000..eb30bcfe7666
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java
@@ -0,0 +1,580 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BaseNLPSolver.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver;
+
+import com.sun.star.awt.XReschedule;
+import com.sun.star.beans.Property;
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.beans.XPropertyChangeListener;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.beans.XVetoableChangeListener;
+import com.sun.star.chart.XChartDataArray;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.document.XEmbeddedObjectSupplier;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.IndexOutOfBoundsException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.sheet.SolverConstraint;
+import com.sun.star.sheet.SolverConstraintOperator;
+import com.sun.star.sheet.XCellRangeData;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.sheet.XSpreadsheets;
+import com.sun.star.table.CellAddress;
+import com.sun.star.table.CellContentType;
+import com.sun.star.table.CellRangeAddress;
+import com.sun.star.table.XCell;
+import com.sun.star.table.XTableChartsSupplier;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Andreas Schneider <Andreas.Schneider@Sun.COM>
+ */
+public abstract class BaseNLPSolver extends WeakBase
+ implements com.sun.star.lang.XLocalizable,
+ com.sun.star.sheet.XSolver,
+ com.sun.star.sheet.XSolverDescription,
+ com.sun.star.beans.XPropertySet,
+ com.sun.star.beans.XPropertySetInfo
+{
+
+ protected final XComponentContext m_xContext;
+ protected final String m_name;
+
+ protected final ArrayList<PropertyInfo> m_properties = new ArrayList<PropertyInfo>();
+ protected final HashMap<String, PropertyInfo> m_propertyMap = new HashMap<String, PropertyInfo>();
+
+ protected com.sun.star.lang.Locale m_locale = new com.sun.star.lang.Locale();
+ protected final ResourceManager resourceManager;
+
+ public BaseNLPSolver(XComponentContext xContext, String name) {
+ m_xContext = xContext;
+ m_name = name;
+
+ m_componentFactory = xContext.getServiceManager();
+ try {
+ Object toolkit = m_componentFactory.createInstanceWithContext("com.sun.star.awt.Toolkit", xContext);
+ m_xReschedule = (XReschedule) UnoRuntime.queryInterface(XReschedule.class, toolkit);
+ } catch (Exception ex) {
+ Logger.getLogger(BaseNLPSolver.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ resourceManager = new ResourceManager(xContext, "com.sun.star.comp.Calc.NLPSolver", "/locale", "NLPSolverCommon");
+
+ registerProperty(m_assumeNonNegative);
+ }
+
+ protected void registerProperty(PropertyInfo property) {
+ m_properties.add(property);
+ m_propertyMap.put(property.getProperty().Name, property);
+ property.localize(resourceManager);
+ }
+
+ // com.sun.star.lang.XLocalizable:
+ public void setLocale(com.sun.star.lang.Locale eLocale)
+ {
+ m_locale = eLocale;
+ }
+
+ public com.sun.star.lang.Locale getLocale()
+ {
+ return m_locale;
+ }
+
+ // com.sun.star.sheet.XSolver:
+
+ protected XSpreadsheetDocument m_document;
+ protected XMultiComponentFactory m_componentFactory;
+ protected XModel m_xModel;
+ protected XReschedule m_xReschedule;
+ protected CellAddress m_objective;
+ protected CellAddress[] m_variables;
+ protected SolverConstraint[] m_constraints;
+ protected ExtSolverConstraint[] m_extConstraints;
+ protected boolean m_maximize;
+
+ protected int m_variableCount;
+ protected int m_constraintCount;
+ protected int m_cellRangeCount;
+ protected XCell m_objectiveCell;
+ protected XCell[] m_variableCells;
+ protected CellRangeAddress[] m_cellRanges;
+ protected XChartDataArray[] m_cellRangeData;
+ protected CellMap[] m_variableMap;
+ protected double[][][] m_variableData;
+
+ protected double m_functionValue;
+ protected double[] m_currentParameters;
+ protected boolean m_success = false;
+
+ public XSpreadsheetDocument getDocument() {
+ return m_document;
+ }
+
+ public void setDocument(XSpreadsheetDocument document) {
+ m_document = document;
+ m_xModel = (XModel) UnoRuntime.queryInterface(XModel.class, m_document);
+ }
+
+ public CellAddress getObjective() {
+ return m_objective;
+ }
+
+ public void setObjective(CellAddress objective) {
+ m_objective = objective;
+ m_objectiveCell = getCell(objective);
+ }
+
+ public CellAddress[] getVariables() {
+ if (m_variables == null)
+ return new CellAddress[0]; //Workaround for basic scripts; otherwise
+ //setting the Variables property fails.
+ return m_variables;
+ }
+
+ protected class RowInfo {
+ protected short Sheet;
+ protected int Row;
+ protected int StartCol;
+ protected int EndCol;
+
+ public RowInfo(short sheet, int row) {
+ Sheet = sheet;
+ Row = row;
+ }
+
+ public CellRangeAddress getCellRangeAddress(int lastRow) {
+ CellRangeAddress result = new CellRangeAddress();
+ result.Sheet = Sheet;
+ result.StartColumn = StartCol;
+ result.StartRow = Row;
+ result.EndColumn = EndCol;
+ result.EndRow = lastRow;
+ return result;
+ }
+ }
+
+ protected class CellMap {
+ protected int Range;
+ protected int Col;
+ protected int Row;
+ }
+
+ protected class ExtSolverConstraint {
+
+ public XCell Left;
+ public SolverConstraintOperator Operator;
+ public XCell Right;
+ public double Data;
+
+ public ExtSolverConstraint(XCell left, SolverConstraintOperator operator, Object right) {
+ this.Left = left;
+ this.Operator = operator;
+ this.Right = null;
+ if (right instanceof Number) {
+ this.Data = ((Number)right).doubleValue();
+ } else if (right instanceof CellAddress) {
+ XCell cell = getCell((CellAddress)right);
+ if (cell.getType() == CellContentType.VALUE) {
+ this.Data = cell.getValue();
+ } else {
+ this.Right = cell;
+ this.Data = 0.0;
+ }
+ }
+ }
+
+ public double getLeftValue() {
+ if (this.Right == null) {
+ return this.Left.getValue();
+ } else {
+ return this.Left.getValue() - this.Right.getValue();
+ }
+ }
+
+ }
+
+ public void setVariables(CellAddress[] variables) {
+ m_variables = variables;
+ m_variableCount = variables.length;
+
+ //update cell references
+ m_variableCells = new XCell[m_variableCount];
+ m_currentParameters = new double[m_variableCount];
+ for (int i = 0; i < m_variableCount; i++) {
+ m_variableCells[i] = getCell(variables[i]);
+ m_currentParameters[i] = m_variableCells[i].getValue();
+ }
+
+ //parse for cell ranges (under the assumption, that the cells are ordered
+ //left to right, top to bottom for each cell range
+ m_variableMap = new CellMap[m_variableCount];
+ m_variableData = new double[m_variableCount][][];
+
+ ArrayList<RowInfo> rows = new ArrayList<RowInfo>();
+ RowInfo currentRow = null;
+ int lastSheet = -1, lastRow = -1;
+ for (int i = 0; i < m_variableCount; i++) {
+ if (lastSheet == m_variables[i].Sheet && lastRow == m_variables[i].Row &&
+ currentRow.EndCol == m_variables[i].Column - 1)
+ currentRow.EndCol++;
+ else {
+ currentRow = new RowInfo(m_variables[i].Sheet, m_variables[i].Row);
+ currentRow.StartCol = m_variables[i].Column;
+ currentRow.EndCol = m_variables[i].Column;
+ rows.add(currentRow);
+ lastSheet = currentRow.Sheet;
+ lastRow = currentRow.Row;
+ }
+ }
+
+ ArrayList<CellRangeAddress> cellRangeAddresses = new ArrayList<CellRangeAddress>();
+ if (rows.size() > 0) {
+ RowInfo firstRow = rows.get(0);
+ int offset = 0;
+ for (int i = 1; i < rows.size(); i++) {
+ currentRow = rows.get(i);
+ if (currentRow.Sheet != firstRow.Sheet ||
+ currentRow.Row != firstRow.Row + offset + 1 ||
+ currentRow.StartCol != firstRow.StartCol ||
+ currentRow.EndCol != firstRow.EndCol) {
+ cellRangeAddresses.add(firstRow.getCellRangeAddress(firstRow.Row + offset));
+ firstRow = currentRow;
+ offset = 0;
+ } else {
+ offset++;
+ }
+ }
+ cellRangeAddresses.add(firstRow.getCellRangeAddress(firstRow.Row + offset));
+ }
+
+ m_cellRangeCount = cellRangeAddresses.size();
+ m_cellRanges = new CellRangeAddress[m_cellRangeCount];
+ m_cellRanges = cellRangeAddresses.toArray(m_cellRanges);
+ m_cellRangeData = new XChartDataArray[m_cellRangeCount];
+ int varID = 0;
+ //get cell range data and map the variables to their new location
+ for (int i = 0; i < m_cellRangeCount; i++) {
+ for (int y = 0; y <= m_cellRanges[i].EndRow - m_cellRanges[i].StartRow; y++)
+ for (int x = 0; x <= m_cellRanges[i].EndColumn - m_cellRanges[i].StartColumn; x++) {
+ CellMap map = new CellMap();
+ m_variableMap[varID++] = map;
+ map.Range = i;
+ map.Col = x;
+ map.Row = y;
+ }
+ m_cellRangeData[i] = getChartDataArray(m_cellRanges[i]);
+ m_variableData[i] = m_cellRangeData[i].getData();
+ }
+ }
+
+ public SolverConstraint[] getConstraints() {
+ if (m_constraints == null)
+ return new SolverConstraint[0]; //Workaround for basic scripts; otherwise
+ //setting the Constraints property fails.
+ return m_constraints;
+ }
+
+ public void setConstraints(SolverConstraint[] constraints) {
+ m_constraints = constraints;
+ m_constraintCount = constraints.length;
+
+ //update cell references
+ m_extConstraints = new ExtSolverConstraint[m_constraintCount];
+ for (int i = 0; i < m_constraintCount; i++) {
+ m_extConstraints[i] = new ExtSolverConstraint(
+ getCell(constraints[i].Left),
+ constraints[i].Operator,
+ constraints[i].Right);
+ }
+ }
+
+ public boolean getMaximize() {
+ return m_maximize;
+ }
+
+ public void setMaximize(boolean maximize) {
+ m_maximize = maximize;
+ }
+
+ public boolean getSuccess() {
+ return m_success;
+ }
+
+ public double getResultValue() {
+ return m_functionValue;
+ }
+
+ public double[] getSolution() {
+ return m_currentParameters;
+ }
+
+ protected XCell getCell(CellAddress cellAddress) {
+ return getCell(cellAddress.Column, cellAddress.Row, cellAddress.Sheet);
+ }
+
+ protected XCell getCell(int col, int row, int sheet) {
+ try {
+ XSpreadsheets xSpreadsheets = m_document.getSheets();
+ XIndexAccess xSheetIndex = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
+ XSpreadsheet xSpreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, xSheetIndex.getByIndex(sheet));
+ return xSpreadsheet.getCellByPosition(col, row);
+ } catch (IndexOutOfBoundsException ex) {
+ Logger.getLogger(BaseNLPSolver.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (WrappedTargetException ex) {
+ Logger.getLogger(BaseNLPSolver.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ return null;
+ }
+
+ protected XCellRangeData getCellRangeData(CellRangeAddress cellRangeAddress) {
+ return getCellRangeData(cellRangeAddress.Sheet, cellRangeAddress.StartColumn,
+ cellRangeAddress.StartRow, cellRangeAddress.EndColumn, cellRangeAddress.EndRow);
+ }
+
+ protected XCellRangeData getCellRangeData(int sheet, int startCol, int startRow, int endCol, int endRow) {
+ try {
+ XSpreadsheets xSpreadsheets = m_document.getSheets();
+ XIndexAccess xSheetIndex = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
+ XSpreadsheet xSpreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, xSheetIndex.getByIndex(sheet));
+ return (XCellRangeData) UnoRuntime.queryInterface(XCellRangeData.class, xSpreadsheet.getCellRangeByPosition(startCol, startRow, endCol, endRow));
+ } catch (IndexOutOfBoundsException ex) {
+ Logger.getLogger(BaseNLPSolver.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (WrappedTargetException ex) {
+ Logger.getLogger(BaseNLPSolver.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ return null;
+ }
+
+ protected XChartDataArray getChartDataArray(CellRangeAddress cellRangeAddress) {
+ return getChartDataArray(cellRangeAddress.Sheet, cellRangeAddress.StartColumn,
+ cellRangeAddress.StartRow, cellRangeAddress.EndColumn, cellRangeAddress.EndRow);
+ }
+
+ protected XChartDataArray getChartDataArray(int sheet, int startCol, int startRow, int endCol, int endRow) {
+ try {
+ XSpreadsheets xSpreadsheets = m_document.getSheets();
+ XIndexAccess xSheetIndex = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
+ XSpreadsheet xSpreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, xSheetIndex.getByIndex(sheet));
+ return (XChartDataArray) UnoRuntime.queryInterface(XChartDataArray.class, xSpreadsheet.getCellRangeByPosition(startCol, startRow, endCol, endRow));
+ } catch (IndexOutOfBoundsException ex) {
+ Logger.getLogger(BaseNLPSolver.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (WrappedTargetException ex) {
+ Logger.getLogger(BaseNLPSolver.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ return null;
+ }
+
+ protected PropertyInfo<Boolean> m_assumeNonNegative = new PropertyInfo<Boolean>("AssumeNonNegative", false, "Assume Non-Negative Variables");
+
+ protected void initializeSolve() {
+ lockDocument();
+ }
+
+ protected void finalizeSolve() {
+ unlockDocument();
+ }
+
+ public String getComponentDescription() {
+ return m_name;
+ }
+
+ public String getStatusDescription() {
+ return "";
+ }
+
+ public String getPropertyDescription(String property) {
+ PropertyInfo propertyInfo = m_propertyMap.get(property);
+ if (propertyInfo != null)
+ return propertyInfo.getDescription();
+ else
+ return "";
+ }
+
+ // com.sun.star.beans.XPropertySet:
+
+ public XPropertySetInfo getPropertySetInfo() {
+ return this;
+ }
+
+ public void setPropertyValue(String property, Object value) throws UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException {
+ PropertyInfo propertyInfo = m_propertyMap.get(property);
+ if (propertyInfo != null)
+ propertyInfo.setValue(value);
+ else
+ throw new UnknownPropertyException();
+ }
+
+ public Object getPropertyValue(String property) throws UnknownPropertyException, WrappedTargetException {
+ PropertyInfo propertyInfo = m_propertyMap.get(property);
+ if (propertyInfo != null)
+ return propertyInfo.getValue();
+ else
+ throw new UnknownPropertyException();
+ }
+
+ public void addPropertyChangeListener(String property, XPropertyChangeListener listener) throws UnknownPropertyException, WrappedTargetException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void removePropertyChangeListener(String property, XPropertyChangeListener listener) throws UnknownPropertyException, WrappedTargetException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void addVetoableChangeListener(String property, XVetoableChangeListener listener) throws UnknownPropertyException, WrappedTargetException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void removeVetoableChangeListener(String property, XVetoableChangeListener listener) throws UnknownPropertyException, WrappedTargetException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ // com.sun.star.beans.XPropertySetInfo:
+
+ public Property[] getProperties() {
+ int propertyCount = m_properties.size();
+ Property[] properties = new Property[propertyCount];
+ for (int i = 0; i < propertyCount; i++)
+ properties[i] = m_properties.get(i).getProperty();
+ return properties;
+ }
+
+ public Property getPropertyByName(String property) throws UnknownPropertyException {
+ PropertyInfo propertyInfo = m_propertyMap.get(property);
+ if (propertyInfo != null)
+ return propertyInfo.getProperty();
+ else
+ throw new UnknownPropertyException();
+ }
+
+ public boolean hasPropertyByName(String property) {
+ return m_properties.contains(property);
+ }
+
+ // <editor-fold defaultstate="collapsed" desc="Helper functions">
+ protected void lockDocument(boolean lock) {
+ if (lock)
+ m_xModel.lockControllers();
+ else
+ m_xModel.unlockControllers();
+
+ try {
+ XIndexAccess xSpreadsheets = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, m_document.getSheets());
+ int sheets = xSpreadsheets.getCount();
+ for (int i = 0; i < sheets; i++) {
+ Object sheet = xSpreadsheets.getByIndex(i);
+ XTableChartsSupplier xTableChartsSupplier = (XTableChartsSupplier) UnoRuntime.queryInterface(XTableChartsSupplier.class, sheet);
+ XIndexAccess xCharts = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTableChartsSupplier.getCharts());
+ int charts = xCharts.getCount();
+ for (int j = 0; j < charts; j++) {
+ Object chart = xCharts.getByIndex(j);
+ XEmbeddedObjectSupplier xChartObjects = (XEmbeddedObjectSupplier) UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class, chart);
+ XModel xChartModel = (XModel) UnoRuntime.queryInterface(XModel.class, xChartObjects.getEmbeddedObject());
+ if (lock)
+ xChartModel.lockControllers();
+ else
+ xChartModel.unlockControllers();
+ }
+ }
+ } catch (Exception ex) {
+ Logger.getLogger(BaseNLPSolver.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ protected void lockDocument() {
+ lockDocument(true);
+ }
+
+ protected void unlockDocument() {
+ lockDocument(false);
+ }
+
+ public static String nanoTimeToString(ResourceManager resourceManager, long nanoseconds) {
+ if (nanoseconds < 0) return null; //shouldn't happen .... but if it does, throw an error!
+
+ if (nanoseconds == 0) return "0";
+
+ if (nanoseconds < 1000)
+ return nanoseconds + " " + resourceManager.getLocalizedString("Time.Nanoseconds", "Nanoseconds");
+
+ double microseconds = (double) nanoseconds / 1000;
+ if (microseconds < 1000)
+ return String.format("%.2f %s", microseconds, resourceManager.getLocalizedString("Time.Microseconds", "Microseconds"));
+
+ double milliseconds = microseconds / 1000;
+ if (milliseconds < 1000)
+ return String.format("%.2f %s", milliseconds, resourceManager.getLocalizedString("Time.Milliseconds", "Milliseconds"));
+
+ double seconds = milliseconds / 1000;
+ if (seconds < 90)
+ return String.format("%.2f %s", seconds, resourceManager.getLocalizedString("Time.Seconds", "Seconds"));
+
+ long minutes = (long) seconds / 60;
+ seconds -= minutes * 60;
+ long hours = minutes / 60;
+ minutes -= hours * 60;
+ long days = hours / 24;
+ hours -= days * 24;
+
+ if (days > 0)
+ return String.format("%d %s, %d %s",
+ days, resourceManager.getLocalizedString(String.format("Time.Day%", days == 1 ? "" : "s"), "Days"),
+ hours, resourceManager.getLocalizedString(String.format("Time.Hour%s", hours == 1 ? "" : "s"), "Hours"));
+
+ if (hours > 0)
+ return String.format("%d %s, %d %s",
+ hours, resourceManager.getLocalizedString(String.format("Time.Hour%s", hours == 1 ? "" : "s"), "Hours"),
+ minutes, resourceManager.getLocalizedString(String.format("Time.Minute%s", minutes == 1 ? "" : "s"), "Minutes"));
+
+ if (minutes > 0)
+ return String.format("%d %s, %.0f %s",
+ minutes, resourceManager.getLocalizedString(String.format("Time.Minute%s", minutes == 1 ? "" : "s"), "Minutes"),
+ Math.floor(seconds), resourceManager.getLocalizedString(String.format("Time.Second%s", Math.floor(seconds) == 1 ? "" : "s"), "Seconds"));
+
+ return String.format("%.2f %s", seconds, resourceManager.getLocalizedString("Time.Seconds", "Seconds"));
+ }
+ // </editor-fold>
+
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/CentralRegistrationClass.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/CentralRegistrationClass.java
new file mode 100755
index 000000000000..0d9fb029b0f5
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/CentralRegistrationClass.java
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: CentralRegistrationClass.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver;
+
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.registry.XRegistryKey;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+/**
+ *
+ * @author as231978
+ */
+public class CentralRegistrationClass {
+
+ public static XSingleComponentFactory __getComponentFactory( String sImplementationName ) {
+ String regClassesList = getRegistrationClasses();
+ StringTokenizer t = new StringTokenizer(regClassesList, " ");
+ while (t.hasMoreTokens()) {
+ String className = t.nextToken();
+ if (className != null && className.length() != 0) {
+ try {
+ Class regClass = Class.forName(className);
+ Method writeRegInfo = regClass.getDeclaredMethod("__getComponentFactory", new Class[]{String.class});
+ Object result = writeRegInfo.invoke(regClass, sImplementationName);
+ if (result != null) {
+ return (XSingleComponentFactory)result;
+ }
+ }
+ catch (ClassNotFoundException ex) {
+ ex.printStackTrace();
+ } catch (ClassCastException ex) {
+ ex.printStackTrace();
+ } catch (SecurityException ex) {
+ ex.printStackTrace();
+ } catch (NoSuchMethodException ex) {
+ ex.printStackTrace();
+ } catch (IllegalArgumentException ex) {
+ ex.printStackTrace();
+ } catch (InvocationTargetException ex) {
+ ex.printStackTrace();
+ } catch (IllegalAccessException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ return null;
+ }
+
+ public static boolean __writeRegistryServiceInfo( XRegistryKey xRegistryKey ) {
+ boolean bResult = true;
+ String regClassesList = getRegistrationClasses();
+ StringTokenizer t = new StringTokenizer(regClassesList, " ");
+ while (t.hasMoreTokens()) {
+ String className = t.nextToken();
+ if (className != null && className.length() != 0) {
+ try {
+ Class regClass = Class.forName(className);
+ Method writeRegInfo = regClass.getDeclaredMethod("__writeRegistryServiceInfo", new Class[]{XRegistryKey.class});
+ Object result = writeRegInfo.invoke(regClass, xRegistryKey);
+ bResult &= ((Boolean)result).booleanValue();
+ }
+ catch (ClassNotFoundException ex) {
+ ex.printStackTrace();
+ } catch (ClassCastException ex) {
+ ex.printStackTrace();
+ } catch (SecurityException ex) {
+ ex.printStackTrace();
+ } catch (NoSuchMethodException ex) {
+ ex.printStackTrace();
+ } catch (IllegalArgumentException ex) {
+ ex.printStackTrace();
+ } catch (InvocationTargetException ex) {
+ ex.printStackTrace();
+ } catch (IllegalAccessException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ return bResult;
+ }
+
+ private static String getRegistrationClasses() {
+ CentralRegistrationClass c = new CentralRegistrationClass();
+ String name = c.getClass().getCanonicalName().replace('.', '/').concat(".class");
+ try {
+ Enumeration<URL> urlEnum = c.getClass().getClassLoader().getResources("META-INF/MANIFEST.MF");
+ while (urlEnum.hasMoreElements()) {
+ URL url = urlEnum.nextElement();
+ String file = url.getFile();
+ JarURLConnection jarConnection =
+ (JarURLConnection) url.openConnection();
+ Manifest mf = jarConnection.getManifest();
+
+ Attributes attrs = (Attributes) mf.getAttributes(name);
+ if ( attrs != null ) {
+ String classes = attrs.getValue( "RegistrationClasses" );
+ return classes;
+ }
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+
+ return "";
+ }
+
+ /** Creates a new instance of CentralRegistrationClass */
+ private CentralRegistrationClass() {
+ }
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
new file mode 100755
index 000000000000..c3a0de2fd294
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
@@ -0,0 +1,215 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: DEPSSolverImpl.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver;
+
+import com.sun.star.comp.Calc.NLPSolver.dialogs.IEvolutionarySolverStatusDialog;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lib.uno.helper.Factory;
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.registry.XRegistryKey;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import net.adaptivebox.deps.DEPSAgent;
+import net.adaptivebox.deps.behavior.DEGTBehavior;
+import net.adaptivebox.deps.behavior.PSGTBehavior;
+import net.adaptivebox.global.IUpdateCycleEngine;
+import net.adaptivebox.knowledge.ILibEngine;
+import net.adaptivebox.knowledge.Library;
+import net.adaptivebox.knowledge.SearchPoint;
+
+
+public final class DEPSSolverImpl extends BaseEvolutionarySolver
+ implements com.sun.star.lang.XServiceInfo
+{
+ private static final String m_implementationName = DEPSSolverImpl.class.getName();
+ private static final String[] m_serviceNames = {
+ "com.sun.star.sheet.Solver",
+ "com.sun.star.beans.PropertySet"
+ };
+
+ public DEPSSolverImpl( XComponentContext context )
+ {
+ super(context, "DEPS Evolutionary Algorithm");
+
+ registerProperty(m_agentSwitchRate);
+ registerProperty(m_factor);
+ registerProperty(m_CR);
+ registerProperty(m_c1);
+ registerProperty(m_c2);
+ registerProperty(m_weight);
+ registerProperty(m_CL);
+ }
+
+ public static XSingleComponentFactory __getComponentFactory( String sImplementationName ) {
+ XSingleComponentFactory xFactory = null;
+
+ if ( sImplementationName.equals( m_implementationName ) )
+ xFactory = Factory.createComponentFactory(DEPSSolverImpl.class, m_serviceNames);
+ return xFactory;
+ }
+
+ public static boolean __writeRegistryServiceInfo( XRegistryKey xRegistryKey ) {
+ return Factory.writeRegistryServiceInfo(m_implementationName,
+ m_serviceNames,
+ xRegistryKey);
+ }
+
+ // com.sun.star.lang.XServiceInfo:
+ public String getImplementationName() {
+ return m_implementationName;
+ }
+
+ public boolean supportsService( String sService ) {
+ int len = m_serviceNames.length;
+
+ for( int i=0; i < len; i++) {
+ if (sService.equals(m_serviceNames[i]))
+ return true;
+ }
+ return false;
+ }
+
+ public String[] getSupportedServiceNames() {
+ return m_serviceNames;
+ }
+
+ // com.sun.star.sheet.XSolver:
+ private DEPSAgent[] m_agents;
+
+ private PropertyInfo<Double> m_agentSwitchRate = new PropertyInfo<Double>("AgentSwitchRate", 0.5, "Agent Switch Rate (DE Probability)");
+ // --DE
+ private PropertyInfo<Double> m_factor = new PropertyInfo<Double>("DEFactor", 0.5, "DE: Scaling Factor (0-1.2)");
+ private PropertyInfo<Double> m_CR = new PropertyInfo<Double>("DECR", 0.9, "DE: Crossover Probability (0-1)");
+ // --PS
+ private PropertyInfo<Double> m_c1 = new PropertyInfo<Double>("PSC1", 1.494, "PS: Cognitive Constant");
+ private PropertyInfo<Double> m_c2 = new PropertyInfo<Double>("PSC2", 1.494, "PS: Social Constant");
+ private PropertyInfo<Double> m_weight = new PropertyInfo<Double>("PSWeight", 0.729, "PS: Constriction Coefficient");
+ private PropertyInfo<Double> m_CL = new PropertyInfo<Double>("PSCL", 0.0, "PS: Mutation Probability (0-0.005)");
+
+ public void solve() {
+ try {
+ m_librarySize.setValue(m_swarmSize.getValue()); //DEPS' library is as large as the swarm
+ } catch (IllegalArgumentException ex) {
+ Logger.getLogger(DEPSSolverImpl.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ initializeSolve();
+
+ //Init:
+ m_agents = new DEPSAgent[m_swarmSize.getValue()];
+ for (int i = 0; i < m_swarmSize.getValue(); i++) {
+ m_agents[i] = new DEPSAgent();
+ m_agents[i].setProblemEncoder(m_problemEncoder);
+ m_agents[i].setPbest(m_library.getSelectedPoint(i));
+
+ DEGTBehavior deGTBehavior = new DEGTBehavior();
+ deGTBehavior.FACTOR = m_factor.getValue();
+ deGTBehavior.CR = m_CR.getValue();
+
+ PSGTBehavior psGTBehavior = new PSGTBehavior();
+ psGTBehavior.c1 = m_c1.getValue();
+ psGTBehavior.c2 = m_c2.getValue();
+ psGTBehavior.CL = m_CL.getValue();
+ psGTBehavior.weight = m_weight.getValue();
+
+ m_agents[i].switchP = m_agentSwitchRate.getValue();
+ m_agents[i].setGTBehavior(deGTBehavior);
+ m_agents[i].setGTBehavior(psGTBehavior);
+
+ m_agents[i].setSpecComparator(m_specCompareEngine);
+ if (m_agents[i] instanceof ILibEngine)
+ ((ILibEngine)m_agents[i]).setLibrary(m_library);
+ }
+
+ //Learn:
+ m_solverStatusDialog.setVisible(true);
+ m_solverStatusDialog.setMaxIterations(m_learningCycles.getValue());
+ m_solverStatusDialog.setMaxStagnation(m_required.getValue());
+ int learningCycle = 1;
+ long runtime = 0;
+ do {
+ long startTime = System.nanoTime();
+
+ if (learningCycle >= m_learningCycles.getValue())
+ learningCycle = 1;
+
+ if (m_solverStatusDialog.getUserState() == IEvolutionarySolverStatusDialog.CONTINUE)
+ lockDocument();
+
+ m_toleratedCount = 0;
+ m_toleratedMin = -1.0 * m_tolerance.getValue();
+ m_toleratedMax = m_tolerance.getValue();
+ for (; learningCycle <= m_learningCycles.getValue() &&
+ m_toleratedCount < m_required.getValue() &&
+ m_solverStatusDialog.getUserState() != IEvolutionarySolverStatusDialog.CANCEL; learningCycle++) {
+ m_library.refreshGbest(m_specCompareEngine);
+
+ for (int i = 0; i < m_swarmSize.getValue(); i++)
+ m_agents[i].generatePoint();
+
+ for (int i = 0; i < m_swarmSize.getValue(); i++)
+ m_agents[i].learn();
+
+ for (int i = 0; i < m_swarmSize.getValue(); i++) {
+ SearchPoint agentPoint = m_agents[i].getMGState();
+ boolean inRange = (agentPoint.getObjectiveValue() >= m_toleratedMin && agentPoint.getObjectiveValue() <= m_toleratedMax);
+ if (Library.replace(m_envCompareEngine, agentPoint, m_totalBestPoint)) {
+ m_solverStatusDialog.setBestSolution(m_totalBestPoint.getObjectiveValue(), m_totalBestPoint.isFeasible());
+ if (!inRange) {
+ m_toleratedMin = agentPoint.getObjectiveValue() - m_tolerance.getValue();
+ m_toleratedMax = agentPoint.getObjectiveValue() + m_tolerance.getValue();
+ m_toleratedCount = 0;
+ }
+ }
+ }
+
+ if (m_specCompareEngine instanceof IUpdateCycleEngine)
+ ((IUpdateCycleEngine)m_specCompareEngine).updateCycle(learningCycle);
+
+ m_solverStatusDialog.setIteration(learningCycle);
+ m_solverStatusDialog.setStagnation(m_toleratedCount);
+ m_solverStatusDialog.setRuntime(runtime + (System.nanoTime() - startTime));
+ m_xReschedule.reschedule();
+ }
+
+ applySolution(); //show the current solution
+ unlockDocument(); //allow the solution to be displayed
+
+ runtime += (System.nanoTime() - startTime);
+ m_solverStatusDialog.setRuntime(runtime);
+ } while (m_solverStatusDialog.waitForUser() == IEvolutionarySolverStatusDialog.CONTINUE);
+
+ lockDocument();
+
+ finalizeSolve();
+ }
+
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java
new file mode 100755
index 000000000000..a32cb3988418
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: PropertyInfo.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver;
+
+import com.sun.star.beans.Property;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.uno.Type;
+
+/**
+ *
+ * @author Andreas Schneider
+ */
+public class PropertyInfo<PropType> {
+
+ private Property m_property;
+ private PropType m_value;
+ private String m_description;
+
+ public Property getProperty() {
+ return m_property;
+ }
+
+ public PropType getValue() {
+ return m_value;
+ }
+
+ public String getDescription() {
+ return m_description;
+ }
+
+ public void setValue(Object value) throws IllegalArgumentException {
+ if (m_property.Type == Type.LONG) {
+ if (!(value instanceof Integer))
+ throw new IllegalArgumentException();
+ m_value = (PropType)value;
+ } else if (m_property.Type == Type.DOUBLE) {
+ if (!(value instanceof Double))
+ throw new IllegalArgumentException();
+ m_value = (PropType)value;
+ } else if (m_property.Type == Type.BOOLEAN) {
+ if (!(value instanceof Boolean))
+ throw new IllegalArgumentException();
+ m_value = (PropType)value;
+ }
+ }
+
+ public PropertyInfo(String name, PropType value, String description) {
+ this(name, value, (short)0, description);
+ }
+
+ public PropertyInfo(String name, PropType value, short attributes,
+ String description) {
+ m_property = new Property();
+ m_property.Name = name;
+ m_property.Attributes = attributes;
+ m_property.Handle = -1;
+
+ if (value instanceof Integer)
+ m_property.Type = Type.LONG;
+ else if (value instanceof Double)
+ m_property.Type = Type.DOUBLE;
+ else if (value instanceof Boolean)
+ m_property.Type = Type.BOOLEAN;
+
+ m_value = value;
+ m_description = description;
+ }
+
+ public void localize(ResourceManager resourceManager) {
+ try {
+ m_description = resourceManager.getLocalizedString("Properties." + m_property.Name);
+ } catch (com.sun.star.resource.MissingResourceException ex) {
+
+ }
+ }
+
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/ResourceManager.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/ResourceManager.java
new file mode 100755
index 000000000000..6bf1031bd4cd
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/ResourceManager.java
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ResourceManager.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver;
+
+import com.sun.star.beans.PropertyState;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.deployment.PackageInformationProvider;
+import com.sun.star.deployment.XPackageInformationProvider;
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.resource.StringResourceWithLocation;
+import com.sun.star.resource.XStringResourceWithLocation;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+
+public class ResourceManager {
+
+ private final XComponentContext m_context;
+ private final String m_oxtRoot;
+ private final String m_resourceBaseUrl;
+ private final String m_resourceBasename;
+ private XStringResourceWithLocation m_xStrResource;
+ private Locale m_locale;
+
+ public ResourceManager(XComponentContext xContext, String oxtId, String relativeResourceBaseUrl, String resourceBasename) {
+ m_context = xContext;
+ m_resourceBasename = resourceBasename;
+
+ XPackageInformationProvider xPkgInfo = PackageInformationProvider.get(m_context);
+ m_oxtRoot = xPkgInfo.getPackageLocation(oxtId);
+ m_resourceBaseUrl = m_oxtRoot + relativeResourceBaseUrl;
+
+ try {
+ XMultiServiceFactory xConfig = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class,
+ m_context.getServiceManager().createInstanceWithContext("com.sun.star.configuration.ConfigurationProvider", m_context));
+
+ Object[] args = new Object[1];
+ args[0] = new PropertyValue("nodepath", 0, "/org.openoffice.Setup/L10N", PropertyState.DIRECT_VALUE);
+ XPropertySet xConfigProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,
+ xConfig.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", args));
+ String[] locale = AnyConverter.toString(xConfigProps.getPropertyValue("ooLocale")).split("-");
+ String lang = locale[0];
+ String country = (locale.length >= 2 ? locale[1] : "");
+ String variant = (locale.length >= 3 ? locale[2] : "");
+ m_locale = new Locale(lang, country, variant);
+
+ m_xStrResource = StringResourceWithLocation.create(m_context, m_resourceBaseUrl, true, m_locale, m_resourceBasename, "", null);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ /* This implementation is used if the presence of the key will be handled
+ * "outside" (i.e. by catching the appropriate MissingResourceException). */
+ public String getLocalizedString(String key) throws com.sun.star.resource.MissingResourceException {
+ return m_xStrResource.resolveString(m_resourceBasename + "." + key);
+ }
+
+ /* This implementation on the other hand handles the exception by itself
+ * and returns a (predefined) default value if necessary. */
+ public String getLocalizedString(String key, String defaultValue) {
+ try {
+ return m_xStrResource.resolveString(m_resourceBasename + "." + key);
+ } catch (com.sun.star.resource.MissingResourceException ex) {
+ return defaultValue;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/SCOSolverImpl.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/SCOSolverImpl.java
new file mode 100755
index 000000000000..ca32f7a92bab
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/SCOSolverImpl.java
@@ -0,0 +1,169 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: SCOSolverImpl.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver;
+
+import com.sun.star.comp.Calc.NLPSolver.dialogs.IEvolutionarySolverStatusDialog;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lib.uno.helper.Factory;
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.registry.XRegistryKey;
+import net.adaptivebox.sco.SCAgent;
+import net.adaptivebox.global.IUpdateCycleEngine;
+import net.adaptivebox.knowledge.Library;
+import net.adaptivebox.knowledge.SearchPoint;
+
+
+public final class SCOSolverImpl extends BaseEvolutionarySolver
+ implements com.sun.star.lang.XServiceInfo
+{
+ private static final String m_implementationName = SCOSolverImpl.class.getName();
+ private static final String[] m_serviceNames = {
+ "com.sun.star.sheet.Solver",
+ "com.sun.star.beans.PropertySet"
+ };
+
+ public SCOSolverImpl( XComponentContext context )
+ {
+ super(context, "SCO Evolutionary Algorithm");
+
+ registerProperty(m_librarySize); //SCO allows the user to specify the size of the library
+ }
+
+ public static XSingleComponentFactory __getComponentFactory( String sImplementationName ) {
+ XSingleComponentFactory xFactory = null;
+
+ if ( sImplementationName.equals( m_implementationName ) )
+ xFactory = Factory.createComponentFactory(SCOSolverImpl.class, m_serviceNames);
+ return xFactory;
+ }
+
+ public static boolean __writeRegistryServiceInfo( XRegistryKey xRegistryKey ) {
+ return Factory.writeRegistryServiceInfo(m_implementationName,
+ m_serviceNames,
+ xRegistryKey);
+ }
+
+ // com.sun.star.lang.XServiceInfo:
+ public String getImplementationName() {
+ return m_implementationName;
+ }
+
+ public boolean supportsService( String sService ) {
+ int len = m_serviceNames.length;
+
+ for( int i=0; i < len; i++) {
+ if (sService.equals(m_serviceNames[i]))
+ return true;
+ }
+ return false;
+ }
+
+ public String[] getSupportedServiceNames() {
+ return m_serviceNames;
+ }
+
+ // com.sun.star.sheet.XSolver:
+
+ private SCAgent[] m_agents;
+
+ public void solve() {
+ initializeSolve();
+
+ //Init:
+ int swarmSize = m_swarmSize.getValue();
+ m_agents = new SCAgent[swarmSize];
+ for (int i = 0; i < swarmSize; i++) {
+ m_agents[i] = new SCAgent();
+ m_agents[i].setProblemEncoder(m_problemEncoder);
+ m_agents[i].setSpecComparator(m_specCompareEngine);
+ m_agents[i].setExternalLib(m_library);
+ }
+
+ //Learn:
+ m_solverStatusDialog.setVisible(true);
+ int learningCycles = m_learningCycles.getValue();
+ m_solverStatusDialog.setMaxIterations(learningCycles);
+ m_solverStatusDialog.setMaxStagnation(m_required.getValue());
+ int learningCycle = 1;
+ long runtime = 0;
+ do {
+ long startTime = System.nanoTime();
+
+ if (learningCycle >= m_learningCycles.getValue())
+ learningCycle = 1;
+
+ if (m_solverStatusDialog.getUserState() == IEvolutionarySolverStatusDialog.CONTINUE)
+ lockDocument();
+
+ m_toleratedCount = 0;
+ m_toleratedMin = -1.0 * m_tolerance.getValue();
+ m_toleratedMax = m_tolerance.getValue();
+ for (; learningCycle <= learningCycles &&
+ m_toleratedCount < m_required.getValue() &&
+ m_solverStatusDialog.getUserState() != IEvolutionarySolverStatusDialog.CANCEL; learningCycle++) {
+ for (int i = 0; i < swarmSize; i++) {
+ SearchPoint point = m_agents[i].generatePoint();
+ boolean inRange = (point.getObjectiveValue() >= m_toleratedMin && point.getObjectiveValue() <= m_toleratedMax);
+ if (Library.replace(m_envCompareEngine, point, m_totalBestPoint)) {
+ m_solverStatusDialog.setBestSolution(m_totalBestPoint.getObjectiveValue(), m_totalBestPoint.isFeasible());
+ if (!inRange) {
+ m_toleratedMin = point.getObjectiveValue() - m_tolerance.getValue();
+ m_toleratedMax = point.getObjectiveValue() + m_tolerance.getValue();
+ m_toleratedCount = 0;
+ }
+ }
+ }
+
+ for (int i = 0; i < swarmSize; i++)
+ m_agents[i].updateInfo();
+
+ if (m_specCompareEngine instanceof IUpdateCycleEngine)
+ ((IUpdateCycleEngine)m_specCompareEngine).updateCycle(learningCycle);
+
+ m_solverStatusDialog.setIteration(learningCycle);
+ m_solverStatusDialog.setStagnation(m_toleratedCount);
+ m_solverStatusDialog.setRuntime(runtime + (System.nanoTime() - startTime));
+ m_xReschedule.reschedule();
+ }
+
+ applySolution(); //show the current solution
+ unlockDocument(); //allow the solution to be displayed
+
+ runtime += (System.nanoTime() - startTime);
+ m_solverStatusDialog.setRuntime(runtime);
+ } while (m_solverStatusDialog.waitForUser() == IEvolutionarySolverStatusDialog.CONTINUE);
+
+ lockDocument();
+
+ finalizeSolve();
+ }
+
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/BaseDialog.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/BaseDialog.java
new file mode 100755
index 000000000000..8c79bff279a9
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/BaseDialog.java
@@ -0,0 +1,169 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BaseDialog.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver.dialogs;
+
+import com.sun.star.awt.InvalidateStyle;
+import com.sun.star.awt.PosSize;
+import com.sun.star.awt.Rectangle;
+import com.sun.star.comp.Calc.NLPSolver.dialogs.controls.BaseControl;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XWindow;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * The BaseDialog represents the base for all dialogs used within the addon.
+ * It automatically loads the necessary interfaces to access OpenOffice.org dialogs.
+ * @author Andreas Schneider
+ */
+public abstract class BaseDialog extends BaseControl {
+
+ private XMultiComponentFactory xMCF;
+ private Object toolkit;
+ private XMultiServiceFactory xMSF;
+ protected XWindow xWindow;
+ protected XDialog xDialog;
+ protected XWindowPeer xWindowPeer;
+ protected ModalState modalState;
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ public XMultiServiceFactory getMultiServiceFactory() {
+ return xMSF;
+ }
+
+ public XFrame getCurrentFrame() {
+ try {
+ Object oDesktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", context);
+ XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, oDesktop);
+ XComponent xComponent = xDesktop.getCurrentComponent();
+ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent);
+ XController xController = xModel.getCurrentController();
+ return xController.getFrame();
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public Rectangle getWorkspaceDimensions() {
+ return getCurrentFrame().getComponentWindow().getPosSize();
+ }
+
+ public BaseDialog(XComponentContext context, String title, int x, int y, int width, int height) {
+ super(context);
+ modalState = ModalState.Exit;
+ try {
+ xMCF = context.getServiceManager();
+ setUnoModel(xMCF.createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", context));
+ xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, getUnoModel());
+
+ setProperty("Title", title);
+ setPosition(x, y);
+ setSize(width, height);
+
+ unoControl = xMCF.createInstanceWithContext("com.sun.star.awt.UnoControlDialog", context);
+ XControl xControl = (XControl)UnoRuntime.queryInterface(XControl.class, unoControl);
+ XControlModel xControlModel = (XControlModel)UnoRuntime.queryInterface(XControlModel.class, getUnoModel());
+ xControl.setModel(xControlModel);
+
+ toolkit = xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", context);
+ XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, toolkit);
+ xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, unoControl);
+ xWindow.setVisible(false);
+ XWindowPeer xParentWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, getCurrentFrame().getComponentWindow());
+ xControl.createPeer(xToolkit, xParentWindowPeer);
+ xWindowPeer = xControl.getPeer();
+
+ xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, unoControl);
+
+ //center if necessary
+ if (x < 0 || y < 0) {
+ Rectangle workspacePosSize = getWorkspaceDimensions();
+ Rectangle dialogPosSize = xWindow.getPosSize();
+ if (x < 0)
+ dialogPosSize.X = workspacePosSize.X + (workspacePosSize.Width / 2) - (dialogPosSize.Width / 2);
+ if (y < 0)
+ dialogPosSize.Y = workspacePosSize.Y + (workspacePosSize.Height / 2) - (dialogPosSize.Height / 2);
+
+ xWindow.setPosSize(dialogPosSize.X, dialogPosSize.Y,
+ dialogPosSize.Width, dialogPosSize.Height, PosSize.POS);
+ }
+
+ } catch (Exception ex) {
+ Logger.getLogger(BaseDialog.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, unoControl);
+ xComponent.dispose();
+ super.finalize();
+ }
+
+ public ModalState showModal() {
+ xWindow.setVisible(true);
+ xDialog.execute();
+ return modalState;
+ }
+
+ public void close() {
+ xDialog.endExecute();
+ xWindow.setVisible(false);
+ }
+
+ public void setCloseable(boolean closeable) {
+ setProperty("Closeable", new Boolean(closeable));
+ }
+
+ public void repaint() {
+ xWindowPeer.invalidate((short)(InvalidateStyle.CHILDREN /*| InvalidateStyle.NOERASE*/ |
+ InvalidateStyle.UPDATE | InvalidateStyle.TRANSPARENT));
+ }
+
+} \ No newline at end of file
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/DummyEvolutionarySolverStatusDialog.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/DummyEvolutionarySolverStatusDialog.java
new file mode 100755
index 000000000000..cc471d8b382c
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/DummyEvolutionarySolverStatusDialog.java
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: DummyEvolutionarySolverStatusDialog.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver.dialogs;
+
+/**
+ *
+ * @author Andreas Schneider <andreas.schneider@sun.com>
+ */
+public class DummyEvolutionarySolverStatusDialog
+ implements IEvolutionarySolverStatusDialog {
+
+ public int getUserState() {
+ return OK;
+ }
+
+ public void setBestSolution(double solution, boolean feasible) {
+
+ }
+
+ public void setMaxIterations(int maxIterations) {
+
+ }
+
+ public void setMaxStagnation(int maxStagnation) {
+
+ }
+
+ public void setIteration(int iteration) {
+
+ }
+
+ public void setStagnation(int stagnation) {
+
+ }
+
+ public void setRuntime(long runtime) {
+
+ }
+
+ public int waitForUser() {
+ return OK;
+ }
+
+ public void setVisible(boolean visible) {
+
+ }
+
+ public void dispose() {
+
+ }
+
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/EvolutionarySolverStatusUno.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/EvolutionarySolverStatusUno.java
new file mode 100755
index 000000000000..ec11aa971fae
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/EvolutionarySolverStatusUno.java
@@ -0,0 +1,306 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: EvolutionarySolverStatusUno.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver.dialogs;
+
+import com.sun.star.comp.Calc.NLPSolver.BaseNLPSolver;
+import com.sun.star.awt.ActionEvent;
+import com.sun.star.awt.XActionListener;
+import com.sun.star.comp.Calc.NLPSolver.ResourceManager;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XComponent;
+import com.sun.star.style.VerticalAlignment;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.comp.Calc.NLPSolver.dialogs.controls.Button;
+import com.sun.star.comp.Calc.NLPSolver.dialogs.controls.Label;
+import com.sun.star.comp.Calc.NLPSolver.dialogs.controls.ProgressBar;
+
+/**
+ *
+ * @author Andreas Schneider <Andreas.Schneider@Sun.COM>
+ */
+public class EvolutionarySolverStatusUno extends BaseDialog
+ implements IEvolutionarySolverStatusDialog,
+ XActionListener {
+
+ private int userState;
+
+ // <editor-fold defaultstate="collapsed" desc="UNO Controls">
+ private Label lblSolution;
+ private Label lblSolutionValue;
+ private Label lblIteration;
+ private ProgressBar pbIteration;
+ private Label lblIterationValue;
+ private Label lblStagnation;
+ private ProgressBar pbStagnation;
+ private Label lblStagnationValue;
+ private Label lblRuntime;
+ private Label lblRuntimeValue;
+ private Button btnStop;
+ private Button btnOK;
+ private Button btnContinue;
+ // </editor-fold>
+ private int defaultTextColor;
+ private int maxIterations;
+ private int maxStagnation;
+
+ private final ResourceManager resourceManager;
+
+ private final int COLOR_RED = 0xFF0000;
+
+ public EvolutionarySolverStatusUno(XComponentContext xContext) {
+ super(xContext, "Solver Status", -1, -1, 170, 95); //center the dialog on the parent
+
+ setCloseable(false);
+ userState = IEvolutionarySolverStatusDialog.OK;
+
+ resourceManager = new ResourceManager(xContext, "com.sun.star.comp.Calc.NLPSolver", "/locale", "NLPSolverStatusDialog");
+
+ try {
+ setProperty("Title", resourceManager.getLocalizedString("Dialog.Caption"));
+ } catch (com.sun.star.resource.MissingResourceException ex) {} //leave the title as it is
+
+ // <editor-fold defaultstate="collapsed" desc="Create UNO Controls">
+ int y = 5;
+ lblSolution = new Label(this, "lblSolution");
+ lblSolution.setPosition(5, y);
+ lblSolution.setSize(60, 10);
+ lblSolution.setLabel(resourceManager.getLocalizedString("Controls.lblSolution", "Current Solution:"));
+ lblSolution.setParentControl(this);
+
+ lblSolutionValue = new Label(this, "lblSolutionValue");
+ lblSolutionValue.setPosition(65, y);
+ lblSolutionValue.setSize(100, 10);
+ lblSolutionValue.setParentControl(this);
+ defaultTextColor = lblSolutionValue.getTextColor();
+ y += 15;
+
+ lblIteration = new Label(this, "lblIteration");
+ lblIteration.setPosition(5, y);
+ lblIteration.setSize(60, 15);
+ lblIteration.setLabel(resourceManager.getLocalizedString("Controls.lblIteration", "Iteration:"));
+ lblIteration.setVerticalAlign(VerticalAlignment.MIDDLE);
+ lblIteration.setParentControl(this);
+
+ pbIteration = new ProgressBar(this, "pbIteration");
+ pbIteration.setPosition(65, y);
+ pbIteration.setSize(100, 15);
+ pbIteration.setParentControl(this);
+
+ lblIterationValue = new Label(this, "lblIterationValue");
+ lblIterationValue.setPosition(65, y);
+ lblIterationValue.setSize(100, 20);
+ lblIterationValue.setVerticalAlign(VerticalAlignment.MIDDLE);
+ lblIterationValue.setMultiLine(true);
+ lblIterationValue.setParentControl(this);
+ lblIterationValue.setVisible(false);
+ y += 20;
+
+ lblStagnation = new Label(this, "lblStagnation");
+ lblStagnation.setPosition(5, y);
+ lblStagnation.setSize(60, 15);
+ lblStagnation.setLabel(resourceManager.getLocalizedString("Controls.lblStagnation", "Stagnation:"));
+ lblStagnation.setVerticalAlign(VerticalAlignment.MIDDLE);
+ lblStagnation.setParentControl(this);
+
+ pbStagnation = new ProgressBar(this, "pbStagnation");
+ pbStagnation.setPosition(65, y);
+ pbStagnation.setSize(100, 15);
+ pbStagnation.setParentControl(this);
+
+ lblStagnationValue = new Label(this, "lblStagnationValue");
+ lblStagnationValue.setPosition(65, y);
+ lblStagnationValue.setSize(100, 20);
+ lblStagnationValue.setVerticalAlign(VerticalAlignment.MIDDLE);
+ lblStagnationValue.setMultiLine(true);
+ lblStagnationValue.setParentControl(this);
+ lblStagnationValue.setVisible(false);
+ y+= 20;
+
+ lblRuntime = new Label(this, "lblRuntime");
+ lblRuntime.setPosition(5, y);
+ lblRuntime.setSize(60, 10);
+ lblRuntime.setLabel(resourceManager.getLocalizedString("Controls.lblRuntime", "Runtime:"));
+ lblRuntime.setParentControl(this);
+
+ lblRuntimeValue = new Label(this, "lblRuntimeValue");
+ lblRuntimeValue.setPosition(65, y);
+ lblRuntimeValue.setSize(100, 10);
+ lblRuntimeValue.setParentControl(this);
+ y += 15;
+
+ btnStop = new Button(this, "btnStop");
+ btnStop.setPosition(5, y);
+ btnStop.setSize(45, 15);
+ btnStop.setLabel(resourceManager.getLocalizedString("Controls.btnStop", "Stop"));
+ btnStop.setParentControl(this);
+ btnStop.addActionListener(this);
+ btnStop.setActionCommand("btnStopClick");
+
+ btnOK = new Button(this, "btnOK");
+ btnOK.setPosition(65, y);
+ btnOK.setSize(40, 15);
+ btnOK.setLabel(resourceManager.getLocalizedString("Controls.btnOK", "OK"));
+ btnOK.setParentControl(this);
+ btnOK.addActionListener(this);
+ btnOK.setActionCommand("btnOKClick");
+ btnOK.setEnabled(false);
+
+ btnContinue = new Button(this, "btnContinue");
+ btnContinue.setPosition(110, y);
+ btnContinue.setSize(55, 15);
+ btnContinue.setLabel(resourceManager.getLocalizedString("Controls.btnContinue", "Continue"));
+ btnContinue.setParentControl(this);
+ btnContinue.addActionListener(this);
+ btnContinue.setActionCommand("btnContinueClick");
+ btnContinue.setEnabled(false);
+ y += 15;
+ // </editor-fold>
+ }
+
+ public int getUserState() {
+ return userState;
+ }
+
+ public void setBestSolution(double solution, boolean feasible) {
+ lblSolutionValue.setLabel(String.format("%.2f", solution));
+ if (feasible)
+ lblSolutionValue.setTextColor(defaultTextColor);
+ else
+ lblSolutionValue.setTextColor(COLOR_RED); //red
+ }
+
+ public void setMaxIterations(int maxIterations) {
+ pbIteration.setRange(0, maxIterations);
+ this.maxIterations = maxIterations;
+ }
+
+ public void setMaxStagnation(int maxStagnation) {
+ pbStagnation.setRange(0, maxStagnation);
+ this.maxStagnation = maxStagnation;
+ }
+
+ public void setIteration(int iteration) {
+ pbIteration.setValue(iteration);
+ }
+
+ public void setStagnation(int stagnation) {
+ pbStagnation.setValue(stagnation);
+ }
+
+ public void setRuntime(long runtime) {
+ lblRuntimeValue.setLabel(BaseNLPSolver.nanoTimeToString(resourceManager, runtime));
+ }
+
+ public int waitForUser() {
+ btnStop.setEnabled(false);
+ btnOK.setEnabled(true);
+ btnContinue.setEnabled(true);
+
+ if (pbIteration.getValue() >= maxIterations) {
+ lblIteration.setTextColor(COLOR_RED);
+ if (userState != IEvolutionarySolverStatusDialog.CANCEL)
+ lblStagnationValue.setLabel(
+ resourceManager.getLocalizedString("Message.StopIteration",
+ "Maximum iterations reached."));
+ }
+
+ if (pbStagnation.getValue() >= maxStagnation) {
+ lblStagnation.setTextColor(COLOR_RED);
+ if (userState != IEvolutionarySolverStatusDialog.CANCEL)
+ lblStagnationValue.setLabel(
+ resourceManager.getLocalizedString("Message.StopStagnation",
+ "Process stopped due to stagnation."));
+ }
+
+ lblIterationValue.setLabel(String.format(
+ resourceManager.getLocalizedString("Message.CurrentIteration",
+ "Process stopped at iteration %d of %d."),
+ pbIteration.getValue(), maxIterations));
+ if (userState == IEvolutionarySolverStatusDialog.CANCEL)
+ lblStagnationValue.setLabel(
+ resourceManager.getLocalizedString("Message.StopUser",
+ "Process stopped due to user interruption."));
+
+ pbIteration.setVisible(false);
+ pbStagnation.setVisible(false);
+ lblIterationValue.setVisible(true);
+ lblStagnationValue.setVisible(true);
+
+ repaint();
+
+ userState = IEvolutionarySolverStatusDialog.WAITING;
+ xDialog.execute();
+
+ lblIteration.setTextColor(defaultTextColor);
+ lblStagnation.setTextColor(defaultTextColor);
+
+ lblIterationValue.setVisible(false);
+ lblStagnationValue.setVisible(false);
+ pbIteration.setVisible(true);
+ pbStagnation.setVisible(true);
+
+ btnStop.setEnabled(true);
+ btnOK.setEnabled(false);
+ btnContinue.setEnabled(false);
+
+ return userState;
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ xWindow.setVisible(visible);
+ }
+
+ public void dispose() {
+ XComponent component = (XComponent) UnoRuntime.queryInterface(XComponent.class, xDialog);
+ component.dispose();
+ }
+
+ public void actionPerformed(ActionEvent actionEvent) {
+ if (userState == IEvolutionarySolverStatusDialog.WAITING) {
+ xDialog.endExecute();
+ setVisible(true);
+ }
+
+ if (actionEvent.ActionCommand.equals("btnStopClick"))
+ userState = IEvolutionarySolverStatusDialog.CANCEL;
+ else if (actionEvent.ActionCommand.equals("btnOKClick"))
+ userState = IEvolutionarySolverStatusDialog.OK;
+ else if (actionEvent.ActionCommand.equals("btnContinueClick"))
+ userState = IEvolutionarySolverStatusDialog.CONTINUE;
+ }
+
+ public void disposing(EventObject eventObject) {
+
+ }
+
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/IEvolutionarySolverStatusDialog.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/IEvolutionarySolverStatusDialog.java
new file mode 100755
index 000000000000..63bf7d89ac2a
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/IEvolutionarySolverStatusDialog.java
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: IEvolutionarySolverStatusDialog.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver.dialogs;
+
+/**
+ *
+ * @author Andreas Schneider <Andreas.Schneider@Sun.COM>
+ */
+public interface IEvolutionarySolverStatusDialog {
+ public final static int WAITING = 0;
+ public final static int OK = 1;
+ public final static int CONTINUE = 2;
+ public final static int CANCEL = 3;
+
+ public int getUserState();
+
+ public void setBestSolution(double solution, boolean feasible);
+ public void setMaxIterations(int maxIterations);
+ public void setMaxStagnation(int maxStagnation);
+ public void setIteration(int iteration);
+ public void setStagnation(int stagnation);
+ public void setRuntime(long runtime);
+ public int waitForUser();
+
+ public void setVisible(boolean visible);
+ public void dispose();
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/ModalState.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/ModalState.java
new file mode 100755
index 000000000000..e32016b80a6e
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/ModalState.java
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ModalState.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver.dialogs;
+
+/**
+ * The ModalState is used to represent the state of the dialog when it closes.
+ * "Exit" indicates no significant change (for example when the user presses
+ * Cancel or simply closes the dialog). "OK" indicates for example, that the
+ * user pressed the OK button.
+ * @author Andreas Schneider
+ */
+public enum ModalState {
+ Exit,
+ OK
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/BaseControl.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/BaseControl.java
new file mode 100755
index 000000000000..9faf1fafa59a
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/BaseControl.java
@@ -0,0 +1,154 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BaseControl.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver.dialogs.controls;
+
+import com.sun.star.awt.XControlContainer;
+import com.sun.star.awt.XWindow;
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Andreas Schneider
+ */
+public abstract class BaseControl {
+
+ protected XComponentContext context;
+ private Object unoModel;
+ protected Object unoControl;
+ protected XPropertySet properties;
+ protected BaseControl parentControl;
+
+ public abstract String getName();
+
+ public Object getUnoModel() {
+ return unoModel;
+ }
+
+ /**
+ * This is used <b>internally</b> to update the UnoModel and refresh the
+ * associated PropertySet.
+ * @param unoModel The new UnoModel for this control.
+ */
+ protected void setUnoModel(Object unoModel) {
+ this.unoModel = unoModel;
+ properties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, unoModel);
+ }
+
+ public Object getUnoControl() {
+ return unoControl;
+ }
+
+ public void setParentControl(BaseControl parentControl) {
+ //TODO : remove from existing parentControl
+ try {
+ String name = getName();
+ XNameContainer nameContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, parentControl.unoModel);
+ nameContainer.insertByName(name, unoModel);
+
+ XControlContainer controlContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class, parentControl.unoControl);
+ unoControl = controlContainer.getControl(name);
+
+ this.parentControl = parentControl;
+ } catch (IllegalArgumentException ex) {
+ Logger.getLogger(BaseControl.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (ElementExistException ex) {
+ Logger.getLogger(BaseControl.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (WrappedTargetException ex) {
+ Logger.getLogger(BaseControl.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ public BaseControl(XComponentContext context) {
+ this.context = context;
+ unoModel = null;
+ unoControl = null;
+ parentControl = null;
+ }
+
+ protected void setProperty(String name, Object value) {
+ try {
+ properties.setPropertyValue(name, value);
+ } catch (UnknownPropertyException ex) {
+ Logger.getLogger(BaseControl.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (PropertyVetoException ex) {
+ Logger.getLogger(BaseControl.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IllegalArgumentException ex) {
+ Logger.getLogger(BaseControl.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (WrappedTargetException ex) {
+ Logger.getLogger(BaseControl.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ protected Object getProperty(String name) {
+ try {
+ return properties.getPropertyValue(name);
+ } catch (UnknownPropertyException ex) {
+ Logger.getLogger(BaseControl.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (WrappedTargetException ex) {
+ Logger.getLogger(BaseControl.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return null;
+ }
+
+ // <editor-fold defaultstate="collapsed" desc="Uno Properties">
+
+ public void setPosition(int x, int y) {
+ setProperty("PositionX", new Integer(x));
+ setProperty("PositionY", new Integer(y));
+ }
+
+ public void setSize(int width, int height) {
+ setProperty("Width", new Integer(width));
+ setProperty("Height", new Integer(height));
+ }
+
+ public void setEnabled(boolean enabled) {
+ setProperty("Enabled", new Boolean(enabled));
+ }
+
+ public void setVisible(boolean visible) {
+ XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, unoControl);
+ xWindow.setVisible(visible);
+ }
+
+ // </editor-fold>
+
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/Button.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/Button.java
new file mode 100755
index 000000000000..ad895ded2539
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/Button.java
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: Button.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver.dialogs.controls;
+
+import com.sun.star.awt.XActionListener;
+import com.sun.star.awt.XButton;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import com.sun.star.comp.Calc.NLPSolver.dialogs.BaseDialog;
+
+/**
+ *
+ * @author Andreas Schneider
+ */
+public class Button extends LabeledControl {
+
+ private String name;
+ private XButton xButton;
+
+ public Button(BaseDialog owner, String name) {
+ super(owner.context);
+ try {
+ setUnoModel(owner.getMultiServiceFactory().createInstance("com.sun.star.awt.UnoControlButtonModel"));
+ this.name = name;
+ setProperty("Name", name);
+ } catch (Exception ex) {
+ Logger.getLogger(Button.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setParentControl(BaseControl parentControl) {
+ super.setParentControl(parentControl);
+ xButton = (XButton) UnoRuntime.queryInterface(XButton.class, unoControl);
+ }
+
+ public void addActionListener(XActionListener actionListener) {
+ xButton.addActionListener(actionListener);
+ }
+
+ public void setActionCommand(String actionCommand) {
+ xButton.setActionCommand(actionCommand);
+ }
+
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/Label.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/Label.java
new file mode 100755
index 000000000000..8c337d980b60
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/Label.java
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: Label.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver.dialogs.controls;
+
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.style.VerticalAlignment;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import com.sun.star.comp.Calc.NLPSolver.dialogs.BaseDialog;
+
+/**
+ *
+ * @author Andreas Schneider
+ */
+public class Label extends LabeledControl {
+
+ private String name;
+
+ public Label(BaseDialog owner, String name) {
+ super(owner.context);
+ try {
+ setUnoModel(owner.getMultiServiceFactory().createInstance("com.sun.star.awt.UnoControlFixedTextModel"));
+ this.name = name;
+ setProperty("Name", name);
+ } catch (Exception ex) {
+ Logger.getLogger(Button.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setVerticalAlign(VerticalAlignment align) {
+ setProperty("VerticalAlign", align);
+ }
+
+
+ public void setTextColor(int RGB) {
+ setProperty("TextColor", new Integer(RGB));
+ }
+
+ public int getTextColor() {
+ try {
+ Object prop = getProperty("TextColor");
+ if (AnyConverter.getType(prop) == Type.LONG)
+ return AnyConverter.toInt(prop);
+ } catch (IllegalArgumentException ex) {
+ Logger.getLogger(LabeledControl.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return 0;
+ }
+
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/LabeledControl.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/LabeledControl.java
new file mode 100755
index 000000000000..9d755bca0fa0
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/LabeledControl.java
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: LabeledControl.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver.dialogs.controls;
+
+import com.sun.star.uno.XComponentContext;
+
+/**
+ *
+ * @author Andreas Schneider
+ */
+public abstract class LabeledControl extends BaseControl {
+
+ public LabeledControl(XComponentContext context) {
+ super(context);
+ }
+
+ public void setLabel(String label) {
+ setProperty("Label", label);
+ }
+
+ public void setAlign(TextAlign align) {
+ setProperty("Align", new Short(align.getUnoValue()));
+ }
+
+ public void setMultiLine(boolean multiLine) {
+ setProperty("MultiLine", new Boolean(multiLine));
+ }
+
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/ProgressBar.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/ProgressBar.java
new file mode 100755
index 000000000000..691fc98e4c0f
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/ProgressBar.java
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ProgressBar.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver.dialogs.controls;
+
+import com.sun.star.awt.XProgressBar;
+import com.sun.star.uno.UnoRuntime;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import com.sun.star.comp.Calc.NLPSolver.dialogs.BaseDialog;
+
+/**
+ *
+ * @author Andreas Schneider <Andreas.Schneider@Sun.COM>
+ */
+public class ProgressBar extends BaseControl {
+
+ private String m_name;
+ private XProgressBar m_progressBar;
+
+ public ProgressBar(BaseDialog owner, String name) {
+ super(owner.context);
+ try {
+ setUnoModel(owner.getMultiServiceFactory().createInstance("com.sun.star.awt.UnoControlProgressBarModel"));
+ m_name = name;
+ setProperty("Name", name);
+ } catch (Exception ex) {
+ Logger.getLogger(Button.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return m_name;
+ }
+
+ @Override
+ public void setParentControl(BaseControl parentControl) {
+ super.setParentControl(parentControl);
+ m_progressBar = (XProgressBar) UnoRuntime.queryInterface(XProgressBar.class, unoControl);
+ }
+
+ public void setRange(int min, int max) {
+ m_progressBar.setRange(min, max);
+ }
+
+ public void setValue(int value) {
+ m_progressBar.setValue(value);
+ }
+
+ public int getValue() {
+ return m_progressBar.getValue();
+ }
+}
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/TextAlign.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/TextAlign.java
new file mode 100755
index 000000000000..e2c627813088
--- /dev/null
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/controls/TextAlign.java
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: TextAlign.java,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.Calc.NLPSolver.dialogs.controls;
+
+/**
+ *
+ * @author Andreas Schneider
+ */
+public enum TextAlign {
+ Left(0),
+ Center(1),
+ Right(2);
+
+ private short unoValue;
+
+ private TextAlign(int unoValue) {
+ this.unoValue = (short)unoValue;
+ }
+
+ public short getUnoValue() {
+ return unoValue;
+ }
+}
diff --git a/nlpsolver/src/description.xml b/nlpsolver/src/description.xml
new file mode 100644
index 000000000000..424b289bb8b7
--- /dev/null
+++ b/nlpsolver/src/description.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--Created with OpenOffice.org API plug-in for NetBeans Version 2.0.3-->
+<description xmlns="http://openoffice.org/extensions/description/2006" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <version value="0.9"/>
+ <identifier value="com.sun.star.comp.Calc.NLPSolver"/>
+ <display-name>
+ <name lang="en">Solver for Nonlinear Programming</name>
+ </display-name>
+ <publisher>
+ <name lang="en" xlink:href="http://www.sun.com/software/star/staroffice/extensions.jsp?cid=925095">Sun Microsystems</name>
+ </publisher>
+ <extension-description>
+ <src lang="en" xlink:href="description/extensiondescription.txt"/>
+ </extension-description>
+ <registration>
+ <simple-license accept-by="admin" default-license-id="en">
+ <license-text lang="en" license-id="en" xlink:href="licenses/lgpl-3.0.txt"/>
+ </simple-license>
+ </registration>
+ <dependencies>
+ <OpenOffice.org-minimal-version xmlns:d="http://openoffice.org/extensions/description/2006" d:name="OpenOffice.org 3.0" value="3.0"/>
+ </dependencies>
+</description>
diff --git a/nlpsolver/src/locale/NLPSolverCommon_en_US.default b/nlpsolver/src/locale/NLPSolverCommon_en_US.default
new file mode 100755
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/nlpsolver/src/locale/NLPSolverCommon_en_US.default
diff --git a/nlpsolver/src/locale/NLPSolverStatusDialog_en_US.default b/nlpsolver/src/locale/NLPSolverStatusDialog_en_US.default
new file mode 100755
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/nlpsolver/src/locale/NLPSolverStatusDialog_en_US.default
diff --git a/nlpsolver/src/uno-extension-manifest.xml b/nlpsolver/src/uno-extension-manifest.xml
new file mode 100755
index 000000000000..b6631450a30b
--- /dev/null
+++ b/nlpsolver/src/uno-extension-manifest.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<manifest:manifest xmlns:manifest="http://openoffice.org/2001/manifest">
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=Java"
+ manifest:full-path="NLPSolver.jar"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.help"
+ manifest:full-path="help"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.package-bundle-description"
+ manifest:full-path="description/extensiondescription.txt"/>
+</manifest:manifest> \ No newline at end of file