示例#1
0
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)
示例#2
0
文件: NMPC.py 项目: psinha/rawesome
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# rawesome is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with rawesome.  If not, see <http://www.gnu.org/licenses/>.

import rawe
import casadi as C

intOpts = rawe.RtIntegratorOptions()
intOpts['INTEGRATOR_TYPE'] = 'INT_IRK_GL2'
intOpts['NUM_INTEGRATOR_STEPS'] = 40
intOpts['IMPLICIT_INTEGRATOR_NUM_ITS'] = 3
intOpts['IMPLICIT_INTEGRATOR_NUM_ITS_INIT'] = 0
intOpts['LINEAR_ALGEBRA_SOLVER'] = 'HOUSEHOLDER_QR'
intOpts['UNROLL_LINEAR_SOLVER'] = False
intOpts['IMPLICIT_INTEGRATOR_MODE'] = 'IFTR'


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'