The optimize Method
def optimize(self):
"""
Run an optimization
"""
obj = [self.R1,self.R2,self.R3]
wt = [1,1,1]
self.opt = Optimizer (
label = "Optimize RMS2",
objective = obj,
weights = wt,
ineqConstraints = self.R4,
plot = False,
dsa = 'FD',
simFunction = simulate_function_pid,
outputMode = 'FileOnly',
)
return self.opt.optimize()
Here we pass in a simulate function instead of specifying end, dtout, type in the optimizer. This deactivates the force during the simulation.
def simulate_function_pid(model):
run = model.simulate(end=10, dtout=0.01, returnResults=True, output="Off")
model.force.active = False
run = model.simulate(end=100, dtout=0.01, returnResults=True,output="Off")
model.force.active = True
return run