Skip to content
Snippets Groups Projects
Commit b2393276 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

optlab -> conveks

parent af63cbcf
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# #
import numpy as np import numpy as np
import optlab import conveks
import onelab import onelab
c = onelab.client(__file__) c = onelab.client(__file__)
...@@ -110,20 +110,20 @@ lowerBound = 0.001*np.ones(numVariables) ...@@ -110,20 +110,20 @@ lowerBound = 0.001*np.ones(numVariables)
upperBound = np.ones(numVariables) upperBound = np.ones(numVariables)
# Initialize the MMA optimizer # Initialize the MMA optimizer
optlab.mma.initialize(x, lowerBound, upperBound) conveks.mma.initialize(x, lowerBound, upperBound)
# Set appropriate options for MMA # Set appropriate options for MMA
optlab.mma.option.setNumber('General.Verbosity', 4) conveks.mma.option.setNumber('General.Verbosity', 4)
optlab.mma.option.setNumber('General.SaveHistory', 0) conveks.mma.option.setNumber('General.SaveHistory', 0)
optlab.mma.option.setNumber('SubProblem.isRobustMoveLimit', 1) conveks.mma.option.setNumber('SubProblem.isRobustMoveLimit', 1)
optlab.mma.option.setNumber('SubProblem.isRobustAsymptotes', 1) conveks.mma.option.setNumber('SubProblem.isRobustAsymptotes', 1)
optlab.mma.option.setNumber('SubProblem.type', 0) conveks.mma.option.setNumber('SubProblem.type', 0)
optlab.mma.option.setNumber('SubProblem.addConvexity', 1) conveks.mma.option.setNumber('SubProblem.addConvexity', 1)
optlab.mma.option.setNumber('SubProblem.asymptotesRmax', 100.0) conveks.mma.option.setNumber('SubProblem.asymptotesRmax', 100.0)
optlab.mma.option.setNumber('SubProblem.asymptotesRmin', 0.001) conveks.mma.option.setNumber('SubProblem.asymptotesRmin', 0.001)
# Get iteration count (here it will be 1 - could be different in case of restart) # Get iteration count (here it will be 1 - could be different in case of restart)
it = optlab.mma.getOuterIteration() it = conveks.mma.getOuterIteration()
change = 1.0 change = 1.0
while change > maxChange and it <= maxIter and c.getString('topo/Action') != 'stop': while change > maxChange and it <= maxIter and c.getString('topo/Action') != 'stop':
...@@ -134,7 +134,7 @@ while change > maxChange and it <= maxIter and c.getString('topo/Action') != 'st ...@@ -134,7 +134,7 @@ while change > maxChange and it <= maxIter and c.getString('topo/Action') != 'st
attributes={'Highlight':'LightYellow'}) attributes={'Highlight':'LightYellow'})
# get (copy of) current point # get (copy of) current point
x = np.array(optlab.mma.getCurrentPoint()) x = np.array(conveks.mma.getCurrentPoint())
if filtering: if filtering:
setElementTable('Optimization/Results/filterInput', elements, x) setElementTable('Optimization/Results/filterInput', elements, x)
...@@ -183,10 +183,10 @@ while change > maxChange and it <= maxIter and c.getString('topo/Action') != 'st ...@@ -183,10 +183,10 @@ while change > maxChange and it <= maxIter and c.getString('topo/Action') != 'st
c.sendInfo('Optimization: it. {}, obj. {}, constr. {}, change {}'.format(it,objective,constraints[0], change)) c.sendInfo('Optimization: it. {}, obj. {}, constr. {}, change {}'.format(it,objective,constraints[0], change))
# call MMA and update the current point # call MMA and update the current point
optlab.mma.setMoveLimits(lowerBound, upperBound, 0.1) conveks.mma.setMoveLimits(lowerBound, upperBound, 0.1)
optlab.mma.updateCurrentPoint(constraints, grad_objective, grad_constraints) conveks.mma.updateCurrentPoint(constraints, grad_objective, grad_constraints)
change = optlab.mma.getDesignChange() change = conveks.mma.getDesignChange()
it = optlab.mma.getOuterIteration() it = conveks.mma.getOuterIteration()
# This should be called at the end # This should be called at the end
optlab.mma.finalize() conveks.mma.finalize()
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# #
import numpy as np import numpy as np
import optlab import conveks
import onelab import onelab
c = onelab.client(__file__) c = onelab.client(__file__)
...@@ -102,20 +102,20 @@ for label, var in x.iteritems(): ...@@ -102,20 +102,20 @@ for label, var in x.iteritems():
upperBound[label] = var[3] upperBound[label] = var[3]
# Initialize the MMA optimizer # Initialize the MMA optimizer
optlab.mma.initialize(initialPoint, lowerBound, upperBound) conveks.mma.initialize(initialPoint, lowerBound, upperBound)
# Set some options for MMA # Set some options for MMA
optlab.mma.option.setNumber('General.Verbosity', 4) conveks.mma.option.setNumber('General.Verbosity', 4)
optlab.mma.option.setNumber('General.SaveHistory', 0) conveks.mma.option.setNumber('General.SaveHistory', 0)
optlab.mma.option.setNumber('SubProblem.isRobustMoveLimit', 1) conveks.mma.option.setNumber('SubProblem.isRobustMoveLimit', 1)
optlab.mma.option.setNumber('SubProblem.isRobustAsymptotes', 1) conveks.mma.option.setNumber('SubProblem.isRobustAsymptotes', 1)
optlab.mma.option.setNumber('SubProblem.type', 0) conveks.mma.option.setNumber('SubProblem.type', 0)
optlab.mma.option.setNumber('SubProblem.addConvexity', 0) conveks.mma.option.setNumber('SubProblem.addConvexity', 0)
optlab.mma.option.setNumber('SubProblem.asymptotesRmax', 100.0) conveks.mma.option.setNumber('SubProblem.asymptotesRmax', 100.0)
optlab.mma.option.setNumber('SubProblem.asymptotesRmin', 0.001) conveks.mma.option.setNumber('SubProblem.asymptotesRmin', 0.001)
# Get iteration count (here it will be 1 - could be different in case of restart) # Get iteration count (here it will be 1 - could be different in case of restart)
it = optlab.mma.getOuterIteration() it = conveks.mma.getOuterIteration()
change = 1.0 change = 1.0
while it <= maxIter and c.getString('shape/Action') != 'stop': while it <= maxIter and c.getString('shape/Action') != 'stop':
...@@ -124,7 +124,7 @@ while it <= maxIter and c.getString('shape/Action') != 'stop': ...@@ -124,7 +124,7 @@ while it <= maxIter and c.getString('shape/Action') != 'stop':
attributes={'Highlight':'LightYellow'}) attributes={'Highlight':'LightYellow'})
# get (copy of) current point # get (copy of) current point
xFromMMA = np.array(optlab.mma.getCurrentPoint()) xFromMMA = np.array(conveks.mma.getCurrentPoint())
# send the current point to GetDP model # send the current point to GetDP model
for label, var in x.iteritems(): for label, var in x.iteritems():
...@@ -171,10 +171,10 @@ while it <= maxIter and c.getString('shape/Action') != 'stop': ...@@ -171,10 +171,10 @@ while it <= maxIter and c.getString('shape/Action') != 'stop':
c.sendInfo('Optimization: it. {}, obj. {}, constr. {}'.format(it,objective,constraints[0])) c.sendInfo('Optimization: it. {}, obj. {}, constr. {}'.format(it,objective,constraints[0]))
# call MMA and update the current point # call MMA and update the current point
optlab.mma.setMoveLimits(lowerBound, upperBound, 1.0e-4) conveks.mma.setMoveLimits(lowerBound, upperBound, 1.0e-4)
optlab.mma.updateCurrentPoint(constraints,grad_objective,grad_constraints) conveks.mma.updateCurrentPoint(constraints,grad_objective,grad_constraints)
change = optlab.mma.getDesignChange() change = conveks.mma.getDesignChange()
it = optlab.mma.getOuterIteration() it = conveks.mma.getOuterIteration()
# This should be called at the end # This should be called at the end
optlab.mma.finalize() conveks.mma.finalize()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment