There are two ways to access the file. The first method is to switch to remote=False
to solve locally and produce the infeasibilities.txt file on your computer. The second method is to retrieve the file from the remote directory. The first method is the most simple solution in terms of coding (just change an option and open the run folder). The second method is most convenient because it makes the file available in your run directory. The example that I include below is purposefully infeasible with equations x+y=1
and x+y=0
.
Method 1 - Open run folder when remote=False
from gekko import GEKKO
m = GEKKO(remote=False) # remote=False to produce local folder with results
x = m.Var()
y = m.Var()
m.Equations([x+y==1, x+y==0]) # no solution
m.open_folder() # open folder if remote=False to see infeasibilities.txt
m.solve(disp=True) # solve
Method 2 - Retrieve infeasibilities.txt file when remote=True
from gekko import GEKKO
m = GEKKO(remote=True)
x = m.Var()
y = m.Var()
m.Equations([x+y==1, x+y==0]) # no solution
try:
m.solve(disp=True) # solve
except:
print('Not successful')
from gekko.apm import get_file
print(m._server)
print(m._model_name)
f = get_file(m._server,m._model_name,'infeasibilities.txt')
f = f.decode().replace('\r','')
with open('infeasibilities.txt', 'w') as fl:
fl.write(str(f))
The infeasibilities.txt file is somewhat hard to read but it does try to identify equations that are causing the solution to fail. Here is the example from this problem.
************************************************
***** POSSIBLE INFEASBILE EQUATIONS ************
************************************************
____________________________________________________________________________
EQ Number Lower Residual Upper Infeas. Name
1 0.0000E+00 -9.4140E-01 0.0000E+00 9.4140E-01 ss.Eqn(1): 0 = (v1+v2)-(1)
Variable Lower Value Upper $Value Name
1 -1.2346E+20 2.9300E-02 1.2346E+20 0.0000E+00 ss.v1
2 -1.2346E+20 2.9300E-02 1.2346E+20 0.0000E+00 ss.v2
____________________________________________________________________________
EQ Number Lower Residual Upper Infeas. Name
2 0.0000E+00 5.8600E-02 0.0000E+00 -5.8600E-02 ss.Eqn(2): 0 = (v1+v2)-(0)
Variable Lower Value Upper $Value Name
1 -1.2346E+20 2.9300E-02 1.2346E+20 0.0000E+00 ss.v1
2 -1.2346E+20 2.9300E-02 1.2346E+20 0.0000E+00 ss.v2
************************************************
****** ACTIVE OBJECTIVE EQUATIONS **************
************************************************
Number ID Node Horizon Unscaled Res Scaled Res Scaling Name
************************************************
************* ACTIVE EQUATIONS *****************
************************************************
Number ID Node Horizon Unscaled Res Scaled Res Scaling Name
1 1 1 1 -9.4140E-01 -9.4140E-01 1.0000E+00 ss.Eqn(1): 0 = (v1+v2)-(1)
2 2 1 1 5.8600E-02 5.8600E-02 1.0000E+00 ss.Eqn(2): 0 = (v1+v2)-(0)
************************************************
************ INACTIVE EQUATIONS ****************
************************************************
Number Unscaled Res Scaled Res Scaling Name
If you use x = m.Var(name='x')
to name your variables then the file will become more descriptive. Both equations were identified as potentially infeasible.