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':
# compute objective function and constraints
c.runSubClient('myGetDP', mygetdp + '-solve GetPerformances')
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
getVelocityField(x)
......@@ -146,19 +145,17 @@ while it <= maxIter and c.getString('shape/Action') != 'stop':
c.waitOnSubClients()
grad_objective = np.asarray([np.sum(readSimpleTable(c.getPath('res_opt/Grad_w_wrt_dv_'+str(dv)+'.txt')))\
for dv in xrange(numVariables)])
grad_constraints = np.ones(numVariables)/np.sum(upperBound)
print('*'*50)
print('iteration: ', it)
print('change: ', change)
print('current point:', xFromMMA)
print('objective:', objective)
print('constraints:', constraints)
c.sendInfo('Optimization: it. {}, obj. {}, constr. {}'.format(it,objective,constraints[0]))
c.sendInfo('Optimization: it. {}, obj. {}'.format(it,objective))
# call MMA and update the current point
conveks.mma.setMoveLimits(lowerBound, upperBound, 1.0e-3)
conveks.mma.updateCurrentPoint(grad_objective,constraints,grad_constraints)
conveks.mma.setMoveLimits(lowerBound, upperBound, 0.1)
conveks.mma.updateCurrentPoint(grad_objective)
change = conveks.mma.getDesignChange()
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