BYU-PRISM / GEKKO

GEKKO Python for Machine Learning and Dynamic Optimization
https://machinelearning.byu.edu
Other
573 stars 102 forks source link

Optionally ignore fixed / free specifications from restart file #97

Open APMonitor opened 3 years ago

APMonitor commented 3 years ago

The option to ignore fixed / free specifications isn't communicated appropriately when using m.options.SPECS=0. Here is an example script that demonstrates the behavior.

from gekko import GEKKO

m = GEKKO(remote=False)

# Variables
x1 = m.Var()
x2 = m.Var()

# Equation
FindX1 = 6 == x1*x2
m.Equation(FindX1)

# Fix x1 to 2
m.fix(x1, val=2)

# Solve X2
m.solve(disp=False)
print("X1: %s and X2: %s" % (x1.VALUE, x2.VALUE))

# Fix x2 to 2
m.fix(x2, val=2)

# Free x1
m.free(x1)

m.options.SPECS = 0

# Solve X1
m.solve(disp=False)
print("X1: %s and X2: %s" % (x1.VALUE, x2.VALUE))

The solution should be:

X1: [2.0] and X2: [3.0]
X1: [3.0] and X2: [2.0]

but instead this is produced:

X1: [2.0] and X2: [3.0]
X1: [2.0] and X2: [3.0]

See StackOverflow post for the original question.