Skip to content
Snippets Groups Projects
Commit 5a665cbb authored by Erin Kuci's avatar Erin Kuci
Browse files

unconstrained example

parent bb2f418b
No related branches found
No related tags found
No related merge requests found
...@@ -133,7 +133,6 @@ while it <= maxIter and c.getString('shape/Action') != 'stop': ...@@ -133,7 +133,6 @@ while it <= maxIter and c.getString('shape/Action') != 'stop':
# compute objective function and constraints # compute objective function and constraints
c.runSubClient('myGetDP', mygetdp + '-solve GetPerformances') c.runSubClient('myGetDP', mygetdp + '-solve GetPerformances')
objective = np.sum(readSimpleTable(c.getPath('res_opt/w.txt'))) objective = np.sum(readSimpleTable(c.getPath('res_opt/w.txt')))
constraints = np.array([np.sum(xFromMMA)/np.sum(upperBound)-1.0])
# generate the velocity field of each design variable # generate the velocity field of each design variable
getVelocityField(x) getVelocityField(x)
...@@ -146,19 +145,17 @@ while it <= maxIter and c.getString('shape/Action') != 'stop': ...@@ -146,19 +145,17 @@ while it <= maxIter and c.getString('shape/Action') != 'stop':
c.waitOnSubClients() c.waitOnSubClients()
grad_objective = np.asarray([np.sum(readSimpleTable(c.getPath('res_opt/Grad_w_wrt_dv_'+str(dv)+'.txt')))\ grad_objective = np.asarray([np.sum(readSimpleTable(c.getPath('res_opt/Grad_w_wrt_dv_'+str(dv)+'.txt')))\
for dv in xrange(numVariables)]) for dv in xrange(numVariables)])
grad_constraints = np.ones(numVariables)/np.sum(upperBound)
print('*'*50) print('*'*50)
print('iteration: ', it) print('iteration: ', it)
print('change: ', change) print('change: ', change)
print('current point:', xFromMMA) print('current point:', xFromMMA)
print('objective:', objective) print('objective:', objective)
print('constraints:', constraints) c.sendInfo('Optimization: it. {}, obj. {}'.format(it,objective))
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
conveks.mma.setMoveLimits(lowerBound, upperBound, 1.0e-3) conveks.mma.setMoveLimits(lowerBound, upperBound, 0.1)
conveks.mma.updateCurrentPoint(grad_objective,constraints,grad_constraints) conveks.mma.updateCurrentPoint(grad_objective)
change = conveks.mma.getDesignChange() change = conveks.mma.getDesignChange()
it = conveks.mma.getOuterIteration() it = conveks.mma.getOuterIteration()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment