本文整理汇总了C++中setOption函数的典型用法代码示例。如果您正苦于以下问题:C++ setOption函数的具体用法?C++ setOption怎么用?C++ setOption使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setOption函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setOption
void WorhpInternal::setQPOptions() {
setOption("UserHM", true);
}
示例2: setOption
bool setOption(T &option,
std::string flagStr,
const std::string &shortDescription,
bool required = false) {
return setOption(option, flagStr, shortDescription, required, "Misc");
}
示例3: setOption
void Magick::Options::textInterwordSpacing(double spacing_)
{
_drawInfo->interword_spacing=spacing_;
setOption("interword-spacing",spacing_);
}
示例4: Q_D
/*!
Initializes a QNativeSocketEngine by creating a new socket of type \a
socketType and network layer protocol \a protocol. Returns true on
success; otherwise returns false.
If the socket was already initialized, this function closes the
socket before reeinitializing it.
The new socket is non-blocking, and for UDP sockets it's also
broadcast enabled.
*/
bool QNativeSocketEngine::initialize(QAbstractSocket::SocketType socketType, QAbstractSocket::NetworkLayerProtocol protocol)
{
Q_D(QNativeSocketEngine);
if (isValid())
close();
#if defined(QT_NO_IPV6)
if (protocol == QAbstractSocket::IPv6Protocol) {
d->setError(QAbstractSocket::UnsupportedSocketOperationError,
QNativeSocketEnginePrivate::NoIpV6ErrorString);
return false;
}
#endif
// Create the socket
if (!d->createNewSocket(socketType, protocol)) {
#if defined (QNATIVESOCKETENGINE_DEBUG)
QString typeStr = QLatin1String("UnknownSocketType");
if (socketType == QAbstractSocket::TcpSocket) typeStr = QLatin1String("TcpSocket");
else if (socketType == QAbstractSocket::UdpSocket) typeStr = QLatin1String("UdpSocket");
QString protocolStr = QLatin1String("UnknownProtocol");
if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = QLatin1String("IPv4Protocol");
else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = QLatin1String("IPv6Protocol");
qDebug("QNativeSocketEngine::initialize(type == %s, protocol == %s) failed: %s",
typeStr.toLatin1().constData(), protocolStr.toLatin1().constData(), d->socketErrorString.toLatin1().constData());
#endif
return false;
}
// Make the socket nonblocking.
if (!setOption(NonBlockingSocketOption, 1)) {
d->setError(QAbstractSocket::UnsupportedSocketOperationError,
QNativeSocketEnginePrivate::NonBlockingInitFailedErrorString);
close();
return false;
}
// Set the broadcasting flag if it's a UDP socket.
if (socketType == QAbstractSocket::UdpSocket
&& !setOption(BroadcastSocketOption, 1)) {
d->setError(QAbstractSocket::UnsupportedSocketOperationError,
QNativeSocketEnginePrivate::BroadcastingInitFailedErrorString);
close();
return false;
}
// Make sure we receive out-of-band data
// On Symbian OS this works only with native IP stack, not with WinSock
if (socketType == QAbstractSocket::TcpSocket
&& !setOption(ReceiveOutOfBandData, 1)) {
qWarning("QNativeSocketEngine::initialize unable to inline out-of-band data");
}
// Before Qt 4.6, we always set the send and receive buffer size to 49152 as
// this was found to be an optimal value. However, modern OS
// all have some kind of auto tuning for this and we therefore don't set
// this explictly anymore.
// If it introduces any performance regressions for Qt 4.6.x (x > 0) then
// it will be put back in.
//
// You can use tests/manual/qhttpnetworkconnection to test HTTP download speed
// with this.
//
// pre-4.6:
// setReceiveBufferSize(49152);
// setSendBufferSize(49152);
d->socketType = socketType;
d->socketProtocol = protocol;
return true;
}
示例5: setOption
void OptionsFunctionalityNode::copyOptions(const OptionsFunctionality& obj){
setOption(obj.dictionary());
}
示例6: setOption
void QPlatformWindowFormat::setDoubleBuffer(bool enable)
{
setOption(enable ? QPlatformWindowFormat::DoubleBuffer : QPlatformWindowFormat::SingleBuffer);
}
示例7: setOption
/*!
Sets the size of the operating system receive buffer to \a size.
The operating system receive buffer size effectively limits two
things: how much data can be in transit at any one moment, and how
much data can be received in one iteration of the main event loop.
The default is operating system-dependent. A socket that receives
large amounts of data is probably best with a buffer size of
49152.
*/
void Q3SocketDevice::setReceiveBufferSize( uint size )
{
setOption( ReceiveBuffer, size );
}
示例8: number
/*!
Sets the address of this socket to be usable by other sockets too
if \a enable is true, and to be used exclusively by this socket if
\a enable is false.
When a socket is reusable, other sockets can use the same port
number (and IP address), which is generally useful. Of course
other sockets cannot use the same
(address,port,peer-address,peer-port) 4-tuple as this socket, so
there is no risk of confusing the two TCP connections.
\sa addressReusable()
*/
void Q3SocketDevice::setAddressReusable( bool enable )
{
setOption( ReuseAddress, enable );
}
示例9: strcpy
void WorhpInternal::setOptionsFromFile(const std::string & file) {
int status;
char *cpy = new char[file.size()+1] ;
strcpy(cpy, file.c_str());
worhp_p_.initialised = true;
ReadParamsNoInit(&status, cpy, &worhp_p_);
delete cpy;
for (int i=0;i<WorhpGetParamCount();++i) {
WorhpType type = WorhpGetParamType(i+1);
const char* name = WorhpGetParamName(i+1);
if (strcmp(name,"Ares")==0) continue;
switch(type) {
case WORHP_BOOL_T:
bool default_bool;
WorhpGetBoolParam(&worhp_p_, name, &default_bool);
setOption(WorhpGetParamName(i+1),default_bool);
break;
case WORHP_DOUBLE_T:
double default_double;
WorhpGetDoubleParam(&worhp_p_, name, &default_double);
setOption(WorhpGetParamName(i+1),default_double);
break;
case WORHP_INT_T:
int default_int;
WorhpGetIntParam(&worhp_p_, name, &default_int);
setOption(WorhpGetParamName(i+1),default_int);
break;
default:
break; // do nothing
}
}
setOption("qp_ipBarrier",worhp_p_.qp.ipBarrier);
setOption("qp_ipComTol",worhp_p_.qp.ipComTol);
setOption("qp_ipFracBound",worhp_p_.qp.ipFracBound);
setOptionByEnumValue("qp_ipLsMethod",worhp_p_.qp.ipLsMethod );
setOption("qp_ipMinAlpha",worhp_p_.qp.ipMinAlpha);
setOption("qp_ipTryRelax",worhp_p_.qp.ipTryRelax);
setOption("qp_ipRelaxDiv",worhp_p_.qp.ipRelaxDiv);
setOption("qp_ipRelaxMult",worhp_p_.qp.ipRelaxMult);
setOption("qp_ipRelaxMax",worhp_p_.qp.ipRelaxMax);
setOption("qp_ipRelaxMin",worhp_p_.qp.ipRelaxMin);
setOption("qp_ipResTol",worhp_p_.qp.ipResTol);
setOption("qp_lsItMaxIter",worhp_p_.qp.lsItMaxIter);
setOptionByEnumValue("qp_lsItMethod",worhp_p_.qp.lsItMethod );
setOptionByEnumValue("qp_lsItPrecondMethod",worhp_p_.qp.lsItPrecondMethod );
setOption("qp_lsRefineMaxIter",worhp_p_.qp.lsRefineMaxIter);
setOption("qp_lsScale",worhp_p_.qp.lsScale);
setOption("qp_lsTrySimple",worhp_p_.qp.lsTrySimple);
setOption("qp_lsTol",worhp_p_.qp.lsTol);
setOption("qp_maxIter",worhp_p_.qp.maxIter);
setOptionByEnumValue("qp_method",worhp_p_.qp.method );
setOption("qp_nsnBeta",worhp_p_.qp.nsnBeta);
setOption("qp_nsnGradStep",worhp_p_.qp.nsnGradStep);
setOption("qp_nsnKKT",worhp_p_.qp.nsnKKT);
setOptionByEnumValue("qp_nsnLsMethod",worhp_p_.qp.nsnLsMethod );
setOption("qp_nsnMinAlpha",worhp_p_.qp.nsnMinAlpha);
setOption("qp_nsnSigma",worhp_p_.qp.nsnSigma);
setOptionByEnumValue("qp_printLevel",worhp_p_.qp.printLevel );
setOption("qp_scaleIntern",worhp_p_.qp.scaleIntern);
setOption("qp_strict",worhp_p_.qp.strict);
std::cout << "readparams status: " << status << std::endl;
}
示例10: NLPSolverInternal
WorhpInternal::WorhpInternal(const Function& nlp) : NLPSolverInternal(nlp){
// Monitors
addOption("monitor", OT_STRINGVECTOR, GenericType(), "Monitor functions", "eval_f|eval_g|eval_jac_g|eval_grad_f|eval_h", true);
addOption("print_time", OT_BOOLEAN, true, "Print information about execution time");
int status;
InitParams(&status, &worhp_p_);
std::stringstream ss;
ss << "Armijo recovery strategies. Vector of size " << NAres;
std::vector<int> ares(NAres);
std::copy(worhp_p_.Ares,worhp_p_.Ares+NAres,ares.begin());
addOption("Ares",OT_INTEGERVECTOR,ares,ss.str());
for (int i=0;i<WorhpGetParamCount();++i) {
WorhpType type = WorhpGetParamType(i+1);
const char* name = WorhpGetParamName(i+1);
if (strcmp(name,"Ares")==0) continue;
switch(type) {
case WORHP_BOOL_T:
bool default_bool;
WorhpGetBoolParam(&worhp_p_, name, &default_bool);
addOption(WorhpGetParamName(i+1),OT_BOOLEAN,default_bool,WorhpGetParamDescription(i+1));
break;
case WORHP_DOUBLE_T:
double default_double;
WorhpGetDoubleParam(&worhp_p_, name, &default_double);
addOption(WorhpGetParamName(i+1),OT_REAL,default_double,WorhpGetParamDescription(i+1));
break;
case WORHP_INT_T:
int default_int;
WorhpGetIntParam(&worhp_p_, name, &default_int);
addOption(WorhpGetParamName(i+1),OT_INTEGER,default_int,WorhpGetParamDescription(i+1));
break;
default:
break;// do nothing
}
}
addOption("qp_ipBarrier",OT_REAL,worhp_p_.qp.ipBarrier,"IP barrier parameter.");
addOption("qp_ipComTol",OT_REAL,worhp_p_.qp.ipComTol,"IP complementarity tolerance.");
addOption("qp_ipFracBound",OT_REAL,worhp_p_.qp.ipFracBound,"IP fraction-to-the-boundary parameter.");
addOption("qp_ipLsMethod",OT_STRING,GenericType(),"Select the direct linear solver used by the IP method.","LAPACK::0|MA57: only available if provided by the user:1|SuperLU::2|PARDISO: only available if provided by the user, subject to license availability:3|MUMPS: currently Linux platforms only:5|WSMP: subject to license availability:6|MA86: experimental, only available if provided by the user:7|MA97:experimental, only available if provided by the user:8");
setOptionByEnumValue("qp_ipLsMethod",worhp_p_.qp.ipLsMethod);
addOption("qp_ipMinAlpha",OT_REAL,worhp_p_.qp.ipMinAlpha,"IP line search minimum step size.");
addOption("qp_ipTryRelax",OT_BOOLEAN,worhp_p_.qp.ipTryRelax,"Enable relaxation strategy when encountering an error.");
addOption("qp_ipRelaxDiv",OT_REAL,worhp_p_.qp.ipRelaxDiv,"The relaxation term is divided by this value if successful.");
addOption("qp_ipRelaxMult",OT_REAL,worhp_p_.qp.ipRelaxMult,"The relaxation term is multiplied by this value if unsuccessful.");
addOption("qp_ipRelaxMax",OT_REAL,worhp_p_.qp.ipRelaxMax,"Maximum relaxation value.");
addOption("qp_ipRelaxMin",OT_REAL,worhp_p_.qp.ipRelaxMin,"Mimimum relaxation value.");
addOption("qp_ipResTol",OT_REAL,worhp_p_.qp.ipResTol,"IP residuals tolerance.");
addOption("qp_lsItMaxIter",OT_INTEGER,worhp_p_.qp.lsItMaxIter,"Maximum number of iterations of the iterative linear solvers.");
addOption("qp_lsItMethod",OT_STRING,GenericType(),"Select the iterative linear solver.","none:Deactivate; use a direct linear solver.:0|CGNR::1|CGNE::2|CGS::3|BiCGSTAB::4");
setOptionByEnumValue("qp_lsItMethod",worhp_p_.qp.lsItMethod);
addOption("qp_lsItPrecondMethod",OT_STRING,GenericType(),"Select preconditioner for the iterative linear solver.","none:No preconditioner.:0|static:Static preconditioner (KKT-matrix with constant lower-right block).:1|full:Full KKT-matrix.:2");
setOptionByEnumValue("qp_lsItPrecondMethod",worhp_p_.qp.lsItPrecondMethod);
addOption("qp_lsRefineMaxIter",OT_INTEGER,worhp_p_.qp.lsRefineMaxIter,"Maximum number of iterative refinement steps of the direct linear solvers.");
addOption("qp_lsScale",OT_BOOLEAN,worhp_p_.qp.lsScale,"Enables scaling on linear solver level.");
addOption("qp_lsTrySimple",OT_BOOLEAN,worhp_p_.qp.lsTrySimple,"Some matrices can be solved without calling a linear equation solver.Currently only diagonal matrices are supported. Non-diagonal matrices will besolved with the chosen linear equation solver.");
addOption("qp_lsTol",OT_REAL,worhp_p_.qp.lsTol,"Tolerance for the linear solver.");
addOption("qp_maxIter",OT_INTEGER,worhp_p_.qp.maxIter,"Imposes an upper limit on the number of minor solver iterations, i.e. for thequadratic subproblem solver. If the limit is reached before convergence,WORHP will activate QP recovery strategies to prevent a solver breakdown.");
addOption("qp_method",OT_STRING,GenericType(),"Select the solution method used by the QP solver.","ip:Interior-Point method.:1|nsn:Nonsmooth-Newton method.:2|automatic: Prefer IP and fall back to NSN on error.:12");
setOptionByEnumValue("qp_method",worhp_p_.qp.method);
addOption("qp_nsnBeta",OT_REAL,worhp_p_.qp.nsnBeta,"NSN stepsize decrease factor.");
addOption("qp_nsnGradStep",OT_BOOLEAN,worhp_p_.qp.nsnGradStep,"Enable gradient steps in the NSN method.");
addOption("qp_nsnKKT",OT_REAL,worhp_p_.qp.nsnKKT,"NSN KKT tolerance.");
addOption("qp_nsnLsMethod",OT_STRING,GenericType(),"Select the direct linear solver used by the NSN method.","SuperLU::2|MA48: only available if provided by the user:4");
setOptionByEnumValue("qp_nsnLsMethod",worhp_p_.qp.nsnLsMethod);
addOption("qp_nsnMinAlpha",OT_REAL,worhp_p_.qp.nsnMinAlpha,"NSN line search minimum step size.");
addOption("qp_nsnSigma",OT_REAL,worhp_p_.qp.nsnSigma,"NSN line search slope parameter.");
addOption("qp_printLevel",OT_STRING,GenericType(),"Controls the amount of QP solver output.","none:No output.:0|warn:Print warnings and errors.:1|iterations:Print iterations.:2");
setOptionByEnumValue("qp_printLevel",worhp_p_.qp.printLevel);
addOption("qp_scaleIntern",OT_BOOLEAN,worhp_p_.qp.scaleIntern,"Enable scaling on QP level.");
addOption("qp_strict",OT_BOOLEAN,worhp_p_.qp.strict,"Use strict termination criteria in IP method.");
worhp_o_.initialised = false;
worhp_w_.initialised = false;
worhp_p_.initialised = false;
worhp_c_.initialised = false;
// WORKAROUND: Bug in scaling, set to false by default // FIXME
setOption("ScaledObj",false);
// WORKAROUND: Why is this needed? // FIXME
setOption("ScaleConIter",true);
}
示例11: main
int main(int argn, char* argv[])
{
LXQt::SingleApplication app(argn, argv);
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
// Command line options
QCommandLineParser parser;
parser.setApplicationDescription(QStringLiteral("LXQt Config Brightness"));
const QString VERINFO = QStringLiteral(LXQT_CONFIG_VERSION
"\nliblxqt " LXQT_VERSION
"\nQt " QT_VERSION_STR);
app.setApplicationVersion(VERINFO);
QCommandLineOption increaseOption(QStringList() << "i" << "icrease",
app.tr("Increase brightness."));
parser.addOption(increaseOption);
QCommandLineOption decreaseOption(QStringList() << "d" << "decrease",
app.tr("Decrease brightness."));
parser.addOption(decreaseOption);
QCommandLineOption setOption(QStringList() << "s" << "set",
app.tr("Set brightness from 1 to 100."), "brightness");
parser.addOption(setOption);
QCommandLineOption helpOption = parser.addHelpOption();
parser.addOption(increaseOption);
parser.addOption(decreaseOption);
parser.addOption(setOption);
parser.addOption(helpOption);
parser.addVersionOption();
parser.process(app);
if( parser.isSet(increaseOption) || parser.isSet(decreaseOption) || parser.isSet(setOption) )
{
XRandrBrightness *brightness = new XRandrBrightness();
QList<MonitorInfo> monitors = brightness->getMonitorsInfo();
QList<MonitorInfo> monitorsChanged;
float sign = parser.isSet(decreaseOption)?-1.0:1.0;
double brightness_value = parser.value(setOption).toFloat();
brightness_value = qMin( qMax(brightness_value, 0.0), 100.0 ) / 100.0;
if(!parser.value(setOption).isEmpty())
sign = 0.0;
foreach(MonitorInfo monitor, monitors)
{
if( monitor.isBacklightSupported() )
{
long backlight = ( monitor.backlight() + sign*(monitor.backlightMax()/50 + 1) )*qAbs(sign) + brightness_value*monitor.backlightMax();
if(backlight<monitor.backlightMax() && backlight>0)
{
monitor.setBacklight(backlight);
monitorsChanged.append(monitor);
}
}
else
{
float brightness = (monitor.brightness() + 0.1*sign)*qAbs(sign) + brightness_value*2.0;
if(brightness<2.0 && brightness>0.0)
{
monitor.setBrightness(brightness);
monitorsChanged.append(monitor);
}
}
}
brightness->setMonitorsSettings(monitorsChanged);
return 0;
}
示例12: sampleBuffers
/*!
If \a enable is true, a GL context with multisample buffer support
is picked; otherwise ignored.
\sa sampleBuffers(), setSamples(), samples()
*/
void QPlatformWindowFormat::setSampleBuffers(bool enable)
{
setOption(enable ? QPlatformWindowFormat::SampleBuffers : QPlatformWindowFormat::NoSampleBuffers);
}
示例13: getOption
void SQPInternal::init(){
// Call the init method of the base class
NLPSolverInternal::init();
// Read options
maxiter_ = getOption("maxiter");
maxiter_ls_ = getOption("maxiter_ls");
c1_ = getOption("c1");
beta_ = getOption("beta");
merit_memsize_ = getOption("merit_memory");
lbfgs_memory_ = getOption("lbfgs_memory");
tol_pr_ = getOption("tol_pr");
tol_du_ = getOption("tol_du");
regularize_ = getOption("regularize");
if(getOption("hessian_approximation")=="exact")
hess_mode_ = HESS_EXACT;
else if(getOption("hessian_approximation")=="limited-memory")
hess_mode_ = HESS_BFGS;
if (hess_mode_== HESS_EXACT && H_.isNull()) {
if (!getOption("generate_hessian")){
casadi_error("SQPInternal::evaluate: you set option 'hessian_approximation' to 'exact', but no hessian was supplied. Try with option \"generate_hessian\".");
}
}
// If the Hessian is generated, we use exact approximation by default
if (bool(getOption("generate_hessian"))){
setOption("hessian_approximation", "exact");
}
// Allocate a QP solver
CRSSparsity H_sparsity = hess_mode_==HESS_EXACT ? H_.output().sparsity() : sp_dense(n_,n_);
H_sparsity = H_sparsity + DMatrix::eye(n_).sparsity();
CRSSparsity A_sparsity = J_.isNull() ? CRSSparsity(0,n_,false) : J_.output().sparsity();
QPSolverCreator qp_solver_creator = getOption("qp_solver");
qp_solver_ = qp_solver_creator(H_sparsity,A_sparsity);
// Set options if provided
if(hasSetOption("qp_solver_options")){
Dictionary qp_solver_options = getOption("qp_solver_options");
qp_solver_.setOption(qp_solver_options);
}
qp_solver_.init();
// Lagrange multipliers of the NLP
mu_.resize(m_);
mu_x_.resize(n_);
// Lagrange gradient in the next iterate
gLag_.resize(n_);
gLag_old_.resize(n_);
// Current linearization point
x_.resize(n_);
x_cand_.resize(n_);
x_old_.resize(n_);
// Constraint function value
gk_.resize(m_);
gk_cand_.resize(m_);
// Hessian approximation
Bk_ = DMatrix(H_sparsity);
// Jacobian
Jk_ = DMatrix(A_sparsity);
// Bounds of the QP
qp_LBA_.resize(m_);
qp_UBA_.resize(m_);
qp_LBX_.resize(n_);
qp_UBX_.resize(n_);
// QP solution
dx_.resize(n_);
qp_DUAL_X_.resize(n_);
qp_DUAL_A_.resize(m_);
// Gradient of the objective
gf_.resize(n_);
// Create Hessian update function
if(hess_mode_ == HESS_BFGS){
// Create expressions corresponding to Bk, x, x_old, gLag and gLag_old
SXMatrix Bk = ssym("Bk",H_sparsity);
SXMatrix x = ssym("x",input(NLP_X_INIT).sparsity());
SXMatrix x_old = ssym("x",x.sparsity());
SXMatrix gLag = ssym("gLag",x.sparsity());
SXMatrix gLag_old = ssym("gLag_old",x.sparsity());
SXMatrix sk = x - x_old;
SXMatrix yk = gLag - gLag_old;
SXMatrix qk = mul(Bk, sk);
// Calculating theta
SXMatrix skBksk = inner_prod(sk, qk);
SXMatrix omega = if_else(inner_prod(yk, sk) < 0.2 * inner_prod(sk, qk),
0.8 * skBksk / (skBksk - inner_prod(sk, yk)),
1);
//.........这里部分代码省略.........
示例14: setOption
void SocketImpl::setBroadcast(bool flag)
{
int value = flag ? 1 : 0;
setOption(SOL_SOCKET, SO_BROADCAST, value);
}