I'm Arthur. I'm very new to gekko, thus I might be missing something very obvious here.
I have been trying to find the solution to an optimal control problem, namely trajectory optimization of a spacecraft rendezvous problem (Chaser -> Target), under certain final constraints to the relative final distance and velocity and certain distance along their trip. In order to do this, I tried using soft constraints to the final path. As a objective function, I use a norm 1 of the force generated from Thrusters.
The computation keeps going until the maximum no. of iterations (2000) is reached and cancels. Is there maybe a way to discretize the search space of this problem to make it solvable in acceptable time trading off computation time for accuracy?
import matplotlib.pyplot as plt
import numpy as np
from gekko import GEKKO
# create GEKKO model
m = GEKKO()
print(m.path)
nt = 501
m.time = np.linspace(0,500,nt)
# Variables
# Initial Position and Velocity - Chaser
r1_c = -1182.339411 # [km]
r2_c = 6816.939420 # [km]
r3_c = 904.891745 # [km]
v1_c = 0.1175776 # [km/s]
v2_c = -0.963776 # [km/s]
v3_c = 7.494102 # [km/s]
# Initial Position and Velocity - Target
r1_t = -1182.959348 # [km]
r2_t = 6817.396210 # [km]
r3_t = 904.495486 # [km]
v1_t = 0.1175776 # [km/s]
v2_t = -0.963776 # [km/s]
v3_t = 7.494102 # [km/s]
# initial values
x = m.Var(value = r1_c)
y = m.Var(value = r2_c)
z = m.Var(value = r3_c)
vx = m.Var(value = v1_c)
vy = m.Var(value = v2_c)
vz = m.Var(value = v3_c)
# initial values
x2 = m.Var(value = r1_t)
y2 = m.Var(value = r2_t)
z2 = m.Var(value = r3_t)
vx2 = m.Var(value = v1_t)
vy2 = m.Var(value = v2_t)
vz2 = m.Var(value = v3_t)
# Cost Initial - Integrated thrust (fuel usage)
J = m.Var(value = 0)
# Manipulated Variable
U = m.MV(value=0, lb=-0.001, ub=0.001)
U.STATUS = 1
# Mask time
p = np.zeros(nt) # mask final time point
p[-1] = 500
final = m.Param(value=p)
# Parameters
RT = m.Const(6378.139); # [km]
mu_t = m.Const(3.9860064*10**(5)) # [km^3/s^2]
# Equations
# Define intermediate quantities - Chaser
Rc = m.Intermediate((x**2 + y**2 + z**2)**0.5)
v = m.Intermediate((vx**2 + vy**2 + vz**2)**0.5)
ax = m.Intermediate(x * -mu_t / Rc**3 + U *vx / v )
ay = m.Intermediate(y * -mu_t / Rc**3 + U *vy / v )
az = m.Intermediate(z * -mu_t / Rc**3 + U *vz / v )
# Define intermediate quantities - Target
Rt = m.Intermediate((x2**2 + y2**2 + z2**2)**0.5)
v2 = m.Intermediate((vx2**2 + vy2**2 + vz2**2)**0.5)
ax2 = m.Intermediate(x2 * -mu_t / Rt**3 )
ay2 = m.Intermediate(y2 * -mu_t / Rt**3 )
az2 = m.Intermediate(z2 * -mu_t / Rt**3 )
# Governing equations
m.Equations((vx.dt() == ax, vy.dt() == ay, vz.dt() == az))
m.Equations((x.dt() == vx, y.dt() == vy, z.dt() == vz))
m.Equations((vx2.dt() == ax2, vy2.dt() == ay2, vz2.dt() == az2))
m.Equations((x2.dt() == vx2, y2.dt() == vy2, z2.dt() == vz2))
# Equation relating thrust to fuel usage
m.Equation(J.dt() == m.abs2(U))
# Path Constraints
# specify endpoint conditions
m.fix(x, pos=len(m.time)-1, val=x2)
m.fix(y, pos=len(m.time)-1, val=y2)
m.fix(z, pos=len(m.time)-1, val=z2)
m.fix(vx, pos=len(m.time)-1, val=vx2)
m.fix(vy, pos=len(m.time)-1, val=vy2)
m.fix(vz, pos=len(m.time)-1, val=vz2)
# Constraints
m.Equations((m.abs2(Rc - RT) > 200, m.abs2(Rc - RT) < 1000, m.abs2(Rc*final - Rt*final) == 0, m.abs2(v*final - v2*final) == 0))
# Objective, minimizing fuel usage
m.Obj(J * final)
# Set solver mode - Optimal Control
m.options.IMODE = 6
# Increase maximum number of allowed iterations
m.options.MAX_ITER = 2000
# Set number of nodes per time segment
m.options.NODES = 3
# Run solver and display progress
m.solve(disp=True)
---------------------------------------------------
Solver : IPOPT (v3.12)
Solution time : 3663.92820000000 sec
Objective : 185346862893.104
Unsuccessful with error code 0
---------------------------------------------------
Creating file: infeasibilities.txt
Use command apm_get(server,app,'infeasibilities.txt') to retrieve file
@error: Solution Not Found
---------------------------------------------------------------------------
It does not find the solution and I do not find the file infeasibilities.txt
.
Can you help me please?
I would like to find the reason from results (Solution Not Found). However someone can help me with structure of the problem becoming it feasible.