Skip to content

Commit

Permalink
Merge branch 'devel' into alfoa/ls_error_bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
alfoa authored Apr 16, 2020
2 parents e606b40 + 0868c0d commit 440caa1
Show file tree
Hide file tree
Showing 84 changed files with 24,528 additions and 1,101 deletions.
78 changes: 77 additions & 1 deletion developer_tools/XSDSchemas/Optimizers.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<xsd:complexType name="OptimizerData">
<xsd:sequence>
<xsd:element name="GradientDescent" type="GradientDescentOptimizer" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="SimulatedAnnealing" type="SimulatedAnnealingOptimizer" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="verbosity" type="verbosityAttr" default="all"/>
</xsd:complexType>
Expand Down Expand Up @@ -77,6 +78,57 @@
</xsd:all>
</xsd:complexType>

<xsd:complexType name="SAConvergenceType">
<xsd:all>
<xsd:element name="persistence" type="xsd:integer" minOccurs="0"/>
<xsd:element name="objective" type="xsd:float" minOccurs="0"/>
<xsd:element name="temperature" type="xsd:float" minOccurs="0"/>
</xsd:all>
</xsd:complexType>

<!-- <xsd:complexType name="linearCoolingType">
<xsd:element name="beta" type="xsd:float"/>
</xsd:complexType> -->

<xsd:complexType name="exponentialCoolingType">
<xsd:all>
<xsd:element name="alpha" type="xsd:float"/>
</xsd:all>
</xsd:complexType>

<xsd:complexType name="boltzmanCoolingType">
<xsd:all>
<xsd:element name="d" type="xsd:float"/>
</xsd:all>
</xsd:complexType>

<xsd:complexType name="cauchyCoolingType">
<xsd:all>
<xsd:element name="d" type="xsd:float"/>
</xsd:all>
</xsd:complexType>

<!-- <xsd:complexType name="fastCoolingType">
<xsd:element name="c" type="xsd:float"/>
</xsd:complexType> -->

<xsd:complexType name="veryFastCoolingType">
<xsd:all>
<xsd:element name="c" type="xsd:float"/>
</xsd:all>
</xsd:complexType>

<xsd:complexType name="OptCoolingScheduleType">
<xsd:choice>
<!-- <xsd:element name="linear" type="linearCoolingType"/> -->
<xsd:element name="exponential" type="exponentialCoolingType"/>
<xsd:element name="cauchy" type="cauchyCoolingType"/>
<xsd:element name="boltzmann" type="boltzmanCoolingType"/>
<!-- <xsd:element name="fast" type="fastCoolingType"/> -->
<xsd:element name="veryfast" type="veryFastCoolingType"/>
</xsd:choice>
</xsd:complexType>

<xsd:complexType name="GradientDescentOptimizer">
<xsd:sequence>
<xsd:element name="objective" type="xsd:string" minOccurs="1" maxOccurs="1"/>
Expand All @@ -103,4 +155,28 @@
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="verbosity" type="verbosityAttr"/>
</xsd:complexType>
</xsd:schema>
<xsd:complexType name="SimulatedAnnealingOptimizer">
<xsd:sequence>
<xsd:element name="samplerInit" type="optInitType" minOccurs="0"/>
<xsd:element name="convergence" type="SAConvergenceType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="coolingSchedule" type="OptCoolingScheduleType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="variable" type="optVarType" minOccurs="1" maxOccurs='unbounded'/>
<xsd:element name="objective" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="TargetEvaluation" type="AssemblerObjectType" minOccurs="1" maxOccurs="1"/>
<xsd:element name="constant" type="constantVarType" minOccurs="0" maxOccurs='unbounded'/>
<xsd:element name="ConstantSource" minOccurs="0" maxOccurs='unbounded'>
<xsd:complexType mixed="true">
<xsd:attribute name="class" type="xsd:string" use="required"/>
<xsd:attribute name="type" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="Constraint" type="AssemblerObjectType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="Sampler" type="AssemblerObjectType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="Restart" type="AssemblerObjectType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="restartTolerance" type="xsd:float" minOccurs="0" maxOccurs="1"/>
<xsd:element name="variableTransformation" type="variablesTransformationType" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="verbosity" type="verbosityAttr"/>
</xsd:complexType>
</xsd:schema>
2 changes: 1 addition & 1 deletion doc/user_manual/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ conda_command.txt : $(LIB_FILES)
./create_command.sh

pip_commands.txt : $(LIB_FILES)
./create_pip_commands.sh
./create_pip_commands.sh
82 changes: 62 additions & 20 deletions doc/user_manual/generated/generateOptimizerDoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,8 @@ def insertSolnExport(tex, obj):
tex = '\n'.join(split)
return tex


#------------#
# OPTIMIZERS #
#------------#
import Optimizers
msg = ''
# base classes first
optDescr = wrapText(Optimizers.Optimizer.userManualDescription(), ' ')
msg += optDescr
# write all known types
for name in Optimizers.knownTypes():
obj = Optimizers.returnClass(name, mu)
specs = obj.getInputSpecification()
tex = specs.generateLatex()
tex = insertSolnExport(tex, obj)
msg += tex

# examples
minimal = r"""
minimalGradientDescent = r"""
\hspace{24pt}
Gradient Descent Example:
\begin{lstlisting}[style=XML]
Expand Down Expand Up @@ -122,7 +105,66 @@ def insertSolnExport(tex, obj):
\end{lstlisting}
"""
msg += minimal

minimalSimulatedAnnealing = r"""
\hspace{24pt}
Simulated Annealing Example:
\begin{lstlisting}[style=XML]
<Optimizers>
...
<SimulatedAnnealing name="simOpt">
<samplerInit>
<limit>2000</limit>
<initialSeed>42</initialSeed>
<writeSteps>every</writeSteps>
<type>min</type>
</samplerInit>
<convergence>
<objective>1e-6</objective>
<temperature>1e-20</temperature>
<persistence>1</persistence>
</convergence>
<coolingSchedule>
<exponential>
<alpha>0.94</alpha>
</exponential>
</coolingSchedule>
<variable name="x">
<distribution>beale_dist</distribution>
<initial>-2.5</initial>
</variable>
<variable name="y">
<distribution>beale_dist</distribution>
<initial>3.5</initial>
</variable>
<objective>ans</objective>
<TargetEvaluation class="DataObjects" type="PointSet">optOut</TargetEvaluation>
</SimulatedAnnealing>
...
</Optimizers>
\end{lstlisting}
"""
# examples Factory
exampleFactory = {'GradientDescent':minimalGradientDescent,'SimulatedAnnealing':minimalSimulatedAnnealing}

#------------#
# OPTIMIZERS #
#------------#
import Optimizers
msg = ''
# base classes first
optDescr = wrapText(Optimizers.Optimizer.userManualDescription(), ' ')
msg += optDescr
# write all known types
for name in Optimizers.knownTypes():
obj = Optimizers.returnClass(name, mu)
specs = obj.getInputSpecification()
tex = specs.generateLatex()
tex = insertSolnExport(tex, obj)
msg +=tex
msg+= exampleFactory[name]

fName = os.path.abspath(os.path.join(os.path.dirname(__file__), 'optimizer.tex'))
with open(fName, 'w') as f:
f.writelines(msg)
f.writelines(msg)
Loading

0 comments on commit 440caa1

Please sign in to comment.