Running the attached code results in the below error. The error is the same even if changing m.options.SOLVER
to 2 or 3
Traceback (most recent call last): File "C:\Users\17576\Documents\Python\Scratch.py", line 33, in m.solve() File "C:\Users\17576\Documents\Python\venv\lib\site-packages\gekko\gekko.py", line 2227, in solve self.load_JSON() File "C:\Users\17576\Documents\Python\venv\lib\site-packages\gekko\gk_post_solve.py", line 13, in load_JSON f = open(os.path.join(self._path,'options.json')) FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\17576\AppData\Local\Temp\tmpp6w85mm5gk_model0\options.json'
Error: The system cannot find the path specified.
Error: 'results.json' not found. Check above for additional error details
Process finished with exit code 1
from gekko import GEKKO
# Variables
var_a = 155.31
var_b = 6.27
var_c = 12
var_d = 750
var_e = 10
var_f = 1
var_d_lower_bound_percentage = .99
var_e_lower_bound_percentage = .99
var_e_upper_bound_percentage = 1.01
x_value = 1
y_value = 3
# Optimization
m = GEKKO(remote=False)
x = m.Var(value=x_value, lb=0)
y = m.Var(value=y_value, lb=0, integer=True)
m.Equation(x*var_a + y*var_b <= var_d)
m.Equation(x*var_a + y*var_b >= var_d*var_d_lower_bound_percentage)
m.Equation(((x*var_a)/(x*var_a + y*var_b)) + ((y*var_b)/(x*var_a + y*var_b)) == 1)
m.Equation(((x*var_a)/(x*var_a + y*var_b))*var_f + ((y*var_b)/(x*var_a + y*var_b))*var_c <= var_e*var_e_upper_bound_percentage)
m.Equation(((x*var_a)/(x*var_a + y*var_b))*var_f + ((y*var_b)/(x*var_a + y*var_b))*var_c >= var_e*var_e_lower_bound_percentage)
m.Obj(((x*var_a)/(x*var_a + y*var_b))*var_f + ((y*var_b)/(x*var_a + y*var_b))*var_c)
m.options.SOLVER = 1
m.solve()
print(x.value)
print(y.value)
Try upgrading the version of gekko
. See instructions on managing packages if additional support is needed.
pip install gekko --upgrade
Both remote and local solutions complete successfully with gekko
version 1.0.5. From the path error, it appears that it is either an older version or else there is a permission error with writing to the tmp run directory folder on your Windows computer.
----------------------------------------------------------------
APMonitor, Version 1.0.0
APMonitor Optimization Suite
----------------------------------------------------------------
--------- APM Model Size ------------
Each time step contains
Objects : 0
Constants : 0
Variables : 6
Intermediates: 0
Connections : 0
Equations : 6
Residuals : 6
Number of state variables: 6
Number of total equations: - 5
Number of slack variables: - 4
---------------------------------------
Degrees of freedom : -3
* Warning: DOF <= 0
----------------------------------------------
Steady State Optimization with APOPT Solver
----------------------------------------------
Iter: 1 I: 0 Tm: 0.00 NLPi: 5 Dpth: 0 Lvs: 2 Obj: 9.90E+00 Gap: NaN
--Integer Solution: 9.90E+00 Lowest Leaf: 9.90E+00 Gap: 0.00E+00
Iter: 2 I: 0 Tm: 0.00 NLPi: 5 Dpth: 1 Lvs: 2 Obj: 9.90E+00 Gap: 0.00E+00
Successful solution
---------------------------------------------------
Solver : APOPT (v1.0)
Solution time : 0.0156 sec
Objective : 9.9
Successful solution
---------------------------------------------------
[0.91446827259]
[96.0]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.