Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
APMonitor committed Jul 28, 2020
1 parent ad8f8a4 commit 678911f
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions examples/test_fix_free.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
from gekko import GEKKO
import numpy as np
import matplotlib.pyplot as plt

m = GEKKO(remote=False)

t = np.linspace(0,10,11)
m.time = t

p = m.Param(t+1,lb=0.5,ub=1)

m.free(p)
m.fix_initial(p,1)
m.fix_final(p,2)

m.Minimize(p**2)
p = m.Param(t+1,lb=0.2,ub=1)
x = m.Var(0)

m.Equation(x.dt()==p)
m.Minimize(x**2)
m.options.IMODE = 6
m.solve()
p.value = t
m.solve()

print(p.value)
m.free(p)
m.fix_initial(p,0.9)
m.fix_final(p,1.0)
m.free_initial(x)
#m.free_final(x)
m.solve(disp=True)

plt.plot(t,p.value,'ro-')
plt.plot(t,x.value,'bx-')
plt.show()

0 comments on commit 678911f

Please sign in to comment.