本文整理匯總了Python中qpoases.PyOptions.enableRegularisation方法的典型用法代碼示例。如果您正苦於以下問題:Python PyOptions.enableRegularisation方法的具體用法?Python PyOptions.enableRegularisation怎麽用?Python PyOptions.enableRegularisation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qpoases.PyOptions
的用法示例。
在下文中一共展示了PyOptions.enableRegularisation方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: solveLeastSquare
# 需要導入模塊: from qpoases import PyOptions [as 別名]
# 或者: from qpoases.PyOptions import enableRegularisation [as 別名]
def solveLeastSquare(A, b, lb=None, ub=None, A_in=None, lb_in=None, ub_in=None):
n = A.shape[1];
m_in = 0;
if(A_in!=None):
m_in = A_in.shape[0];
if(lb_in==None):
lb_in = np.array(m_in*[-1e99]);
if(ub_in==None):
ub_in = np.array(m_in*[1e99]);
if(lb==None):
lb = np.array(n*[-1e99]);
if(ub==None):
ub = np.array(n*[1e99]);
Hess = np.dot(A.transpose(),A);
grad = -np.dot(A.transpose(),b);
maxActiveSetIter = np.array([100+2*m_in+2*n]);
maxComputationTime = np.array([600.0]);
options = Options();
options.printLevel = PrintLevel.LOW; #NONE, LOW, MEDIUM
options.enableRegularisation = True;
print 'Gonna solve QP...';
if(m_in==0):
qpOasesSolver = QProblemB(n); #, HessianType.SEMIDEF);
qpOasesSolver.setOptions(options);
imode = qpOasesSolver.init(Hess, grad, lb, ub, maxActiveSetIter, maxComputationTime);
else:
qpOasesSolver = SQProblem(n, m_in); #, HessianType.SEMIDEF);
qpOasesSolver.setOptions(options);
imode = qpOasesSolver.init(Hess, grad, A_in, lb, ub, lb_in, ub_in, maxActiveSetIter, maxComputationTime);
# print 'QP solved in %f seconds and %d iterations' % (maxComputationTime[0],maxActiveSetIter[0]);
if(imode!=0 and imode!=63):
print "ERROR Qp oases %d " % (imode);
x_norm = np.zeros(n); # solution of the normalized problem
qpOasesSolver.getPrimalSolution(x_norm);
return x_norm;