stages.generateCode(get_userid.userid)

# simulate
import myMPC_FORCESPro_py

problem = myMPC_FORCESPro_py.myMPC_FORCESPro_params
x1 = np.array([-4, 2])
kmax = 30
X = np.zeros((nx, kmax + 1))
X[:, 0] = x1
U = np.zeros((nu, kmax))
for k in range(0, kmax):
    problem['minusA_times_x0'] = -np.dot(A, X[:, k])
    [solverout, exitflag,
     info] = myMPC_FORCESPro_py.myMPC_FORCESPro_solve(problem)
    if (exitflag == 1):
        U[:, k] = solverout['u0']
        print(info.solvetime)
    else:
        print(info)
        raise SolverError('Some problem in solver')

    X[:, k + 1] = np.dot(A, X[:, k]) + np.dot(B, U[:, k])

# plot
import matplotlib.pyplot as plt

fig1 = plt.figure()
plt.subplot(2, 1, 1)
plt.axhline(y=max(xmax), c="red", zorder=0)
import get_userid

stages.generateCode(get_userid.userid)

# simulate
import myMPC_FORCESPro_py

problem = myMPC_FORCESPro_py.myMPC_FORCESPro_params
x1 = np.array([-4, 2])
kmax = 30
X = np.zeros((nx, kmax + 1))
X[:, 0] = x1
U = np.zeros((nu, kmax))
for k in range(0, kmax):
    problem['minusA_times_x0'] = -np.dot(A, X[:, k])
    [solverout, exitflag, info] = myMPC_FORCESPro_py.myMPC_FORCESPro_solve(problem)
    if (exitflag == 1):
        U[:, k] = solverout['u0']
        print('Problem solved in %5.3f milliseconds (%d iterations).' % (1000.0 * info.solvetime, info.it))
    else:
        print(info)
        raise SolverError('Some problem in solver')

    X[:, k + 1] = np.dot(A, X[:, k]) + np.dot(B, U[:, k])

# plot
import matplotlib.pyplot as plt

fig1 = plt.figure()
plt.subplot(2, 1, 1)
plt.axhline(y=max(xmax), c="red", zorder=0)