def makeMhe(dae, N, ts): mhe = rawe.ocp.Ocp(dae, N=N, ts=ts, yxNames=['pos', 'vel'], yuNames=[]) # cgOpts = {'CXX':'clang++', 'CC':'clang'} cgOpts = {'CXX': 'g++', 'CC': 'gcc'} # cgOpts = {'CXX':'icpc', 'CC':'icc'} return rawe.OcpRT(mhe, codegenOptions=cgOpts)
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 makeMhe(dae, N, ts): mhe = rawe.ocp.Ocp(dae, N=N, ts=ts) mhe.minimizeLsq([mhe['pos'],mhe['vel']]) mhe.minimizeLsqEndTerm([mhe['pos'],mhe['vel']]) # cgOpts = {'CXX':'clang++', 'CC':'clang'} cgOpts = {'CXX':'g++', 'CC':'gcc'} # cgOpts = {'CXX':'icpc', 'CC':'icc'} return rawe.OcpRT(mhe, 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)
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 # set the cost hessians # xRms = 0.2 # vRms = 0.2 # fRms = 20 ocpRt.S[0, 0] = 1.0 #/(xRms*N)**2 ocpRt.S[1, 1] = 1.0 #/(vRms*N)**2 ocpRt.S[2, 2] = 1.0 #/(fRms*N)**2 ocpRt.SN[0, 0] = 1.0 #/(xRms*N)**2 ocpRt.SN[1, 1] = 1.0 #/(vRms*N)**2