def makeMpc(dae, N, ts): mpc = rawe.Ocp(dae, N=N, ts=ts, yxNames=['pos', 'vel'], yuNames=['force']) mpc.constrain(-2.5, '<=', mpc['force'], '<=', 2.5) # cgOpts = {'CXX':'clang++', 'CC':'clang'} cgOpts = {'CXX': 'g++', 'CC': 'gcc'} # cgOpts = {'CXX':'icpc', 'CC':'icc'} intOpts = rawe.RtIntegratorOptions() intOpts['INTEGRATOR_TYPE'] = 'INT_IRK_GL4' intOpts['NUM_INTEGRATOR_STEPS'] = 5 intOpts['LINEAR_ALGEBRA_SOLVER'] = 'GAUSS_LU' ocpOpts = rawe.OcpExportOptions() ocpOpts['HESSIAN_APPROXIMATION'] = 'GAUSS_NEWTON' ocpOpts['DISCRETIZATION_TYPE'] = 'MULTIPLE_SHOOTING' ocpOpts['QP_SOLVER'] = 'QP_QPOASES' ocpOpts['SPARSE_QP_SOLUTION'] = 'CONDENSING' # ocpOpts['SPARSE_QP_SOLUTION'] = 'FULL_CONDENSING' # ocpOpts['QP_SOLVER'] = 'QP_FORCES' # ocpOpts['SPARSE_QP_SOLUTION'] = 'SPARSE_SOLVER' ocpOpts['FIX_INITIAL_STATE'] = True ocpOpts['HOTSTART_QP'] = True ocpOpts['GENERATE_MATLAB_INTERFACE'] = True return rawe.OcpRT(mpc, ocpOptions=ocpOpts, integratorOptions=intOpts, codegenOptions=cgOpts)
def makeNmpc(dae, N, dt): mpc = rawe.Ocp(dae, N=N, ts=dt) ocpOpts = rawe.OcpExportOptions() ocpOpts['HESSIAN_APPROXIMATION'] = 'GAUSS_NEWTON' ocpOpts['DISCRETIZATION_TYPE'] = 'MULTIPLE_SHOOTING' ocpOpts['QP_SOLVER'] = 'QP_QPOASES' ocpOpts['HOTSTART_QP'] = False ocpOpts['SPARSE_QP_SOLUTION'] = 'CONDENSING' # ocpOpts['SPARSE_QP_SOLUTION'] = 'FULL_CONDENSING_U2' # ocpOpts['AX_NUM_QP_ITERATIONS'] = '30' ocpOpts['FIX_INITIAL_STATE'] = True mpc.minimizeLsq(C.veccat([mpc['x'], mpc['v'], mpc['u']])) mpc.minimizeLsqEndTerm(C.veccat([mpc['x'], mpc['v']])) cgOpts = {'CXX': 'g++', 'CC': 'gcc'} return rawe.OcpRT(mpc, ocpOptions=ocpOpts, integratorOptions=intOpts, codegenOptions=cgOpts)
def makeMhe(dae,N,dt): from rawe.ocp import Ocp mhe = Ocp(dae, N=N, ts=dt) ocpOpts = rawe.OcpExportOptions() ocpOpts['HESSIAN_APPROXIMATION'] = 'GAUSS_NEWTON' ocpOpts['DISCRETIZATION_TYPE'] = 'MULTIPLE_SHOOTING' ocpOpts['QP_SOLVER'] = 'QP_QPOASES' ocpOpts['HOTSTART_QP'] = False ocpOpts['SPARSE_QP_SOLUTION'] = 'CONDENSING' # ocpOpts['SPARSE_QP_SOLUTION'] = 'FULL_CONDENSING_U2' # ocpOpts['AX_NUM_QP_ITERATIONS'] = '30' ocpOpts['FIX_INITIAL_STATE'] = False # mhe.minimizeLsq(C.veccat([mhe['x'],mhe['u']])) # mhe.minimizeLsqEndTerm(C.veccat([mhe['x']])) mhe.minimizeLsq(mhe['measurements']) mhe.minimizeLsqEndTerm(mhe['measurementsN']) cgOpts = {'CXX':'g++', 'CC':'gcc'} print "makeMhe calling rawe.OcpRT" return rawe.OcpRT(mhe, ocpOptions=ocpOpts, integratorOptions=intOpts, codegenOptions=cgOpts)
mpc.constrain(mpc['vel'], '<=', 0.2) mpc.constrain(-0.1, '<=', mpc['force'], '<=', 0.1) mpc.minimizeLsq(C.veccat([mpc['pos'], mpc['vel'], mpc['force']])) mpc.minimizeLsqEndTerm(C.veccat([mpc['pos'], mpc['vel']])) # cgOpts = {'CXX':'clang++', 'CC':'clang'} cgOpts = {'CXX': 'g++', 'CC': 'gcc'} # cgOpts = {'CXX':'icpc', 'CC':'icc'} phase1Opts = {'CXX': 'g++'} intOpts = rawe.RtIntegratorOptions() intOpts['INTEGRATOR_TYPE'] = 'INT_IRK_RIIA3' intOpts['NUM_INTEGRATOR_STEPS'] = 5 ocpOpts = rawe.OcpExportOptions() ocpOpts['QP_SOLVER'] = "QP_QPOASES" ocpOpts['SPARSE_QP_SOLUTION'] = "CONDENSING" # ocpOpts['SPARSE_QP_SOLUTION'] = "FULL_CONDENSING" # ocpOpts['SPARSE_QP_SOLUTION'] = "SPARSE_SOLVER" # ocpOpts['QP_SOLVER'] = "QP_QPDUNES" ocpOpts["FIX_INITIAL_STATE"] = True ocpOpts["HOTSTART_QP"] = True # ocpOpts['GENERATE_MATLAB_INTERFACE'] = True ocpRt = rawe.OcpRT(mpc, ocpOptions=ocpOpts, integratorOptions=intOpts, codegenOptions=cgOpts, phase1Options=phase1Opts) print '=' * 80