├── .github └── workflows │ ├── globlib.yml │ └── matlab.yml ├── .gitignore ├── @sdpvar ├── abs.m ├── accumarray.m ├── acos.m ├── acosh.m ├── acot.m ├── acoth.m ├── acsc.m ├── acsch.m ├── airy.m ├── and.m ├── any.m ├── asec.m ├── asech.m ├── asin.m ├── asinh.m ├── assign.m ├── atan.m ├── atan2.m ├── atanh.m ├── beta.m ├── binary.m ├── blkdiag.m ├── bounds.m ├── brutepersp.m ├── bsxfun.m ├── cat.m ├── ceil.m ├── circshift.m ├── clean.m ├── clear_poly_dep.m ├── clearconic.m ├── clearconicinfo.m ├── clearcreationtime.m ├── clearsdpvar.m ├── colamd.m ├── cone.m ├── conj.m ├── conv.m ├── convexhull.m ├── cos.m ├── cosh.m ├── cot.m ├── coth.m ├── crossentropy.m ├── csc.m ├── csch.m ├── ctranspose.m ├── cumsum.m ├── cumtrapz.m ├── cut.m ├── dct.m ├── deadhub.m ├── deepdepends.m ├── degreduce.m ├── degree.m ├── depends.m ├── det.m ├── diag.m ├── diff.m ├── display.m ├── dissect.m ├── domain.m ├── double.m ├── eig.m ├── eliminateBinary.m ├── ellipke.m ├── end.m ├── eq.m ├── erf.m ├── erfc.m ├── erfcinv.m ├── erfcx.m ├── erfinv.m ├── exclude.m ├── exp.m ├── expanded.m ├── expcone.m ├── expint.m ├── exponents.m ├── false.m ├── fft.m ├── find.m ├── findelements.m ├── fix.m ├── fliplr.m ├── flipud.m ├── floor.m ├── gamma.m ├── gammainc.m ├── gammaincinv.m ├── gammaln.m ├── ge.m ├── generateAB.m ├── geomean.m ├── getbase.m ├── getbasematrix.m ├── getbasematrixwithoutcheck.m ├── getbasevectorwithoutcheck.m ├── gethackflag.m ├── getsosrank.m ├── getvariables.m ├── getvariablesvector.m ├── getvectorvariables.m ├── gt.m ├── hankel.m ├── harmmean.m ├── homogenize.m ├── horzcat.m ├── ifft.m ├── imag.m ├── imag2real.m ├── int.m ├── integer.m ├── interp1.m ├── interp2.m ├── inv.m ├── invsathub.m ├── is.m ├── isconvex.m ├── isequal.m ├── ishermitian.m ├── isinteger.m ├── isinterval.m ├── islinear.m ├── ismember.m ├── ismember_internal.m ├── isreal.m ├── issquare.m ├── issymmetric.m ├── jacobian.m ├── kron.m ├── kyp.m ├── lambertw.m ├── le.m ├── length.m ├── lift2real.m ├── linearize.m ├── linspace.m ├── lmior.m ├── lmixor.m ├── loadobj.m ├── log.m ├── log10.m ├── log2.m ├── lt.m ├── matrixpolynomial.m ├── max.m ├── median.m ├── mid.m ├── min.m ├── minimize.m ├── minus.m ├── mldivide.m ├── mod.m ├── model.m ├── mpower.m ├── mrdivide.m ├── mtimes.m ├── mvncdf.m ├── nchoosek.m ├── ncvar.m ├── ndims.m ├── ne.m ├── nnz.m ├── nonlineartocone.m ├── norm.m ├── norminv.m ├── not.m ├── numel.m ├── or.m ├── parametric.m ├── pcone.m ├── permutation.m ├── permute.m ├── plot.m ├── plus.m ├── poly.m ├── polynomial.m ├── polytope.m ├── pow10.m ├── pow2.m ├── powcone.m ├── power.m ├── powercone.m ├── prod.m ├── psi.m ├── pwa.m ├── pwadynamics.m ├── pwamodel.m ├── pwaproj.m ├── pwaprojUnc.m ├── quaddecomp.m ├── quickrecover.m ├── rad.m ├── rank.m ├── rational.m ├── rcone.m ├── rdivide.m ├── real.m ├── recovermonoms.m ├── registerjacobian.m ├── relaxdouble.m ├── relaxvalue.m ├── rem.m ├── remap.m ├── replace.m ├── repmat.m ├── reshape.m ├── rot90.m ├── round.m ├── saveobj.m ├── sdpcone.m ├── sdpvar.m ├── sdpvarfun.m ├── sec.m ├── sech.m ├── see.m ├── semicont.m ├── set.m ├── setbase.m ├── sethackflag.m ├── setoperatorname.m ├── setsos.m ├── shiftdim.m ├── sign.m ├── simplify.m ├── sin.m ├── sinh.m ├── size.m ├── socpcone.m ├── sort.m ├── sos.m ├── sos1.m ├── sos2.m ├── sosd.m ├── sparse.m ├── spdiags.m ├── spy.m ├── sqr.m ├── sqrt.m ├── sqrtm.m ├── sqrtm_internal.m ├── stackcell.m ├── std.m ├── subsasgn.m ├── subsref.m ├── sum.m ├── sumsum.m ├── sym.m ├── symamd.m ├── tan.m ├── tanh.m ├── times.m ├── toeplitz.m ├── trace.m ├── transpose.m ├── trapz.m ├── tril.m ├── triu.m ├── true.m ├── uminus.m ├── uncertain.m ├── unique.m ├── uplus.m ├── value.m ├── var.m ├── variablereplace.m ├── vec.m ├── vec_replace.m ├── vertcat.m ├── warmstart.m ├── xor.m └── zeros.m ├── Contents.m ├── README.txt ├── demos └── readme.txt ├── extras ├── @blkvar │ ├── blkvar.m │ ├── display.m │ ├── sdisplay.m │ ├── sdpvar.m │ └── subsasgn.m ├── @constraint │ ├── and.m │ ├── assignschur.m │ ├── boundingbox.m │ ├── chebyball.m │ ├── check.m │ ├── checkset.m │ ├── clean.m │ ├── colon.m │ ├── complements.m │ ├── constraint.m │ ├── cut.m │ ├── depends.m │ ├── display.m │ ├── dissect.m │ ├── double.m │ ├── dual.m │ ├── eq.m │ ├── flatten.m │ ├── ge.m │ ├── getbase.m │ ├── getbounds.m │ ├── getcutflag.m │ ├── getlist.m │ ├── getvariables.m │ ├── horzcat.m │ ├── hull.m │ ├── is.m │ ├── ismember.m │ ├── isreal.m │ ├── kkt.m │ ├── le.m │ ├── loadobj.m │ ├── lowrank.m │ ├── nnz.m │ ├── not.m │ ├── or.m │ ├── plot.m │ ├── plotlattice.m │ ├── plus.m │ ├── polyhedron.m │ ├── polytope.m │ ├── problemclass.m │ ├── projection.m │ ├── replace.m │ ├── saveobj.m │ ├── sdpvar.m │ ├── set.m │ ├── setcutflag.m │ ├── settype.m │ ├── spy.m │ ├── subsref.m │ ├── tag.m │ ├── unblkdiag.m │ ├── uncertain.m │ ├── value.m │ ├── vertcat.m │ └── vertex.m ├── @lmi │ ├── Polyhedron.m │ ├── and.m │ ├── assignschur.m │ ├── boundingbox.m │ ├── categorizeproblem.m │ ├── chanceconstraint.m │ ├── chebyball.m │ ├── check.m │ ├── checkset.m │ ├── clean.m │ ├── clear_poly_dep.m │ ├── cleardual.m │ ├── colon.m │ ├── complements.m │ ├── constraintclass.m │ ├── convertlorentz.m │ ├── convertsocp.m │ ├── cut.m │ ├── degree.m │ ├── depends.m │ ├── display.m │ ├── dissect.m │ ├── double.m │ ├── dual.m │ ├── eliminateBinary.m │ ├── ellipsoid.m │ ├── end.m │ ├── envelope.m │ ├── eq.m │ ├── expanded.m │ ├── expandmeta.m │ ├── extractRandomDefinitions.m │ ├── extractglobalboundsmeta.m │ ├── fastcat.m │ ├── flatten.m │ ├── getComplementarityTerms.m │ ├── getbase.m │ ├── getbounds.m │ ├── getbounds_interval.m │ ├── getcutflag.m │ ├── getlmiid.m │ ├── getlrdata.m │ ├── getvariables.m │ ├── groupchanceconstraints.m │ ├── horzcat.m │ ├── hull.m │ ├── imag2reallmi.m │ ├── imagemodel.m │ ├── indicators.m │ ├── is.m │ ├── isfeasible.m │ ├── isinterval.m │ ├── islinear.m │ ├── ismember.m │ ├── isnan.m │ ├── isreal.m │ ├── isrelaxfeasible.m │ ├── issigmonial.m │ ├── kkt.m │ ├── length.m │ ├── lifted.m │ ├── linearize.m │ ├── lmi.m │ ├── lmi2sdpvar.m │ ├── lmi2sedumistruct.m │ ├── lmiinfo.m │ ├── lmior.m │ ├── loadobj.m │ ├── logic2cont.m │ ├── lowrank.m │ ├── minus.m │ ├── or.m │ ├── plot.m │ ├── plotlattice.m │ ├── plus.m │ ├── polytope.m │ ├── problemclass.m │ ├── projection.m │ ├── pwamodel.m │ ├── reduce.m │ ├── registerjacobian.m │ ├── remap.m │ ├── replace.m │ ├── saveobj.m │ ├── sdpvar.m │ ├── see.m │ ├── set.m │ ├── setcutflag.m │ ├── setdualize.m │ ├── settype.m │ ├── setupMeta.m │ ├── shift.m │ ├── size.m │ ├── sizeOLD.m │ ├── sosd.m │ ├── spy.m │ ├── subsasgn.m │ ├── subsref.m │ ├── tag.m │ ├── uncertain.m │ ├── uplus.m │ ├── usedvariables.m │ ├── value.m │ ├── variablereplace.m │ ├── vertcat.m │ └── vertex.m ├── @logdet │ ├── depends.m │ ├── display.m │ ├── double.m │ ├── getP.m │ ├── getcx.m │ ├── getgain.m │ ├── logdet.m │ ├── minus.m │ ├── mtimes.m │ ├── plus.m │ └── uminus.m ├── @ndsdpvar │ ├── abs.m │ ├── alldifferent.m │ ├── assign.m │ ├── binary.m │ ├── cat.m │ ├── circshift.m │ ├── clean.m │ ├── depends.m │ ├── diff.m │ ├── display.m │ ├── double.m │ ├── end.m │ ├── eq.m │ ├── ge.m │ ├── getbasematrix.m │ ├── gethackflag.m │ ├── getvariables.m │ ├── gt.m │ ├── horzcat.m │ ├── imag.m │ ├── integer.m │ ├── is.m │ ├── isreal.m │ ├── le.m │ ├── length.m │ ├── lt.m │ ├── max.m │ ├── minus.m │ ├── mtimes.m │ ├── ndims.m │ ├── ndsdpvar.m │ ├── numel.m │ ├── permute.m │ ├── plus.m │ ├── power.m │ ├── real.m │ ├── repmat.m │ ├── reshape.m │ ├── sdpvar.m │ ├── see.m │ ├── shiftdim.m │ ├── size.m │ ├── sqrt.m │ ├── squeeze.m │ ├── subsasgn.m │ ├── subsref.m │ ├── sum.m │ ├── times.m │ ├── uminus.m │ ├── value.m │ ├── vec.m │ └── vertcat.m ├── @optimizer │ ├── cat.m │ ├── display.m │ ├── fiordos.m │ ├── horzcat.m │ ├── kkt.m │ ├── loadobj.m │ ├── numel.m │ ├── optimizer.m │ ├── optimizer_precalc.m │ ├── plot.m │ ├── presolve.m │ ├── sample.m │ ├── saveobj.m │ ├── solvemp.m │ ├── subsasgn.m │ ├── subsref.m │ ├── updatemodel.m │ └── vertcat.m ├── @optproblem │ ├── boundingbox.m │ ├── display.m │ ├── feasible.m │ ├── horzcat.m │ ├── isfeasible.m │ ├── kkt.m │ ├── linearize.m │ ├── maximize.m │ ├── minimize.m │ ├── optimize.m │ ├── optimizer.m │ ├── optproblem.m │ ├── robustify.m │ ├── solvebilevel.m │ ├── solvemp.m │ └── subsref.m ├── @probability │ ├── display.m │ ├── ge.m │ ├── horzcat.m │ ├── le.m │ └── probability.m ├── CreateBasicOperator.m ├── InstantiateElementWise.m ├── InstantiateElementWiseUnitary.m ├── NormalizeCallback.m ├── RecoverNonlinearSolverSolution.m ├── addExponentialCone.m ├── addStructureBounds.m ├── adjoint.m ├── allvariables.m ├── alreadydone.m ├── amplexpr.m ├── anyCones.m ├── appendYALMIPvariables.m ├── append_normalized_socp.m ├── apply_recursive_differentiation.m ├── apply_recursive_evaluation.m ├── argmin.m ├── assertOperatorProperties.m ├── assertProperty.m ├── assignschur.m ├── binary.m ├── binmodel.m ├── binvar.m ├── bisection.m ├── bisection_core.m ├── blockdiagmoment.m ├── build_recursive_scheme.m ├── checkfeasiblefast.m ├── clean.m ├── coefficients.m ├── compile_bilinearslist.m ├── compile_quadraticslist.m ├── compileinterfacedata.m ├── compressLifted.m ├── compress_evaluation_scheme.m ├── computedimacs.m ├── convert_perspective_log.m ├── convert_polynomial_to_quadratic.m ├── convert_polynomial_to_sdpfun.m ├── convert_sigmonial_to_sdpfun.m ├── convertlogics.m ├── convertquadratics.m ├── createImagBasis.m ├── createNumericalModel.m ├── createOutputStructure.m ├── create_CHS.m ├── create_HS.m ├── create_trivial_initial.m ├── createobjective.m ├── createsdplibfile.m ├── datasaver.m ├── dd.m ├── deadhub.m ├── dec2decbin.m ├── define.m ├── definecreationtime.m ├── degree.m ├── depends.m ├── derandomize.m ├── derivebounds.m ├── derivedualBounds.m ├── derivedualBoundsParameterFree.m ├── det_internal.m ├── detn.m ├── detset.m ├── dissect_internal.m ├── double2sdpvar.m ├── dsdpdata.m ├── dual2cell.m ├── dualize.m ├── eigv.m ├── eliminatevariables.m ├── ellipplot.m ├── emptyNumericalModel.m ├── endOfLPCone.m ├── even.m ├── expanded.m ├── expandforindex.m ├── expandmodel.m ├── expandrecursive.m ├── expandsos2.m ├── export.m ├── extractConstraints.m ├── extractSemiContBounds.m ├── extract_bounds_from_abs_operator.m ├── extract_bounds_from_max_operator.m ├── extract_bounds_from_milpsubsref_operator.m ├── extract_bounds_from_min_operator.m ├── extract_bounds_from_norm_operator.m ├── extsubsref.m ├── eyev.m ├── findOutWeights.m ├── find_lp_bounds.m ├── find_lp_bounds_interval.m ├── find_variable_bounds.m ├── findapplicablesolvers.m ├── findhash.c ├── findhash.m ├── findhashsorted.c ├── findhashsorted.m ├── findrows.m ├── fiordos_call.m ├── fmincon_con.m ├── fmincon_con_liftlayer.m ├── fmincon_congp.m ├── fmincon_fun.m ├── fmincon_fun_liftlayer.m ├── fmincon_fungp.m ├── fmincon_fungrad.m ├── fmincon_funhessian.m ├── gammainc_a.m ├── gammainc_x.m ├── gammaincinv_a.m ├── gammaincinv_x.m ├── gams2yalmip.m ├── gcdfactor.m ├── gen_rand_hash.m ├── getbase.m ├── getbasematrix.m ├── getexponentbase.m ├── getvariables.m ├── gmset.m ├── hessian.m ├── imagemodel.m ├── int_sdpvar.m ├── integer.m ├── intvar.m ├── invsathub.m ├── ipopt_callback_df.m ├── ipopt_callback_dg.m ├── ipopt_callback_f.m ├── ipopt_callback_g.m ├── ipoptgp_callback_df.m ├── ipoptgp_callback_dg.m ├── ipoptgp_callback_f.m ├── ipoptgp_callback_g.m ├── isVersionRecent.m ├── isconvexmeshdata.m ├── isessentiallyhermitian.m ├── isessentiallysymmetric.m ├── isinterval.m ├── islinear.m ├── ismembcYALMIP.m ├── isoutside.m ├── isoutside_internal.m ├── jacobiansparsityfromnonlinear.m ├── knitro_callback_f.m ├── knitro_callback_g.m ├── lifted.m ├── lmiBasis.m ├── loadsdpafile.m ├── loadsedumidata.m ├── map_to_original.m ├── matrixcoefficients.m ├── mergeNumericalModels.m ├── mid.m ├── milpalreadydone.m ├── milpsubsref.m ├── minimize.m ├── modelComplementarityConstraints.m ├── monolist.m ├── monolistcoeff.m ├── monpowers.m ├── mytestNEW.m ├── mytestOLD.m ├── negateNegativeSemiContVariables.m ├── newvariabletypegen.m ├── nonconvexQuadratic.m ├── nonlinearreplace.m ├── normalizeExponentialCone.m ├── optimize.m ├── parseLMI.m ├── parvar.m ├── penlab_callback_con.m ├── penlab_callback_dcon.m ├── penlab_callback_dcon2.m ├── penlab_callback_df.m ├── penlab_callback_df2.m ├── penlab_callback_dff.m ├── penlab_callback_f.m ├── penlab_callback_matrixG.m ├── penlab_callback_matrixdG.m ├── pennlp_con.m ├── pennlp_congrad.m ├── pennlp_conhess.m ├── pennlp_fun.m ├── pennlp_fungrad.m ├── pennlp_funhess.m ├── pennonm_callback_df.m ├── pennonm_callback_dg.m ├── pennonm_callback_f.m ├── pennonm_callback_g.m ├── plotInternalModel.m ├── plothyperplanes.m ├── plottruss.m ├── portfoliodata.mat ├── portfoliodata.txt ├── precalcgpstruct.m ├── precomputeDerivative.m ├── primalize.m ├── problemclass.m ├── propagateInitial.m ├── propagatex0.m ├── pruneOptions.m ├── prunecplexoptions.m ├── pwasos2.m ├── pwf.m ├── rad.m ├── rand_hash.m ├── randpolytope.m ├── randpsd.m ├── ratingdata.mat ├── reDeclareForBinaryMax.m ├── recdef.m ├── recover.m ├── recovermonoms.m ├── recovernc.m ├── relaxdouble.m ├── relaxvalue.m ├── remove_bounds_from_Ab.m ├── remove_bounds_from_Aeqbeq.m ├── removenonlinearity.m ├── save_model_expansion.m ├── saveampl.m ├── savecplexlp.m ├── savesdpafile.m ├── schurgateway.m ├── sdd.m ├── sdisplay.m ├── sdpsettings.m ├── sdpt3data.m ├── sdpt3struct2sdpt3block.m ├── sdpvar2str.m ├── sdpvarremap.m ├── sedumi2dsdp.m ├── sedumi2dsdp5.m ├── sedumi2maxdet.m ├── sedumi2pen.m ├── sedumi2penbmi.m ├── sedumi2sdpa.m ├── sedumi2sdpt3.m ├── sedumi2yalmip.m ├── see.m ├── selectsolution.m ├── selectsolver.m ├── separable.m ├── setdiff1D.m ├── setduals.m ├── setnonlinearvariables.m ├── setpolynomials.m ├── setupBMIBNB.m ├── setupBNB.m ├── setupBounds.m ├── setup_fmincon_params.m ├── shadowjacobian.m ├── showprogress.m ├── sizestring.m ├── snopt_callback.m ├── snoptgp_callback.m ├── solveequalities.m ├── solverCapable.m ├── solver_can_solve.m ├── solvesdp.m ├── solvesdp_multiple.m ├── splitAndDiagonalize.m ├── splitCones.m ├── stableunique.m ├── startofEXPCone.m ├── startofLPCone.m ├── startofPOWCone.m ├── startofSDPCone.m ├── startofSOCPCone.m ├── strmatch_octavesafe.m ├── threeletterwords.mat ├── unblkdiag.m ├── uncvar.m ├── unionstripped.m ├── uniquesafe.m ├── uniquestripped.m ├── value.m ├── variable_replace.m ├── variablechange.m ├── vecquaddecomp.m ├── vectorizedlogic.m ├── yalmip.m ├── yalmip2geometric.m ├── yalmip2mpt.m ├── yalmip2nonlinearsolver.m ├── yalmipbandwidth.m ├── yalmiperror.m └── yalmiptable.m ├── license.txt ├── modules ├── bilevel │ └── solvebilevel.m ├── dummy.m ├── global │ ├── DeriveMonotonicityFromShape.m │ ├── DeriveMonotonicityFromStationary.m │ ├── DeriveVexityFromInflection.m │ ├── add3x3sdpsymmetrycut.m │ ├── addBilinearVariableCuts.m │ ├── addComplementarityCuts.m │ ├── addConvexityCuts.m │ ├── addDisjointBilinearSDPcut.m │ ├── addEquality.m │ ├── addEvalVariableCuts.m │ ├── addExponentialCuts.m │ ├── addFromProbedBinary.m │ ├── addInequality.m │ ├── addMonomialCuts.m │ ├── addMonomialTowerCuts.m │ ├── addMultipliedEqualityCuts.m │ ├── addMultipliedInequalityCuts.m │ ├── addNormBoundCut.m │ ├── addQuadraticCuts.m │ ├── addSDPextendable.m │ ├── addSinCosCuts.m │ ├── addSquaredLinearEqualityCuts.m │ ├── addSymmetryCuts.m │ ├── addTrivialActivationCuts.m │ ├── add_convex_upper_bound_cut.m │ ├── add_delayedsdpconvexity.m │ ├── add_one_sdp_cut.m │ ├── add_socp_cut.m │ ├── adjustMaxTime.m │ ├── bmibnb.m │ ├── bmibnb_branch_and_bound.m │ ├── bnb.m │ ├── bnb_branch_and_bound.m │ ├── bnb_solvelower.m │ ├── bounds_from_cones_to_lp.m │ ├── boxreduce.m │ ├── branchVolume.m │ ├── classifyrows.m │ ├── clean_bounds.m │ ├── cleanuppermodel.m │ ├── compileQuadratic.m │ ├── compile_nonlinear_table.m │ ├── complementmodel.m │ ├── completeInitial.m │ ├── computecost.m │ ├── constraint_residuals.m │ ├── convexhullConcave.m │ ├── convexhullConcave2D.m │ ├── convexhullConvex.m │ ├── convexhullConvex2D.m │ ├── convexhullFromSampled.m │ ├── convexhullGeneral.m │ ├── correctEXPConeClosureInitial.m │ ├── createConvexHullMethod.m │ ├── createConvexHullMethodConcave.m │ ├── createConvexHullMethodConvex.m │ ├── create_sdpknapsack_cuts.m │ ├── createsdpcut.m │ ├── cross_binary_product_cardinality.m │ ├── cutsdp.m │ ├── decide_branch_variables.m │ ├── decreasing_except_at.m │ ├── derivecliques.m │ ├── detect3x3SymmetryGroups.m │ ├── detectAndAdd3x3AtmostGroups.m │ ├── detectAndAdd3x3SDPGUBGroups.m │ ├── detectAndAdd3x3SymmetryGroups.m │ ├── detectMonotoneSDPObjective.m │ ├── detectRedundantInfeasibleEXPRows.m │ ├── detectRedundantInfeasibleLPRows.m │ ├── detectRedundantInfeasiblePOWRows.m │ ├── detectRedundantInfeasibleSDPRows.m │ ├── detectRedundantInfeasibleSOCPRows.m │ ├── detectSOS.m │ ├── detect_hiddendelayedconvex_sdp.m │ ├── detect_knapsack.m │ ├── detect_negated_binary.m │ ├── detect_quadratic_disjoints.m │ ├── detect_quadratic_disjoints_generalized.m │ ├── detect_sdpmonotonicity.m │ ├── detect_special_objectives.m │ ├── diagonalize_quadratic_program.m │ ├── dmpermblockeig.m │ ├── evaluate_nonlinear.m │ ├── exclusionCut.m │ ├── extractBounds.m │ ├── extract_global_cardinality.m │ ├── feaspump.m │ ├── findAtmostGroup.m │ ├── find_gub_groups.m │ ├── fixOperatorProperties.m │ ├── fix_binary_products.m │ ├── fix_cardinality.m │ ├── fix_continuous_in_row_at_best_possible.m │ ├── fix_downforce.m │ ├── fixandresolve.m │ ├── fixedInfeasibleEquality.m │ ├── fixer.m │ ├── global_solve_upper.m │ ├── glover_sherali_raw.m │ ├── heuristics_from_relaxed.m │ ├── increasing_except_at.m │ ├── initializesolution.m │ ├── integer_relax.m │ ├── intvmul.m │ ├── intvpower.m │ ├── iterative_refinement.m │ ├── kktqp.m │ ├── knapsack_add_cover_cut.m │ ├── knapsack_cheapcut.m │ ├── knapsack_cover_lift_balas.m │ ├── knapsack_cover_lift_letchford.m │ ├── knapsack_create_cover_cut.m │ ├── lastresortBounds.m │ ├── lpbmitighten.m │ ├── milppresolve.m │ ├── monotonesdp.m │ ├── plotNodeModel.m │ ├── postdetector.m │ ├── powerbound.m │ ├── preprocess_bilinear_bounds.m │ ├── presolveOneMagicRound.m │ ├── presolveSOS.m │ ├── presolveTrivialSDP.m │ ├── presolve_binaryinteger.m │ ├── presolve_boundargument_periodic.m │ ├── presolve_bounds_from_domains.m │ ├── presolve_bounds_from_inequalities.m │ ├── presolve_bounds_from_modelbounds.m │ ├── presolve_cliques.m │ ├── presolve_cliquestrengthen.m │ ├── presolve_downforce.m │ ├── presolve_dualreductions.m │ ├── presolve_eliminatelinearratios.m │ ├── presolve_empty_rows.m │ ├── presolve_euclideanreduction.m │ ├── presolve_fixvariables.m │ ├── presolve_glover_sherali_cover.m │ ├── presolve_implied_binaryproduct.m │ ├── presolve_implied_from_SDP.m │ ├── presolve_implied_integer.m │ ├── presolve_impliedintegers_from_equalities.m │ ├── presolve_integer_coefficients.m │ ├── presolve_linearize_fractions.m │ ├── presolve_probebinary.m │ ├── presolve_remove_dominatedinequalities.m │ ├── presolve_remove_equalitydominateinequality.m │ ├── presolve_remove_repeatedrows.m │ ├── presolve_sortrows.m │ ├── presolve_strengthen_coefficients.m │ ├── presolve_upforce.m │ ├── propagate_atmost.m │ ├── propagate_binary_product.m │ ├── propagate_bounds_from_arbitrary_quadratics.m │ ├── propagate_bounds_from_complementary.m │ ├── propagate_bounds_from_complete_nested_evaluation.m │ ├── propagate_bounds_from_convex_quadratic.m │ ├── propagate_bounds_from_convex_quadratic_ball.m │ ├── propagate_bounds_from_equalities.m │ ├── propagate_bounds_from_evaluations.m │ ├── propagate_bounds_from_monomials.m │ ├── propagate_bounds_from_qualities.m │ ├── propagate_bounds_from_separable_quadratic_equality.m │ ├── propagate_bounds_from_upper.m │ ├── propagate_bounds_lp.m │ ├── propagate_cardinality.m │ ├── propagate_downforce.m │ ├── propagate_forbidden_region.m │ ├── propagate_quadratic_disjoints.m │ ├── propagate_second_order_cover.m │ ├── propagate_setcover.m │ ├── propagate_upforce.m │ ├── reduce_bilinear_branching_variables.m │ ├── removeCuts.m │ ├── removeEmptyLPRows.m │ ├── removeSDPcuts.m │ ├── remove_objective.m │ ├── remove_redundant.m │ ├── root_node_heuristics.m │ ├── root_node_tighten.m │ ├── round_solution.m │ ├── rounder.m │ ├── sdpPump.m │ ├── sdpextendsolution.m │ ├── smashFixed.m │ ├── smashQPOjective.m │ ├── solve_upper_in_node.m │ ├── solvelower.m │ ├── sosfixer.m │ ├── tightenbounds.m │ ├── update_integer_bounds.m │ ├── update_monomial_bounds.m │ ├── update_one_eval_bound.m │ ├── update_one_inverseeval_bound.m │ ├── update_semicont_bounds.m │ ├── updatenonlinearbounds.m │ ├── updateonenonlinearbound.m │ ├── upper_from_sdpcuts.m │ ├── upper_from_sdpextension.m │ └── widenSmashedBox.m ├── moment │ ├── extractsolution.m │ ├── momentmodel.m │ └── solvemoment.m ├── parametric │ ├── mpt2pop.m │ ├── mpt_appendmodel.m │ ├── mpt_clean_optmizer.m │ ├── mpt_collect_equalities.m │ ├── mpt_de_mpmilp.m │ ├── mpt_derive_bounds.m │ ├── mpt_detect_and_improve_bounds.m │ ├── mpt_detect_fixed_rows.m │ ├── mpt_detect_sos.m │ ├── mpt_enumerate_binary.m │ ├── mpt_enumeration_mpmilp.m │ ├── mpt_parbb.m │ ├── mpt_project_back_equality.m │ ├── mpt_project_on_equality.m │ ├── mpt_reduce.m │ ├── mpt_remove_equalities.m │ ├── mpt_select_rows.m │ ├── mpt_solvenode.m │ ├── removeExplorationConstraints.m │ └── solvemp.m ├── robust │ ├── createDualParameterization.m │ ├── decomposeUncertain.m │ ├── deriveBilinearizing.m │ ├── dilate.m │ ├── dilate2.m │ ├── dualtososrobustness.m │ ├── filter_2boxmodel.m │ ├── filter_boxmodel.m │ ├── filter_duality.m │ ├── filter_eliminatation.m │ ├── filter_enumeration.m │ ├── filter_norm_1.m │ ├── filter_norm_2.m │ ├── filter_norm_inf.m │ ├── filter_normball.m │ ├── filter_polya.m │ ├── filter_sprocedure.m │ ├── find_simple_variable_bounds.m │ ├── find_simplex_models.m │ ├── getEFfromSET.m │ ├── getFzxfromSET.m │ ├── parameterizedW.m │ ├── robust_classify_variables_newest.m │ ├── robustify.m │ ├── robustmodel.m │ ├── solverobust.m │ └── vertexenumerate.m └── sos │ ├── blockmonomialreduction.m │ ├── compilesos.m │ ├── congruenceblocks.m │ ├── consistent.m │ ├── corrsparsity.m │ ├── create_imagemodel.m │ ├── create_kernelmodel.m │ ├── create_lrmodel.m │ ├── deriveBasis.m │ ├── generate_kernel_representation_data.m │ ├── genmonoms.m │ ├── monomialgeneration.m │ ├── monomialproducts.m │ ├── monomialreduction.m │ ├── newtonmonoms.m │ ├── newtonpolytope.m │ ├── newtonreduce.m │ ├── parameterizedbase.m │ ├── postprocesssos.m │ ├── selectSOSmodel.m │ ├── solveranksos.m │ ├── solvesos.m │ ├── solvesos_find_blocks.m │ ├── sosmodel.m │ └── sparsenull.m ├── operators ├── acos_internal.m ├── alldifferent.m ├── atan2_internal.m ├── beta_w.m ├── beta_z.m ├── binary_implies_linearequality.m ├── binary_implies_linearnegativeconstraint.m ├── blackbox.m ├── cabs.m ├── cpower.m ├── crossentropy_internal.m ├── eig_yalmip_internal.m ├── entropy.m ├── expexpintinv.m ├── find_internal.m ├── fraction_internal2.m ├── geomean2.m ├── graph_square.m ├── hinge.m ├── huber.m ├── iff.m ├── iff_internal.m ├── implies.m ├── implies_internal.m ├── interp1_internal.m ├── interp1_nonlinear.m ├── interp2_internal.m ├── inverse_internal2.m ├── invpos.m ├── kullbackleibler.m ├── lambda_max.m ├── lambda_min.m ├── linearnegativeconstraint_iff_binary.m ├── linearnegativeconstraint_implies_binary.m ├── logistic.m ├── logsumexp.m ├── matrix_sdpvar_sort.m ├── max_integer_model.m ├── max_internal.m ├── max_with_loc.m ├── min_internal.m ├── mpower_internal.m ├── mvtest.m ├── negated_perspective_log.m ├── nnz_internal.m ├── norm_nuclear.m ├── norm_tv.m ├── optimizer_operator.m ├── pexp.m ├── plog.m ├── pnorm.m ├── pow10.m ├── power_internal1.m ├── power_internal2.m ├── powerinternalhelper.m ├── pwa_yalmip.m ├── pwadynamics_internal.m ├── pwq_yalmip.m ├── quadratic_over_affine.m ├── quadratic_over_affine_expanded.m ├── sdpfun.m ├── semivar.m ├── slog.m ├── slogfrac.m ├── softplus.m ├── sort_internal.m ├── sqrtm_internal.m ├── starpolygon.m ├── sum_square.m ├── sumabsk.m ├── sumabsk_generator.m ├── sumk.m ├── sumk_generator.m ├── tplus.m ├── ttimes.m ├── ventropy.m ├── xexp.m └── xexpintinv.m ├── solvers ├── appendMosekSDPdata.m ├── callPOP.m ├── call_cplexibm_miqp.m ├── call_cplexibm_qcmiqp.m ├── call_mosek_dual.m ├── call_mosek_geometric.m ├── call_mosek_primal.m ├── call_xpressfico_milp.m ├── call_xpressfico_miqp.m ├── call_xpressfico_qcmip.m ├── callbaron.m ├── callbonmin.m ├── callcbc.m ├── callcdcs.m ├── callcdd.m ├── callclp.m ├── callconeprog.m ├── callcopt.m ├── callcsdp.m ├── calldaqp.m ├── calldsdp.m ├── calldsdp5.m ├── callecos.m ├── callfiltersd.m ├── callfiltersdsp.m ├── callfmincon.m ├── callfmincongp.m ├── callfminsearch.m ├── callfrlib.m ├── callglpk.m ├── callglpkcc.m ├── callglpkoctave.m ├── callgpposy.m ├── callgurobi.m ├── callintlinprog.m ├── callipopt.m ├── callipoptgp.m ├── callipqp.m ├── callknitro.m ├── callknitro_milp.m ├── callknitro_qp.m ├── calllinprog.m ├── calllmilab.m ├── calllmirank.m ├── calllogdetppa.m ├── calllpsolve.m ├── calllpsolvenative.m ├── calllsqlin.m ├── calllsqnonneg.m ├── callmaxdet.m ├── callmosek.m ├── callmpcvx.m ├── callmplcp.m ├── callmpt.m ├── callmpt3.m ├── callnomad.m ├── callnone.m ├── callopticlp.m ├── callopticsdp.m ├── calloptidsdp.m ├── calloptiooqp.m ├── calloptiqsopt.m ├── callosqp.m ├── callpenbmi.m ├── callpenbmim.m ├── callpenlab.m ├── callpenlabbmi.m ├── callpennlp.m ├── callpennonm.m ├── callpensdp.m ├── callpensdpm.m ├── callpiqp.m ├── callqpas.m ├── callqpip.m ├── callqpoases.m ├── callqsopt.m ├── callquadprog.m ├── callquadprogbb.m ├── callscipmex.m ├── callscipnl.m ├── callscs.m ├── callsdpa.m ├── callsdplr.m ├── callsdpnal.m ├── callsdpt34.m ├── callsedumi.m ├── callsievesdp.m ├── callsnopt.m ├── callsnoptgp.m ├── callsparsecolo.m ├── callsparsepop.m ├── callsqplab.m ├── callvsdp.m ├── cplex2yalmip.m ├── create_lp_solve_model.m ├── create_lp_solve_native_model.m ├── definesolvers.m ├── getavailablesolvers.m ├── mpcvx.m ├── yalmip2SDPmosek.m ├── yalmip2cbc.m ├── yalmip2coneprog.m ├── yalmip2copt.m ├── yalmip2cplex.m ├── yalmip2csdp.m ├── yalmip2dsdp.m ├── yalmip2ecos.m ├── yalmip2glpkmex.m ├── yalmip2gurobi.m ├── yalmip2gurobinonlinear.m ├── yalmip2intlinprog.m ├── yalmip2knitromiqp.m ├── yalmip2mosek.m ├── yalmip2opticsdp.m ├── yalmip2optidsdp.m ├── yalmip2osqp.m ├── yalmip2pensdp.m ├── yalmip2piqp.m ├── yalmip2powersolver.m ├── yalmip2quadprog.m ├── yalmip2scs.m ├── yalmip2sdpa.m ├── yalmip2sdpt3.m ├── yalmip2sedumi.m └── yalmip2xpress.m ├── yalmipdemo.m └── yalmiptest.m /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.asv 3 | -------------------------------------------------------------------------------- /@sdpvar/accumarray.m: -------------------------------------------------------------------------------- 1 | function A=accumarray(subs,val,varargin) 2 | %ACCUMARRAY (overloaded) 3 | 4 | if size(subs,2)>1 || min(size(val))>1 || nargin > 2 5 | error('SDPVAR/ACCUMARRAY currently only supports simple cases (subs=column, val=vector)'); 6 | end 7 | 8 | S = sparse(max(subs),length(val),0); 9 | for i = 1:size(S,1) 10 | S(i,find(i == subs)) = 1; 11 | end 12 | A = S*reshape(val,[],1); -------------------------------------------------------------------------------- /@sdpvar/acoth.m: -------------------------------------------------------------------------------- 1 | function varargout = acoth(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'sdpvar' 6 | varargout{1} = InstantiateElementWise(mfilename,varargin{:}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('callback','convex','positive','decreasing'); 11 | operator.derivative = @(x)(1./(1-x.^2)); 12 | operator.domain = [1 inf]; 13 | 14 | varargout{1} = []; 15 | varargout{2} = operator; 16 | varargout{3} = varargin{3}; 17 | 18 | otherwise 19 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 20 | end -------------------------------------------------------------------------------- /@sdpvar/airy.m: -------------------------------------------------------------------------------- 1 | function varargout = airy(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'sdpvar' 6 | varargout{1} = InstantiateElementWise(mfilename,varargin{:}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('callback'); 11 | operator.derivative = @(x)(airy(1,x)); 12 | operator.range = [-4.1901547803e-01 5.35656656014e-01]; 13 | 14 | varargout{1} = []; 15 | varargout{2} = operator; 16 | varargout{3} = varargin{3}; 17 | 18 | otherwise 19 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 20 | end -------------------------------------------------------------------------------- /@sdpvar/any.m: -------------------------------------------------------------------------------- 1 | function anys = any(x) 2 | %ANY (overloaded) 3 | 4 | x_base = x.basis; 5 | anys = full(sum(abs(x.basis),2)>0); 6 | anys = reshape(anys,x.dim(1),x.dim(2)); -------------------------------------------------------------------------------- /@sdpvar/atan2.m: -------------------------------------------------------------------------------- 1 | function varargout = atan2(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'sdpvar' 6 | varargout{1} = yalmip('define','atan2_internal',[varargin{:}]); 7 | 8 | otherwise 9 | error('SDPVAR/atan2 called with CHAR argument?'); 10 | end -------------------------------------------------------------------------------- /@sdpvar/beta.m: -------------------------------------------------------------------------------- 1 | function varargout=beta(varargin) 2 | 3 | if isa(varargin{1},'sdpvar') && isa(varargin{2},'sdpvar') 4 | error('W and Z can not both be an SDPVAR objects') 5 | end 6 | if isa(varargin{1},'sdpvar') 7 | varargout{1} = InstantiateElementWise('beta_z',varargin{:}); 8 | else 9 | varargout{1} = InstantiateElementWise('beta_w',varargin{2},varargin{1}); 10 | end 11 | -------------------------------------------------------------------------------- /@sdpvar/brutepersp.m: -------------------------------------------------------------------------------- 1 | function X=brutepersp(X,t,y) 2 | 3 | X.basis = [zeros(size(X.basis,1),1) X.basis]; 4 | X.lmi_variables = [t y]; 5 | [i,j] = sort(X.lmi_variables); 6 | X.basis = X.basis(:,[1 1+j]); 7 | X.lmi_variables = i; 8 | X.conicinfo = [0 0]; -------------------------------------------------------------------------------- /@sdpvar/bsxfun.m: -------------------------------------------------------------------------------- 1 | function out=bsxfun(f,x,y) 2 | %BSXFUN 3 | 4 | dim1 = size(x); 5 | dim2 = size(y); 6 | 7 | X = x; 8 | Y = y; 9 | 10 | for i = 1:length(dim1) 11 | if dim1(i) < dim2(i) 12 | d = ones(1,length(dim1)); 13 | d(i) = dim2(i); 14 | X = repmat(X,d); 15 | elseif dim1(i) > dim2(i) 16 | d = ones(1,length(dim1)); 17 | d(i) = dim1(i); 18 | Y = repmat(Y,d); 19 | end 20 | end 21 | 22 | % And compute 23 | out = f(X,Y); -------------------------------------------------------------------------------- /@sdpvar/cat.m: -------------------------------------------------------------------------------- 1 | function y = cat(varargin) 2 | %CAT (overloaded) 3 | 4 | switch varargin{1} 5 | case 1 6 | y = vertcat(varargin{2:end}); 7 | case 2 8 | y = horzcat(varargin{2:end}); 9 | otherwise 10 | for i = 2:nargin 11 | if isa(varargin{i},'sdpvar'); 12 | varargin{i} = ndsdpvar(varargin{i}); 13 | end 14 | end 15 | y = cat(varargin{:}); 16 | end -------------------------------------------------------------------------------- /@sdpvar/circshift.m: -------------------------------------------------------------------------------- 1 | function X = circshift(varargin) 2 | % CIRCSHIFT (overloaded) 3 | 4 | Y = varargin{1}; 5 | X = Y; 6 | X.basis = []; 7 | for i = 1:size(Y.basis,2) 8 | base = reshape(full(Y.basis(:,i)),[X.dim(1) X.dim(2)]); 9 | base = circshift(base,varargin{2:end}); 10 | X.basis = [X.basis sparse(base(:))]; 11 | end 12 | X.dim = size(base); 13 | X.conicinfo = [0 0]; 14 | X = clean(X); -------------------------------------------------------------------------------- /@sdpvar/clear_poly_dep.m: -------------------------------------------------------------------------------- 1 | function P = clear_poly_dep(P,x,order) 2 | 3 | mt = yalmip('monomtable'); 4 | xv = getvariables(x); 5 | pv = getvariables(P); 6 | 7 | mt = mt(pv,:); 8 | 9 | polys = find(sum(mt(:,xv),2) > order); 10 | if ~isempty(polys) 11 | P.lmi_variables(polys) = []; 12 | P.basis(:,1+polys) = []; 13 | end 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /@sdpvar/clearconic.m: -------------------------------------------------------------------------------- 1 | function x = clearconic(x) 2 | x.conicinfo = [0 0]; -------------------------------------------------------------------------------- /@sdpvar/clearconicinfo.m: -------------------------------------------------------------------------------- 1 | function x = clearconicinfo(x) 2 | x.conicinfo = [0 0]; 3 | 4 | -------------------------------------------------------------------------------- /@sdpvar/clearcreationtime.m: -------------------------------------------------------------------------------- 1 | function x = clearcreationtime(x) 2 | x.extra.createTime = 0; 3 | -------------------------------------------------------------------------------- /@sdpvar/clearsdpvar.m: -------------------------------------------------------------------------------- 1 | function clearsdpvar(X,value) 2 | % CLEARSDPVAR Clear solution 3 | 4 | x_lmi_variables = X.lmi_variables; 5 | 6 | sol = sdpvar('getSolution'); 7 | keep_these = find(~ismember(sol.variables,x_lmi_variables)); 8 | sol.optvar = [sol.optvar(keep_these)]; 9 | sol.variables = [sol.variables(keep_these)]; 10 | sdpvar('setAllSolution',sol); 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /@sdpvar/colamd.m: -------------------------------------------------------------------------------- 1 | function varargout = colamd(X,variablesonly) 2 | %COLAMD (overloaded) 3 | 4 | if nargin < 2 5 | variablesonly = 0; 6 | end 7 | if isa(X,'blkvar') 8 | X = sdpvar(X); 9 | end 10 | 11 | if variablesonly 12 | Z = X.basis(:,2:end); 13 | else 14 | Z = X.basis; 15 | end 16 | 17 | Z = reshape(sum(abs(Z),2),X.dim(1),X.dim(2)); 18 | Z = Z~=0; 19 | varargout{1}=colamd(Z); -------------------------------------------------------------------------------- /@sdpvar/conj.m: -------------------------------------------------------------------------------- 1 | function Z = conj(Y) 2 | %CONJ (overloaded) 3 | 4 | Z = Y; 5 | Z.basis = conj(Z.basis); 6 | % Reset info about conic terms 7 | Z.conicinfo = [0 0]; -------------------------------------------------------------------------------- /@sdpvar/convexhull.m: -------------------------------------------------------------------------------- 1 | function [A,b] = convexhull(p,xL,xU) 2 | 3 | -------------------------------------------------------------------------------- /@sdpvar/cosh.m: -------------------------------------------------------------------------------- 1 | function varargout = cosh(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'sdpvar' 6 | varargout{1} = InstantiateElementWise(mfilename,varargin{:}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('convex','positive','even','callback'); 11 | operator.derivative = @(x)(sinh(x)); 12 | operator.stationary = [0 1]; 13 | 14 | varargout{1} = []; 15 | varargout{2} = operator; 16 | varargout{3} = varargin{3}; 17 | 18 | otherwise 19 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 20 | end -------------------------------------------------------------------------------- /@sdpvar/cot.m: -------------------------------------------------------------------------------- 1 | function varargout = cot(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'sdpvar' 6 | varargout{1} = InstantiateElementWise(mfilename,varargin{:}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('callback'); 11 | operator.derivative = @(x)(-csc(x).^2); 12 | operator.singularity = [0 -inf inf]; 13 | operator.inflection = [-inf -1 0 1]; 14 | 15 | varargout{1} = []; 16 | varargout{2} = operator; 17 | varargout{3} = varargin{3}; 18 | 19 | otherwise 20 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 21 | end -------------------------------------------------------------------------------- /@sdpvar/csc.m: -------------------------------------------------------------------------------- 1 | function varargout = csc(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'sdpvar' 6 | varargout{1} = InstantiateElementWise(mfilename,varargin{:}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('callback'); 11 | operator.derivative = @(x)(-csc(x)*(cot(x))); 12 | % FIXME: Need extended format to deal with infinitely many 13 | % singularites 14 | 15 | varargout{1} = []; 16 | varargout{2} = operator; 17 | varargout{3} = varargin{3}; 18 | 19 | otherwise 20 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 21 | end -------------------------------------------------------------------------------- /@sdpvar/ctranspose.m: -------------------------------------------------------------------------------- 1 | function X=ctranspose(X) 2 | %CTRANSPOSE (overloaded) 3 | 4 | if isa(X,'blkvar') 5 | X = sdpvar(X); 6 | end 7 | 8 | n = X.dim(1); 9 | m = X.dim(2); 10 | ind = reshape(reshape(1:n*m,n,m)',n*m,1); 11 | if isreal(X.basis) 12 | X.basis = X.basis(ind,:); 13 | else 14 | X.basis = conj(X.basis(ind,:)); 15 | end 16 | X.dim(1) = m; 17 | X.dim(2) = n; 18 | % Reset info about conic terms 19 | X.conicinfo = [0 0]; -------------------------------------------------------------------------------- /@sdpvar/cumsum.m: -------------------------------------------------------------------------------- 1 | function X=cumsum(X,I) 2 | %CUMSUM (overloaded) 3 | 4 | if nargin == 1 & min(X.dim)==1 5 | X.basis = cumsum(X.basis); 6 | else 7 | if nargin == 1 8 | I = min(find(X.dim>1)); 9 | if isempty(I) 10 | I = 1; 11 | end 12 | end 13 | if I == 2 14 | X = (tril(ones(size(X,2)))*X')'; 15 | else 16 | X = tril(ones(size(X,1)))*X; 17 | end 18 | end 19 | X.conicinfo = [0 0]; 20 | X.extra.opname = ''; 21 | X = clean(X); -------------------------------------------------------------------------------- /@sdpvar/cumtrapz.m: -------------------------------------------------------------------------------- 1 | function X=cumtrapz(X,I) 2 | %CUMTRAPZ (overloaded) 3 | 4 | if nargin == 1 && min(X.dim)==1 5 | B = cumtrapz(X.basis); 6 | else 7 | if nargin == 1 8 | I = find(X.dim>1,1); 9 | if isempty(I) 10 | I = 1; 11 | end 12 | end 13 | 14 | B = []; 15 | for i = 1:length(X.lmi_variables)+1 16 | C = reshape(X.basis(:,i),X.dim); 17 | C = cumtrapz(C,I); 18 | B = [B C(:)]; 19 | end 20 | end 21 | X.basis = B; 22 | X.conicinfo = [0 0]; 23 | X.extra.opname = ''; 24 | X = clean(X); -------------------------------------------------------------------------------- /@sdpvar/dct.m: -------------------------------------------------------------------------------- 1 | function X=dct(x,N) 2 | %DCT (overloaded) 3 | 4 | if min(size(x)) > 1 5 | error('DCT currently only supported for vectors'); 6 | end 7 | 8 | % Make sure x is column vector 9 | x = reshape(x,[],1); 10 | 11 | % Pad? 12 | if nargin == 1 13 | N = length(x); 14 | else 15 | x = [x;zeros(N-length(x),1)]; 16 | end 17 | 18 | % Transform 19 | k = 1:N; 20 | n = 1:N; 21 | w=[1/sqrt(N); sqrt(2/N)*ones(N-1,1)]; 22 | e = cos(pi*(k-1)'*(2*n-1)/(2*N)); 23 | X=w.*(e*x); -------------------------------------------------------------------------------- /@sdpvar/degreduce.m: -------------------------------------------------------------------------------- 1 | function pnew = degreduce(p,d) 2 | % DEGREDUCE Remove higher order terms 3 | 4 | if islinear(p) 5 | pnew = p; 6 | else 7 | [sqrList,CompressedList] = yalmip('nonlinearvariables'); 8 | 9 | base = getbase(p); 10 | vars = getvariables(p); 11 | 12 | for i = 1:length(vars) 13 | v = vars(i); 14 | if ismember(v,CompressedList(:,1)) 15 | j = find(CompressedList(:,1)==v); 16 | if sum(any(CompressedList(j,2:end),1))>d 17 | base(i+1)=0; 18 | end 19 | end 20 | end 21 | pnew = clean(sdpvar(1,1,[],vars,base)); 22 | 23 | end -------------------------------------------------------------------------------- /@sdpvar/dissect.m: -------------------------------------------------------------------------------- 1 | function X = dissect(Y) 2 | 3 | X = dissect_internal(Y); -------------------------------------------------------------------------------- /@sdpvar/double.m: -------------------------------------------------------------------------------- 1 | function [sys,values] = double(varargin) 2 | % OBSOLETE. Use VALUE instead 3 | 4 | % New syntax 5 | switch nargout 6 | case 0 7 | double(value(varargin{:})) 8 | case 1 9 | sys = double(value(varargin{:})); 10 | case 2 11 | [sys,values] = value(varargin{:}); 12 | sys = double(sys); 13 | values = double(values); 14 | otherwise 15 | error('Too many output arguments.'); 16 | end 17 | 18 | -------------------------------------------------------------------------------- /@sdpvar/eliminateBinary.m: -------------------------------------------------------------------------------- 1 | function p = eliminateBinary(p,binaries) 2 | 3 | vars = p.lmi_variables; 4 | [mt,vt] = yalmip('monomtable'); 5 | 6 | 7 | mt = mt(vars,:); 8 | mt(:,binaries) = min(mt(:,binaries),1); 9 | 10 | used_variables = find(any(mt,1)); 11 | x = recover(used_variables)'; 12 | new_monoms = []; 13 | mt = mt(:,used_variables); 14 | 15 | y = recovermonoms(mt,x); 16 | y = p.basis*[1;y]; 17 | if isa(y,'sdpvar') 18 | % copy data to p 19 | p.basis = y.basis; 20 | p.lmi_variables = y.lmi_variables; 21 | else 22 | p = y; 23 | end 24 | -------------------------------------------------------------------------------- /@sdpvar/ellipke.m: -------------------------------------------------------------------------------- 1 | function varargout = ellipke(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'sdpvar' 6 | varargout{1} = InstantiateElementWise(mfilename,varargin{:}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('convex','increasing','positive','callback') 11 | operator.derivative = @(x)(airy(1,x)); 12 | operator.range = [1.570796326794897e+00 inf]; 13 | 14 | varargout{1} = []; 15 | varargout{2} = operator; 16 | varargout{3} = varargin{3}; 17 | 18 | otherwise 19 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 20 | end -------------------------------------------------------------------------------- /@sdpvar/end.m: -------------------------------------------------------------------------------- 1 | function index = end(X,position,numindices) 2 | %END (overloaded) 3 | 4 | switch position 5 | case {1,2} 6 | if numindices == 1 7 | % User has written someting like X(end) or X(1:end) 8 | index = prod(X.dim); 9 | else 10 | index = X.dim(position); 11 | end 12 | otherwise 13 | index = 1; 14 | end 15 | -------------------------------------------------------------------------------- /@sdpvar/eq.m: -------------------------------------------------------------------------------- 1 | function y = eq(X,Y) 2 | %EQ (overloaded) 3 | 4 | if isa(X,'blkvar') 5 | X = sdpvar(X); 6 | end 7 | 8 | if isa(Y,'blkvar') 9 | Y = sdpvar(Y); 10 | end 11 | 12 | try 13 | Z = X - Y; 14 | if ishermitian(Z) 15 | if isreal(Z) 16 | mask = triu(true(length(Z))); 17 | y = constraint(extsubsref(Z,mask),'==', 0); 18 | else 19 | mask = triu(true(length(Z)),1); 20 | y = constraint([diag(Z);real(extsubsref(Z,mask));imag(extsubsref(Z,mask))],'==', 0); 21 | end 22 | else 23 | y = constraint(Z,'==',0); 24 | end 25 | catch 26 | error(lasterr) 27 | end 28 | -------------------------------------------------------------------------------- /@sdpvar/erfcx.m: -------------------------------------------------------------------------------- 1 | function varargout = erfcx(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'sdpvar' 6 | varargout{1} = InstantiateElementWise(mfilename,varargin{:}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('convex','decreasing','positive','callback'); 11 | operator.derivative = @(x)(2*x.*exp(x.^2).*erfc(x) + exp(x.^2).*(-exp(-x.^2)*2/sqrt(pi))); 12 | 13 | varargout{1} = []; 14 | varargout{2} = operator; 15 | varargout{3} = varargin{3}; 16 | 17 | otherwise 18 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 19 | end -------------------------------------------------------------------------------- /@sdpvar/expanded.m: -------------------------------------------------------------------------------- 1 | function X = expanded(Y,state) 2 | 3 | if nargin == 1 4 | X = Y.extra.expanded; 5 | else 6 | X = Y; 7 | if state == 0 8 | X.extra.expanded = []; 9 | else 10 | X.extra.expanded = X.lmi_variables; 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /@sdpvar/expint.m: -------------------------------------------------------------------------------- 1 | function varargout = expint(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'sdpvar' 6 | varargout{1} = InstantiateElementWise(mfilename,varargin{:}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('convex','decreasing','positive','callback'); 11 | operator.derivative = @(x)(-exp(-x)./x); 12 | operator.domain = [0 inf]; 13 | varargout{1} = []; 14 | varargout{2} = operator; 15 | varargout{3} = varargin{3}; 16 | 17 | otherwise 18 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 19 | end 20 | -------------------------------------------------------------------------------- /@sdpvar/exponents.m: -------------------------------------------------------------------------------- 1 | function [ML,dummy] = exponents(poly,x) 2 | %EXPONENTS Internal function to extract powers of nonlinear expression 3 | 4 | mt = yalmip('monomtable'); 5 | x_lin = getvariables(poly); 6 | 7 | x_var = []; 8 | for i = 1:length(x) 9 | x_var = [x_var getvariables(extsubsref(x,i))]; 10 | end 11 | 12 | ML = mt(x_lin,x_var); 13 | if any(full(poly.basis(:,1))) 14 | ML = [zeros(1,length(x));ML]; 15 | end 16 | dummy = []; -------------------------------------------------------------------------------- /@sdpvar/false.m: -------------------------------------------------------------------------------- 1 | function x = false(x) 2 | % FALSE Constrains a variable to be negative 3 | % 4 | % TRUE(x) returns the constraint (x<=0.5). It is assumed that x is 5 | % binary. The reason (x<=0.5) is used instead of x==0 is that some big-M 6 | % modelling turns out to be less sensitive to numerical issues in this 7 | % form. Once the model enters the solver, it will be trivially presolved 8 | % anyway. 9 | % 10 | % Example 11 | % 12 | % (FALSE(a)) constrains binary variable a to be 0 (i.e. false) 13 | % (FALSE(a|b)) constrains binary variables a and b to be 0 (i.e. false) 14 | % 15 | % See also SDPVAR/TRUE, SDPVAR/AND, SDPVAR/OR, SDPVAR/NOT, BINVAR, BINARY 16 | 17 | x = (x<=.5); -------------------------------------------------------------------------------- /@sdpvar/fft.m: -------------------------------------------------------------------------------- 1 | function X=fft(x,N) 2 | %FFT (overloaded) 3 | 4 | if min(size(x)) > 1 5 | error('FFT currently only supported for vectors'); 6 | end 7 | 8 | % Make sure x is column vector 9 | x = reshape(x,[],1); 10 | 11 | % Pad? 12 | if nargin == 1 13 | N = length(x); 14 | else 15 | x = [x;zeros(N-length(x),1)]; 16 | end 17 | 18 | % Transform 19 | k = 1:N; 20 | n = 1:N; 21 | e = exp(-j*2*pi*(k-1)'*(n-1)/N); 22 | X=e*x; -------------------------------------------------------------------------------- /@sdpvar/findelements.m: -------------------------------------------------------------------------------- 1 | function indicies = findelements(x) 2 | base = x.basis; 3 | vars = x.lmi_variables; 4 | indicies = find(any(base,2)); 5 | -------------------------------------------------------------------------------- /@sdpvar/fliplr.m: -------------------------------------------------------------------------------- 1 | function X=fliplr(X) 2 | %FLIPLR (overloaded) 3 | 4 | n = X.dim(1); 5 | m = X.dim(2); 6 | nm = n*m; 7 | for i = 1:length(X.lmi_variables)+1 8 | X.basis(:,i) = reshape(fliplr(reshape(X.basis(:,i),n,m)),nm,1); 9 | end 10 | % Reset info about conic terms 11 | X.conicinfo = [0 0]; 12 | 13 | -------------------------------------------------------------------------------- /@sdpvar/flipud.m: -------------------------------------------------------------------------------- 1 | function X=flipud(X) 2 | %FLIPUD (overloaded) 3 | 4 | n = X.dim(1); 5 | m = X.dim(2); 6 | nm = n*m; 7 | for i = 1:length(X.lmi_variables)+1 8 | X.basis(:,i) = reshape(flipud(reshape(X.basis(:,i),n,m)),nm,1); 9 | end 10 | % Reset info about conic terms 11 | X.conicinfo = [0 0]; 12 | 13 | -------------------------------------------------------------------------------- /@sdpvar/ge.m: -------------------------------------------------------------------------------- 1 | function y = ge(X,Y) 2 | %GE (overloaded) 3 | 4 | try 5 | y = constraint(X,'>=',Y); 6 | catch 7 | error(lasterr) 8 | end 9 | -------------------------------------------------------------------------------- /@sdpvar/getbase.m: -------------------------------------------------------------------------------- 1 | function Q=getbase(X) 2 | %GETBASE Internal function to extract all base matrices 3 | 4 | Q=X.basis; 5 | 6 | 7 | -------------------------------------------------------------------------------- /@sdpvar/getbasematrix.m: -------------------------------------------------------------------------------- 1 | function Q=getbasematrix(X,ind) 2 | %GETBASEMATRIX Internal function to extract basematrix for variable IND 3 | 4 | if ind==0 5 | base = X.basis(:,1); 6 | Q = reshape(base,X.dim(1),X.dim(2)); 7 | return; 8 | end 9 | 10 | here = find(X.lmi_variables==ind); 11 | if isempty(here) 12 | Q = sparse(X.dim(1),X.dim(2)); 13 | else 14 | base = X.basis(:,here+1); 15 | Q = reshape(base,X.dim(1),X.dim(2)); 16 | end 17 | 18 | 19 | -------------------------------------------------------------------------------- /@sdpvar/getbasematrixwithoutcheck.m: -------------------------------------------------------------------------------- 1 | function Q=getbasematrixwithoutcheck(X,ind) 2 | %GETBASEMATRIXWITHOUTCHECK Internal function to extract basematrix for variable IND 3 | 4 | Q=reshape(X.basis(:,ind+1),X.dim(1),X.dim(2)); 5 | 6 | 7 | -------------------------------------------------------------------------------- /@sdpvar/getbasevectorwithoutcheck.m: -------------------------------------------------------------------------------- 1 | function Q=getbasevectorwithoutcheck(X,ind) 2 | %GETBASEVECTORWITHOUTCHECK Internal function to extract basematrix for variable ind 3 | 4 | Q=X.basis(:,ind+1); 5 | 6 | 7 | -------------------------------------------------------------------------------- /@sdpvar/gethackflag.m: -------------------------------------------------------------------------------- 1 | function y = gethackflag(X) 2 | %GETHACKFLAG Internal function to extract constraint type 3 | 4 | y = X.typeflag; 5 | -------------------------------------------------------------------------------- /@sdpvar/getsosrank.m: -------------------------------------------------------------------------------- 1 | function r=getsosrank(X) 2 | 3 | try 4 | r = X.extra.rank; 5 | catch 6 | r = inf; 7 | end 8 | 9 | 10 | -------------------------------------------------------------------------------- /@sdpvar/getvariablesvector.m: -------------------------------------------------------------------------------- 1 | function x_var = getvariablesvector(x) 2 | 3 | x_var = zeros(x.n,1); 4 | base = x.basis(:,2:end); 5 | vars = x.lmi_variables; 6 | [i,j,s] = find(base); 7 | x_var = vars(j); 8 | x_var = x_var(:); -------------------------------------------------------------------------------- /@sdpvar/getvectorvariables.m: -------------------------------------------------------------------------------- 1 | function v = getvectorvariables(X) 2 | 3 | B = X.basis; 4 | B(:,1)=[]; 5 | [i,j,k] = find(B'); 6 | v = X.lmi_variables(i); 7 | -------------------------------------------------------------------------------- /@sdpvar/gt.m: -------------------------------------------------------------------------------- 1 | function y = gt(X,Y) 2 | error('Strict inequalities are not supported (learn why)') -------------------------------------------------------------------------------- /@sdpvar/hankel.m: -------------------------------------------------------------------------------- 1 | function H = hankel(c,r) 2 | %HANKEL (overloaded) 3 | 4 | % direct 1-to-1 copy of MATLAB double code 5 | c = reshape(c,prod(size(c)),1); 6 | nc = length(c); 7 | if nargin < 2, 8 | r = zeros(size(c)); 9 | end 10 | r = reshape(r,prod(size(r)),1); 11 | nr = length(r); 12 | x = [c;extsubsref(r,2:nr)]; 13 | cidx = (1:nc)'; 14 | ridx = 0:(nr-1); 15 | H = cidx(:,ones(nr,1)) + ridx(ones(nc,1),:); 16 | if isrow(H) 17 | H = extsubsref(x,H).'; 18 | else 19 | H = extsubsref(x,H); 20 | end 21 | if isa(H,'sdpvar') 22 | H.conicinfo = [0 0]; 23 | end 24 | 25 | -------------------------------------------------------------------------------- /@sdpvar/ifft.m: -------------------------------------------------------------------------------- 1 | function X=fft(x,N) 2 | %FFT (overloaded) 3 | 4 | if min(size(x)) > 1 5 | error('FFT currently only supported for vectors'); 6 | end 7 | 8 | % Make sure x is column vector 9 | x = reshape(x,[],1); 10 | 11 | % Pad? 12 | if nargin == 1 13 | N = length(x); 14 | else 15 | x = [x;zeros(N-length(x),1)]; 16 | end 17 | 18 | % Transform 19 | k = 1:N; 20 | n = 1:N; 21 | e = exp(j*2*pi*(k-1)'*(n-1)/N); 22 | X=(1/N)*e*x; -------------------------------------------------------------------------------- /@sdpvar/imag.m: -------------------------------------------------------------------------------- 1 | function X = imag(X) 2 | %IMAG (overloaded) 3 | 4 | X.basis = imag(X.basis); 5 | X = clean(X); 6 | if isa(X,'sdpvar') 7 | X.conicinfo = [0 0]; 8 | end -------------------------------------------------------------------------------- /@sdpvar/inv.m: -------------------------------------------------------------------------------- 1 | function varargout=inv(varargin) 2 | %INV 3 | 4 | disp('INV is not defined on general SDPVAR objects') 5 | disp('Learn about alternatives') 6 | -------------------------------------------------------------------------------- /@sdpvar/isequal.m: -------------------------------------------------------------------------------- 1 | function out = isequal(X,Y,check) 2 | %ISEQUAL (overloaded) 3 | 4 | if nargin == 3 5 | if (isa(X,'sdpvar') & isa(Y,'sdpvar')) 6 | out = isequal(X.basis,Y.basis) & isequal(X.lmi_variables,Y.lmi_variables); 7 | else 8 | out = false; 9 | end 10 | else 11 | if (isa(X,'sdpvar') & isa(Y,'sdpvar')) 12 | out = isequal(struct(X),struct(Y)); 13 | else 14 | out = false; 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /@sdpvar/isinteger.m: -------------------------------------------------------------------------------- 1 | function isint=isinteger(X) 2 | %ISINTEGER Check if (part of) a variable is integer 3 | 4 | isint = any(ismember(getvariables(X),yalmip('intvariables'))); 5 | -------------------------------------------------------------------------------- /@sdpvar/isinterval.m: -------------------------------------------------------------------------------- 1 | function res = isinterval(Y) 2 | %ISINTERVAL (overloaded) 3 | 4 | res = isa(Y.basis,'intval'); 5 | -------------------------------------------------------------------------------- /@sdpvar/isreal.m: -------------------------------------------------------------------------------- 1 | function res = isreal(Y) 2 | %ISREAL (overloaded) 3 | 4 | res = isreal(Y.basis); 5 | -------------------------------------------------------------------------------- /@sdpvar/issquare.m: -------------------------------------------------------------------------------- 1 | function issquare=issquare(X) 2 | %ISSQUARE Check if variable is square 3 | 4 | n = X.dim(1); 5 | m = X.dim(2); 6 | issquare = (n==m); 7 | -------------------------------------------------------------------------------- /@sdpvar/issymmetric.m: -------------------------------------------------------------------------------- 1 | function issym=issymmetric(X) 2 | %ISSYMMETRIC Check if variable is symmetric 3 | 4 | n = X.dim(1); 5 | m = X.dim(2); 6 | if (n==m) 7 | % What are the linar indicies to the transposed matrices 8 | if isa(X.basis,'lazybasis') 9 | issym = 1; 10 | else 11 | ind = reshape(reshape(1:n^2,n,n)',n^2,1); 12 | % We use mid in case there is interval data 13 | issym = norm(mid(X.basis-X.basis(ind,:)),1)<1e-10; 14 | end 15 | else 16 | issym = 0; 17 | end 18 | 19 | -------------------------------------------------------------------------------- /@sdpvar/kyp.m: -------------------------------------------------------------------------------- 1 | function sys = kyp(A,B,P,M) 2 | %KYP Create KYP matrix variable (Legacy) 3 | % 4 | % X = KYP(A,B,P,M) 5 | % 6 | % KYP is used to generate the matrix 7 | % 8 | % [A'*P+P*A P*B;B'*P zeros(size(B,2))]+M; 9 | 10 | if nargin<4 11 | M = 0; 12 | end 13 | 14 | if isempty(B) 15 | kyp_part = [A'*P+P*A]; 16 | else 17 | kyp_part = [A'*P+P*A P*B;B'*P zeros(size(B,2))]; 18 | end 19 | if isempty(kyp_part) 20 | sys = M; 21 | else 22 | if isempty(M) 23 | sys = kyp_part; 24 | else 25 | sys = kyp_part+M; 26 | end 27 | end -------------------------------------------------------------------------------- /@sdpvar/le.m: -------------------------------------------------------------------------------- 1 | function y = le(X,Y) 2 | %LE (overloaded) 3 | 4 | try 5 | y = constraint(X,'<=',Y); 6 | catch 7 | error(lasterr) 8 | end 9 | -------------------------------------------------------------------------------- /@sdpvar/length.m: -------------------------------------------------------------------------------- 1 | function n=length(X) 2 | %LENGTH (overloaded) 3 | 4 | n = max(X.dim); 5 | -------------------------------------------------------------------------------- /@sdpvar/lift2real.m: -------------------------------------------------------------------------------- 1 | function X = lift2real(X) 2 | 3 | reF=real(X); 4 | imF=imag(X); 5 | X = [reF -imF;imF reF]; -------------------------------------------------------------------------------- /@sdpvar/linspace.m: -------------------------------------------------------------------------------- 1 | function A=linspace(x1,x2,N) 2 | %LINPSPACE (overloaded) 3 | 4 | if nargin < 3 5 | N = 100; 6 | elseif isa(N,'sdpvar') 7 | error('SDPVAR/LINSPACE does not support N as a decision variable'); 8 | end 9 | 10 | A = x1 + linspace(0,1,N)*(x2-x1); -------------------------------------------------------------------------------- /@sdpvar/loadobj.m: -------------------------------------------------------------------------------- 1 | function out = loadobj(obj) 2 | %LOADOBJ (overloaded) 3 | out = []; -------------------------------------------------------------------------------- /@sdpvar/log10.m: -------------------------------------------------------------------------------- 1 | function varargout = log10(varargin) 2 | 3 | varargout{1} = log(varargin{1})*(1/log(10)); -------------------------------------------------------------------------------- /@sdpvar/log2.m: -------------------------------------------------------------------------------- 1 | function varargout = log2(varargin) 2 | 3 | varargout{1} = log(varargin{1})*(1/log(2)); -------------------------------------------------------------------------------- /@sdpvar/lt.m: -------------------------------------------------------------------------------- 1 | function y = lt(X,Y) 2 | error('Strict inequalities are not supported (learn why)') -------------------------------------------------------------------------------- /@sdpvar/mid.m: -------------------------------------------------------------------------------- 1 | function X = mid(X); 2 | 3 | X.basis = mid(X.basis); 4 | -------------------------------------------------------------------------------- /@sdpvar/minimize.m: -------------------------------------------------------------------------------- 1 | function sol = minimize(h) 2 | 3 | sol = solvesdp([],h); -------------------------------------------------------------------------------- /@sdpvar/ncvar.m: -------------------------------------------------------------------------------- 1 | function X = ncvar(X) 2 | X = ncvar(struct(X)); -------------------------------------------------------------------------------- /@sdpvar/ndims.m: -------------------------------------------------------------------------------- 1 | function n=ndims(X) 2 | %NDIM (overloaded) 3 | 4 | n = length(X.dim); -------------------------------------------------------------------------------- /@sdpvar/norminv.m: -------------------------------------------------------------------------------- 1 | function varargout = norminv(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'sdpvar' 6 | varargout{1} = InstantiateElementWise(mfilename,varargin{:}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('increasing','callback'); 11 | operator.domain = [0 1]; 12 | 13 | varargout{1} = []; 14 | varargout{2} = operator; 15 | varargout{3} = varargin{1}; 16 | 17 | otherwise 18 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 19 | end -------------------------------------------------------------------------------- /@sdpvar/numel.m: -------------------------------------------------------------------------------- 1 | function N=numel(varargin) 2 | %NUMEL (overloaded) 3 | 4 | X = varargin{1}; 5 | N = prod(size(X)); 6 | -------------------------------------------------------------------------------- /@sdpvar/parametric.m: -------------------------------------------------------------------------------- 1 | function x = parametric(x) 2 | %PARAMETRIC Defines a variable as parametric 3 | % 4 | % F = PARAMETRIC(x) is used to describe the set of parametric variables 5 | % in a multi-parametric program, as an alternative to using the 4th input 6 | % in SOLVEMP 7 | % 8 | % It can also be used to define the parametric variables in a SOS program 9 | % 10 | % INPUT 11 | % x : SDPVAR object 12 | % 13 | % OUTPUT 14 | % F : Constraint 15 | % 16 | % EXAMPLE 17 | % F = parametric(x); % Short notation 18 | % 19 | % See also SOLVEMP, SOLVESOS, SDPVAR 20 | 21 | x.typeflag = 13; 22 | x = lmi(x); -------------------------------------------------------------------------------- /@sdpvar/permutation.m: -------------------------------------------------------------------------------- 1 | function M = permutation(P) 2 | % PERMUTATION 3 | % 4 | % M = permutation(X) 5 | % 6 | % Creates the model [sum(P,1)==1,sum(P,2)==1,binary(P)] 7 | 8 | M = [sum(P,1)==1,sum(P,2)==1,binary(P)]; -------------------------------------------------------------------------------- /@sdpvar/permute.m: -------------------------------------------------------------------------------- 1 | function X=permute(X,p) 2 | %PERMUTE (overloaded) 3 | 4 | if length(X.dim) < length(p) 5 | X = ndsdpvar(X); 6 | X = permute(X,p); 7 | return 8 | end 9 | i = 1:prod(X.dim); 10 | i = reshape(i,X.dim); 11 | i = permute(i,p); 12 | X.basis = X.basis(i,:); 13 | X.dim = X.dim(p); -------------------------------------------------------------------------------- /@sdpvar/pow10.m: -------------------------------------------------------------------------------- 1 | function varargout = pow10(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'sdpvar' 6 | varargout{1} = InstantiateElementWise(mfilename,varargin{:}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('convex','increasing','positive','callback'); 11 | operator.derivative = @(x)(log(10)*pow10(x)); 12 | 13 | varargout{1} = []; 14 | varargout{2} = operator; 15 | varargout{3} = varargin{3}; 16 | 17 | otherwise 18 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 19 | end -------------------------------------------------------------------------------- /@sdpvar/pow2.m: -------------------------------------------------------------------------------- 1 | function varargout = pow2(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'sdpvar' 6 | varargout{1} = InstantiateElementWise(mfilename,varargin{:}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('convex','increasing','positive','callback'); 11 | operator.derivative = @(x)(log(2)*pow2(x)); 12 | 13 | varargout{1} = []; 14 | varargout{2} = operator; 15 | varargout{3} = varargin{3}; 16 | 17 | otherwise 18 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 19 | end -------------------------------------------------------------------------------- /@sdpvar/powercone.m: -------------------------------------------------------------------------------- 1 | function y = powercone(z,x,y,alpha) 2 | %POWERCONE Defines a power cone x^alpha y ^(1-alpha) > ||z|| 3 | % 4 | % Input 5 | % z : vector SDPVAR objects. 6 | % y,x : scalar SDPVAR objects. 7 | % alpha : scalar double 01 13 | error('x must be a scalar') 14 | end 15 | if numel(y)>1 16 | error('y must be a scalar') 17 | end 18 | 19 | try 20 | y = [x;y;z;alpha]; 21 | y.typeflag = 20; 22 | y = lmi(y); 23 | catch 24 | rethrow(lasterror) 25 | end -------------------------------------------------------------------------------- /@sdpvar/pwamodel.m: -------------------------------------------------------------------------------- 1 | function [p,A,b] = pwamodel(f,x) 2 | 3 | t = sdpvar(1); 4 | F = ([f <= t]); 5 | [A,b] = pwamodel(F,[x;t]); 6 | B = A(:,end); 7 | A = A(:,1:end-1); 8 | 9 | % Ax + Bt <= b 10 | for i = 1:length(B) 11 | if B(i)~=0 12 | A(i,:) = A(i,:)/abs(B(i)); 13 | b(i) = b(i)/abs(B(i)); 14 | else 15 | end 16 | end 17 | p = max(A*x-b); 18 | b = -b; 19 | -------------------------------------------------------------------------------- /@sdpvar/quickrecover.m: -------------------------------------------------------------------------------- 1 | function x = quickrecover(x,v,b); 2 | 3 | x.lmi_variables = v; 4 | x.conicinfo = [0 0]; 5 | if nargin == 3 6 | x.basis(2) = b; 7 | end -------------------------------------------------------------------------------- /@sdpvar/rad.m: -------------------------------------------------------------------------------- 1 | function X = rad(X); 2 | 3 | X.basis = rad(X.basis); 4 | -------------------------------------------------------------------------------- /@sdpvar/rational.m: -------------------------------------------------------------------------------- 1 | function F = rational(x,N) 2 | %INTEGER Constrains variables to be rational 3 | % 4 | % F = RATIONAL(x,N) is used to constrain a variable to be rational in 5 | % the form x = y/N where y is integer 6 | % 7 | % For example, rational(x,10) will allow us to search over the numbers 8 | % 0,+-1/10, +-2/10, +- 3/10,... 9 | 10 | % See also BINARY, INTEGER, BINVAR, INTVAR, SEMIVAR 11 | 12 | y = intvar(numel(x),1); 13 | F = [reshape(x,[],1) == y/N]; -------------------------------------------------------------------------------- /@sdpvar/rcone.m: -------------------------------------------------------------------------------- 1 | function y = rcone(z,x,y) 2 | %RCONE Defines a rotated second order cone constraint ||z||^2<2xy, x+y>0 3 | % 4 | % Input 5 | % z : column vector SDPVAR object. 6 | % h : scalar double or SDPVAR object 7 | % 8 | % Example 9 | % 10 | % F = (rcone(z,x,y)) 11 | % 12 | % See also CONE 13 | 14 | 15 | if size(z,2)>1 16 | error('z must be a column vector') 17 | end 18 | 19 | if prod(size(x))>1 20 | error('x must be a scalar') 21 | end 22 | if prod(size(y))>1 23 | error('y must be a scalar') 24 | end 25 | 26 | try 27 | y = [x;y;z]; 28 | y.typeflag = 5; 29 | y = lmi(y); 30 | catch 31 | error(lasterr) 32 | end -------------------------------------------------------------------------------- /@sdpvar/real.m: -------------------------------------------------------------------------------- 1 | function X = real(X) 2 | %REAL (overloaded) 3 | 4 | X.basis = real(X.basis); 5 | X = clean(X); 6 | if isa(X,'sdpvar') 7 | X.conicinfo = [0 0]; 8 | end -------------------------------------------------------------------------------- /@sdpvar/registerjacobian.m: -------------------------------------------------------------------------------- 1 | function [p] = registerjacobian(p) 2 | %REGISTERJACOBIAN Register jacobians to an expression 3 | 4 | if ~isfield(p.extra, 'jacobian') 5 | x = recover(depends(p)); 6 | p.extra.jacobian = jacobian(p,x); 7 | end -------------------------------------------------------------------------------- /@sdpvar/relaxdouble.m: -------------------------------------------------------------------------------- 1 | function sys=relaxdouble(X) 2 | %RELAXDOUBLE Return numerial value treating nonlinear variables as independent 3 | 4 | solution = yalmip('getsolution'); 5 | lmi_variables = X.lmi_variables; 6 | opt_variables = solution.variables; 7 | 8 | values = zeros(1+length(lmi_variables),1); 9 | values(1)=1; 10 | for i=1:length(lmi_variables) 11 | opt_index = find(lmi_variables(i)==opt_variables); 12 | if isempty(opt_index) 13 | values(i+1,1)=NaN; 14 | else 15 | values(i+1,1)=solution.optvar(opt_index); 16 | end 17 | end 18 | 19 | sys = X.basis*values; 20 | sys = full(reshape(sys,X.dim(1),X.dim(2))); -------------------------------------------------------------------------------- /@sdpvar/relaxvalue.m: -------------------------------------------------------------------------------- 1 | function sys=relaxvalue(X) 2 | %RELAXVALUE Return numerial value treating nonlinear variables as independent 3 | 4 | solution = yalmip('getsolution'); 5 | lmi_variables = X.lmi_variables; 6 | opt_variables = solution.variables; 7 | 8 | values = zeros(1+length(lmi_variables),1); 9 | values(1)=1; 10 | for i=1:length(lmi_variables) 11 | opt_index = find(lmi_variables(i)==opt_variables); 12 | if isempty(opt_index) 13 | values(i+1,1)=NaN; 14 | else 15 | values(i+1,1)=solution.optvar(opt_index); 16 | end 17 | end 18 | 19 | sys = X.basis*values; 20 | sys = full(reshape(sys,X.dim(1),X.dim(2))); -------------------------------------------------------------------------------- /@sdpvar/remap.m: -------------------------------------------------------------------------------- 1 | function X = remap(X,old,new) 2 | 3 | X = sdpvarremap(X,old,new); -------------------------------------------------------------------------------- /@sdpvar/repmat.m: -------------------------------------------------------------------------------- 1 | function Y=repmat(varargin) 2 | %REPMAT (overloaded) 3 | 4 | Y = varargin{1}; 5 | dim = Y.dim; 6 | resize = [varargin{2:end}]; 7 | index = (1:size(Y.basis,1))'; 8 | index = reshape(index,Y.dim); 9 | index = repmat(index,resize); 10 | Y.basis = Y.basis(index(:),:); 11 | Y.dim = size(index); 12 | % Reset info about conic terms 13 | Y.conicinfo = [0 0]; 14 | if length(Y.dim)>2 15 | Y = ndsdpvar(Y); 16 | end 17 | -------------------------------------------------------------------------------- /@sdpvar/rot90.m: -------------------------------------------------------------------------------- 1 | function X=rot90(X) 2 | %ROT90 (overloaded) 3 | 4 | n = X.dim(1); 5 | m = X.dim(2); 6 | nm = n*m; 7 | for i = 1:length(X.lmi_variables)+1 8 | X.basis(:,i) = reshape(rot90(reshape(X.basis(:,i),n,m)),nm,1); 9 | end 10 | X.dim(1) = m; 11 | X.dim(2) = n; 12 | % Reset info about conic terms 13 | X.conicinfo = [0 0]; 14 | 15 | 16 | -------------------------------------------------------------------------------- /@sdpvar/saveobj.m: -------------------------------------------------------------------------------- 1 | function out = saveobj(obj) 2 | %SAVEOBJ (overloaded) 3 | warning('YALMIP objects cannot be saved in binary format. You will run into troubles if you try to load this file later. You should clear all YALMIP objects first, or avoid having any YALMIP objects in the list of variables which you save.'); 4 | out = []; -------------------------------------------------------------------------------- /@sdpvar/sdpcone.m: -------------------------------------------------------------------------------- 1 | function y = sdpcone(y) 2 | %SDPCONE Low-level operator to define several SDP constraints in vectorized 3 | %form 4 | % 5 | % Input 6 | % X : Linear SDPVAR object of size n^2 x N 7 | % 8 | % Example 9 | % 10 | % The typical use is when we want to define a very large number of LMI 11 | % constraints with reduced overhead (no analysis or check for symmetry etc) 12 | % 13 | % This operator is very specialized and low-level, and not normally used... 14 | % 15 | % X = sdpvar(5);Y = sdpvar(5); 16 | % F = sdpcone([X(:) Y(:)]); % Equivalent to [X>=0, Y>=0] 17 | % 18 | % See also @SDPVAR/CONE, @SDPVAR/RCONE 19 | 20 | y.typeflag = 57; 21 | y=lmi(y); -------------------------------------------------------------------------------- /@sdpvar/sec.m: -------------------------------------------------------------------------------- 1 | function varargout = sec(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'sdpvar' 6 | varargout{1} = InstantiateElementWise(mfilename,varargin{:}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('convex','callback'); 11 | operator.derivative = @(x)(tan(x).*sec(x)); 12 | operator.domain = [-pi/2 pi/2]; 13 | 14 | varargout{1} = []; 15 | varargout{2} = operator; 16 | varargout{3} = varargin{3}; 17 | 18 | otherwise 19 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 20 | end -------------------------------------------------------------------------------- /@sdpvar/semicont.m: -------------------------------------------------------------------------------- 1 | function x = semicont(x) 2 | %SEMICONT Constrains variables to be semi-continuous 3 | % 4 | % F = SEMICONT(x) is used to posteriori constrain 5 | % variables to be semi-continuous, in contrast to SEMIVAR 6 | % that declares variables as semi-continuous a priori. 7 | % 8 | % INPUT 9 | % x : SDPVAR object 10 | % 11 | % OUTPUT 12 | % F : Constraint object 13 | % 14 | % See also BINARY, SDPVAR, INTVAR, BINVAR 15 | 16 | x.typeflag = 52; 17 | x = lmi(x); -------------------------------------------------------------------------------- /@sdpvar/set.m: -------------------------------------------------------------------------------- 1 | function F = set(varargin) 2 | %SET OBSOLETE 3 | 4 | disp('SET has been considered obsolete for many years, and the time has come...'); 5 | disp('Update your code by removing SET. https://yalmip.github.io/tutorial/basics/'); 6 | error('Obsolete command') 7 | -------------------------------------------------------------------------------- /@sdpvar/setbase.m: -------------------------------------------------------------------------------- 1 | function X=getbase(X,B) 2 | %SETBASE Internal function to set all base matrices 3 | 4 | X.basis = B; 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /@sdpvar/sethackflag.m: -------------------------------------------------------------------------------- 1 | function X = sethackflag(X,flag) 2 | %GETHACKFLAG Internal function to set constraint type 3 | 4 | X.typeflag = flag; 5 | -------------------------------------------------------------------------------- /@sdpvar/setoperatorname.m: -------------------------------------------------------------------------------- 1 | function Z=setoperatorname(Z,name) 2 | 3 | Z.extra.opname=name; -------------------------------------------------------------------------------- /@sdpvar/setsos.m: -------------------------------------------------------------------------------- 1 | function setsos(X,h,ParametricVariables,Q,v) 2 | %SETSOS Internal function 3 | 4 | yalmip('setsos',X.extra.sosid,h,ParametricVariables,Q,v); 5 | -------------------------------------------------------------------------------- /@sdpvar/shiftdim.m: -------------------------------------------------------------------------------- 1 | function [X,n] = shiftdim(varargin) 2 | % SHIFTDIM (overloaded) 3 | 4 | Y = varargin{1}; 5 | X = Y; 6 | X.basis = []; 7 | for i = 1:size(Y.basis,2) 8 | base = reshape(full(Y.basis(:,i)),[X.dim(1) X.dim(2)]); 9 | [base,n] = shiftdim(base,varargin{2:end}); 10 | X.basis = [X.basis sparse(base(:))]; 11 | end 12 | [X.dim(1), X.dim(2)] = size(base); 13 | X.conicinfo = [0 0]; 14 | X = clean(X); -------------------------------------------------------------------------------- /@sdpvar/simplify.m: -------------------------------------------------------------------------------- 1 | function Y=simplify(X,how) 2 | %SIMPLIFY Reduce PWA complexity 3 | 4 | if nargin <2 5 | how = 'greedy'; 6 | end 7 | 8 | variables = getvariables(X); 9 | extstruct = yalmip('extstruct',variables(1)); 10 | if ~isempty(extstruct) 11 | if isequal(extstruct.fcn,'pwa_yalmip') 12 | extstruct.arg{1}{1}.Fi = extstruct.arg{1}{1}.Bi; 13 | extstruct.arg{1}{1}.Gi = extstruct.arg{1}{1}.Ci; 14 | simplified = mpt_simplify(extstruct.arg{1}{1},how); 15 | simplified.Bi = simplified.Fi; 16 | simplified.Ci = simplified.Gi; 17 | Y = pwf(simplified,extstruct.arg{2},extstruct.arg{3}); 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /@sdpvar/sinh.m: -------------------------------------------------------------------------------- 1 | function varargout = sinh(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'sdpvar' 6 | varargout{1} = InstantiateElementWise(mfilename,varargin{:}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('increasing','odd','callback'); 11 | operator.derivative = @(x)(cosh(x)); 12 | operator.inflection = [-inf -1 0 1]; 13 | 14 | varargout{1} = []; 15 | varargout{2} = operator; 16 | varargout{3} = varargin{3}; 17 | 18 | otherwise 19 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 20 | end -------------------------------------------------------------------------------- /@sdpvar/size.m: -------------------------------------------------------------------------------- 1 | function varargout=size(varargin) 2 | %SIZE (overloaded) 3 | 4 | if nargin == 1 5 | bsize = varargin{1}.dim; 6 | switch (nargout) 7 | case 0 8 | varargout{1} = bsize; 9 | case 1 10 | varargout{1} = bsize; 11 | case 2 12 | varargout{1} = bsize(1); 13 | varargout{2} = bsize(2); 14 | otherwise 15 | error('>2 outputs in size?'); 16 | end 17 | else 18 | if varargin{2} > length(varargin{1}.dim) 19 | varargout{1} = 1; 20 | else 21 | varargout{1} = varargin{1}.dim(varargin{2}); 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /@sdpvar/sos1.m: -------------------------------------------------------------------------------- 1 | function X=sos1(X,weights) 2 | %SOS1 Declare special ordered set of type 1 3 | % 4 | % F = sos(p,w) 5 | % 6 | % Input 7 | % p : SDPVAR object 8 | % w : Priority weights 9 | % Output 10 | % F : CONSTRAINT object 11 | 12 | X.typeflag = 51; 13 | if nargin == 1 14 | X.extra.sosweights = 1:length(X); 15 | else 16 | X.extra.sosweights = findOutWeights(X,weights) 17 | end 18 | X = lmi(X); 19 | -------------------------------------------------------------------------------- /@sdpvar/sosd.m: -------------------------------------------------------------------------------- 1 | function [h,parvar,Q,v] = sosd(X,ops) 2 | %SOSD Returns sum-of-squares decomposition 3 | % 4 | % h = sosd(p) 5 | % 6 | % Example 7 | % 8 | % x = sdpvar(1,1);sdisplay(sosd(x^4 + 1)) 9 | 10 | if isfield(X.extra,'sosid') 11 | % This is used internally when calling sosd on SOS constraint 12 | [h,parvar,Q,v] = yalmip('getsos',X.extra.sosid); 13 | else 14 | F = sos(X); 15 | if nargin == 1 16 | solvesos(F,[],sdpsettings('verbose',0)); 17 | else 18 | solvesos(F,[],ops); 19 | end 20 | [h,parvar,Q,v] = sosd(F); 21 | end 22 | -------------------------------------------------------------------------------- /@sdpvar/spdiags.m: -------------------------------------------------------------------------------- 1 | function X=spdiags(varargin) 2 | %SPDIAGS (overloaded) 3 | 4 | if nargin < 1 5 | error('At-least 1 arguments needed'); 6 | end 7 | 8 | X = varargin{1}; 9 | newBase = []; 10 | for i = 1:length(X.lmi_variables)+1 11 | Y = X.basis(:,i); 12 | Y = reshape(Y,X.dim); 13 | tempBase = spdiags(Y,varargin{2:end}); 14 | newBase = [newBase tempBase(:)]; 15 | end 16 | X.basis = newBase; 17 | X.dim = size(tempBase); 18 | X.conicinfo = [0 0]; 19 | X = clean(X); 20 | -------------------------------------------------------------------------------- /@sdpvar/spy.m: -------------------------------------------------------------------------------- 1 | function varargout = spy(X,variablesonly) 2 | %SPY (overloaded) 3 | 4 | if nargin < 2 5 | variablesonly = 0; 6 | end 7 | if isa(X,'blkvar') 8 | X = sdpvar(X); 9 | end 10 | 11 | if variablesonly 12 | Z = X.basis(:,2:end); 13 | else 14 | Z = X.basis; 15 | end 16 | 17 | Z = reshape(sum(abs(Z),2),X.dim(1),X.dim(2)); 18 | Z = Z~=0; 19 | if nargout==0 20 | spy(Z) 21 | else 22 | varargout{1}=Z; 23 | end -------------------------------------------------------------------------------- /@sdpvar/sqr.m: -------------------------------------------------------------------------------- 1 | function y=sqr(x) 2 | y = x*x; -------------------------------------------------------------------------------- /@sdpvar/sqrtm.m: -------------------------------------------------------------------------------- 1 | function varargout = sqrtm(varargin) 2 | 3 | switch nargout 4 | case {0,1} 5 | varargout{1} = sqrtm_internal(varargin{:}); 6 | case 2 7 | [varargout{1},varargout{2}] = sqrtm_internal(varargin{:}); 8 | case 3 9 | [varargout{1},varargout{2},varargout{3}] = sqrtm_internal(varargin{:}); 10 | otherwise 11 | end 12 | -------------------------------------------------------------------------------- /@sdpvar/sumsum.m: -------------------------------------------------------------------------------- 1 | function Y=sumsum(Y) 2 | %SUM (overloaded) 3 | 4 | Y.basis = sum(Y.basis,1); 5 | Y.dim(1) = 1; 6 | Y.dim(2) = 1; 7 | % Reset info about conic terms 8 | Y.conicinfo = [0 0]; 9 | Y = clean(Y); 10 | -------------------------------------------------------------------------------- /@sdpvar/symamd.m: -------------------------------------------------------------------------------- 1 | function varargout = symamd(X,variablesonly) 2 | %SYMAMD (overloaded) 3 | 4 | if nargin < 2 5 | variablesonly = 0; 6 | end 7 | if isa(X,'blkvar') 8 | X = sdpvar(X); 9 | end 10 | 11 | if variablesonly 12 | Z = X.basis(:,2:end); 13 | else 14 | Z = X.basis; 15 | end 16 | 17 | Z = reshape(sum(abs(Z),2),X.dim(1),X.dim(2)); 18 | Z = Z~=0; 19 | varargout{1}=symamd(Z); -------------------------------------------------------------------------------- /@sdpvar/toeplitz.m: -------------------------------------------------------------------------------- 1 | function t = toeplitz(c,r) 2 | %TOEPLITZ (overloaded) 3 | 4 | % direct 1-to-1 copy of MATLAB double code 5 | if nargin < 2, 6 | c.basis(1,:) = conj(c.basis(1,:)); 7 | r = c; 8 | c.basis = conj(c.basis); 9 | end 10 | r = reshape(r,prod(size(r)),1); 11 | p = length(r); 12 | m = length(c); 13 | x = [extsubsref(r,p:-1:2) ; reshape(c,prod(size(c)),1)]; 14 | cidx = (0:m-1)'; 15 | ridx = p:-1:1; 16 | t = cidx(:,ones(p,1)) + ridx(ones(m,1),:); 17 | if isrow(t) 18 | t = extsubsref(x,t).'; 19 | else 20 | t = extsubsref(x,t); 21 | end 22 | if isa(t,'sdpvar') 23 | t.conicinfo = [0 0]; 24 | end 25 | 26 | -------------------------------------------------------------------------------- /@sdpvar/transpose.m: -------------------------------------------------------------------------------- 1 | function X=transpose(X) 2 | %TRANSPOSE (overloaded) 3 | 4 | if isa(X,'blkvar') 5 | X = sdpvar(X); 6 | end 7 | 8 | n = X.dim(1); 9 | m = X.dim(2); 10 | ind = reshape(reshape(1:n*m,n,m)',n*m,1); 11 | X.basis = X.basis(ind,:); 12 | X.dim(1) = m; 13 | X.dim(2) = n; 14 | % Reset info about conic terms 15 | X.conicinfo = [0 0]; 16 | 17 | -------------------------------------------------------------------------------- /@sdpvar/uminus.m: -------------------------------------------------------------------------------- 1 | function Y = uminus(Y) 2 | %UMINUS (overloaded) 3 | 4 | if isa(Y,'blkvar') 5 | Y = sdpvar(Y); 6 | end 7 | 8 | switch Y.typeflag 9 | case {0,1,2,3,4} 10 | Y.basis = -Y.basis; 11 | case 5 12 | error('Cone object cannot be negated'); 13 | otherwise 14 | end 15 | % Reset info about conic terms 16 | Y.conicinfo = [0 0]; 17 | if ~isempty(Y.extra.opname) 18 | if isempty(strfind(Y.extra.opname,'scaled')) 19 | Y.extra.opname = ['scaled ' Y.extra.opname]; 20 | end 21 | end 22 | 23 | 24 | -------------------------------------------------------------------------------- /@sdpvar/unique.m: -------------------------------------------------------------------------------- 1 | function [x,i] = unique(x) 2 | %UNIQUE (overloaded) 3 | 4 | if min(x.dim(1),x.dim(2))~=1 5 | error('UNIQUE currently only supported for vectors') 6 | end 7 | 8 | base = x.basis; 9 | vars = x.lmi_variables; 10 | [new_base,i,j] = unique(base,'rows'); 11 | 12 | x.basis = new_base; 13 | if x.dim(2)==1 14 | x.dim(1) = size(new_base,1); 15 | else 16 | x.dim(2) = size(new_base,1); 17 | end 18 | % Reset info about conic terms 19 | x.conicinfo = [0 0]; 20 | 21 | -------------------------------------------------------------------------------- /@sdpvar/uplus.m: -------------------------------------------------------------------------------- 1 | function Z = uplus(Y) 2 | %UPLUS (overloaded) 3 | 4 | disp('Most likely you meant to write a + b, but you wrote a +b') 5 | disp('This can easily lead to bugs, as [a +b] is a vector with two elements') 6 | disp('If you really want to use unitary plus, you will have to edit sdpvar/uplus') 7 | disp('and delete this message') 8 | if isa(Y,'blkvar') 9 | Y = sdpvar(Y); 10 | end 11 | 12 | switch Y.typeflag 13 | case {0,5} 14 | Z = Y; 15 | case {1,3,4} 16 | error('Relational objects canot be manipulated') 17 | otherwise 18 | error('Please report internal bug in sdpvar/uplus') 19 | end 20 | 21 | -------------------------------------------------------------------------------- /@sdpvar/var.m: -------------------------------------------------------------------------------- 1 | function varargout=var(varargin) 2 | %VAR (overloaded) 3 | % 4 | % V = var(x) 5 | 6 | x = varargin{1}; 7 | 8 | if nargin > 1 || min(size(x))>1 9 | error('SDPVAR/VAR only supports simple 1-D variance'), 10 | end 11 | 12 | switch length(x) 13 | case 1 14 | varargout{1} = 0; 15 | otherwise 16 | x = reshape(x,length(x),1); 17 | m = sum(x)/length(x); 18 | varargout{1} = ((x-m)'*(x-m)) / (length(x) - 1); 19 | end 20 | -------------------------------------------------------------------------------- /@sdpvar/variablereplace.m: -------------------------------------------------------------------------------- 1 | function y = variablereplace(y,oldVar,newVar) 2 | 3 | var = y.lmi_variables; 4 | 5 | [~,pos] = ismember(oldVar,var); 6 | if any(pos) 7 | index = find(pos); 8 | pos = pos(index); 9 | y.lmi_variables(pos) = newVar(index); 10 | 11 | [var,pos] = sort(y.lmi_variables); 12 | y.lmi_variables = var; 13 | y.basis = [y.basis(:,1) y.basis(:,1+pos)]; 14 | end 15 | -------------------------------------------------------------------------------- /@sdpvar/vec.m: -------------------------------------------------------------------------------- 1 | function x = vec(x) 2 | 3 | x.dim = [prod(x.dim) 1]; 4 | -------------------------------------------------------------------------------- /@sdpvar/zeros.m: -------------------------------------------------------------------------------- 1 | function sys = zeros(varargin) 2 | % ZEROS Creates overloaded SDPVAR zeros 3 | % 4 | % zeros(N,M,'like',spvar) generates an N-by-M zero matrix 5 | % which actually is an SDPVAR, which means its elements can be changed to 6 | % SDPVARs 7 | % 8 | % Example 9 | % X = zeros(2,3,'like',sdpvar) 10 | % y = sdpvar(1); 11 | % X(1,3) = y; 12 | % ShouldBeZero = X - [0 0 y;0 0 0] 13 | 14 | sys = double2sdpvar(zeros(varargin{1:nargin-2})); -------------------------------------------------------------------------------- /Contents.m: -------------------------------------------------------------------------------- 1 | % YALMIP 2 | % Version 22-June-2023 3 | % Help on http://yalmip.github.io 4 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yalmip/YALMIP/c9fa6d8f641908454ea7b9b2baa6db8ba78d0cd0/README.txt -------------------------------------------------------------------------------- /demos/readme.txt: -------------------------------------------------------------------------------- 1 | For demos, please see the extensive on-line manual yalmip.github.io -------------------------------------------------------------------------------- /extras/@blkvar/blkvar.m: -------------------------------------------------------------------------------- 1 | function X = blkvar 2 | % BLKVAR Constructor for block variables 3 | 4 | X.blocks = {}; 5 | X = class(X,'blkvar',sdpvar(1)); 6 | -------------------------------------------------------------------------------- /extras/@blkvar/display.m: -------------------------------------------------------------------------------- 1 | function F = display(X) 2 | % DISPLAY Overloaded 3 | 4 | try 5 | X = sdpvar(X); 6 | display(X); 7 | catch 8 | disp('Incomplete block variable.'); 9 | end 10 | -------------------------------------------------------------------------------- /extras/@blkvar/sdisplay.m: -------------------------------------------------------------------------------- 1 | function F = sdisplay(X) 2 | % DISPLAY Overloaded 3 | 4 | try 5 | error('Not implemented. Convert to SDPVAR first') 6 | catch 7 | disp('Incomplete block variable.'); 8 | end 9 | -------------------------------------------------------------------------------- /extras/@blkvar/subsasgn.m: -------------------------------------------------------------------------------- 1 | function X = subsasgn(X,I,Y) 2 | %SUBASGN (overloaded) 3 | 4 | try 5 | if strcmp('()',I.type) 6 | X_is_spdvar = isa(X,'sdpvar'); 7 | Y_is_spdvar = isa(Y,'sdpvar'); 8 | if any(I.subs{1} <=0) 9 | error('Index into matrix is negative or zero.'); 10 | end 11 | i = I.subs{1}; 12 | j = I.subs{2}; 13 | X.blocks{i,j} = Y; 14 | 15 | else 16 | error('Reference type not supported'); 17 | end 18 | 19 | catch 20 | error(lasterr) 21 | end 22 | 23 | -------------------------------------------------------------------------------- /extras/@constraint/and.m: -------------------------------------------------------------------------------- 1 | function F = and(X,Y) 2 | % Internal class for constraint list 3 | 4 | if isa(X,'sdpvar') 5 | X = true(X); 6 | end 7 | if isa(Y,'sdpvar') 8 | Y = true(Y); 9 | end 10 | if isa(X,'constraint') 11 | X = lmi(X); 12 | end 13 | if isa(Y,'constraint') 14 | Y = lmi(Y); 15 | end 16 | 17 | F = X & Y; -------------------------------------------------------------------------------- /extras/@constraint/assignschur.m: -------------------------------------------------------------------------------- 1 | function sys = assignschur(AConstraint,thecompiler,varargin) 2 | 3 | sys = assignschur(lmi(AConstraint),thecompiler,varargin{:}) 4 | -------------------------------------------------------------------------------- /extras/@constraint/checkset.m: -------------------------------------------------------------------------------- 1 | function [p,d] = checkset(X) 2 | % OBSOLETE USE CHECK 3 | 4 | switch nargout 5 | case 0 6 | check(lmi(X)); 7 | case 1 8 | p = check(lmi(X)); 9 | case 2 10 | [p,d] = check(lmi(X)); 11 | end 12 | -------------------------------------------------------------------------------- /extras/@constraint/clean.m: -------------------------------------------------------------------------------- 1 | function F = clean(X) 2 | 3 | F = clean(lmi(X)); 4 | -------------------------------------------------------------------------------- /extras/@constraint/colon.m: -------------------------------------------------------------------------------- 1 | function F = colon(F,tag) 2 | % COLON Overloaded 3 | 4 | % Allows the syntax (x>=0):Tag in order to give names/descriptions to 5 | % constraints 6 | 7 | for i = 1:length(F.ConstraintID) 8 | F.tag{i} = tag; 9 | end 10 | -------------------------------------------------------------------------------- /extras/@constraint/complements.m: -------------------------------------------------------------------------------- 1 | function F = complements(C1,C2) 2 | %COMPLEMENTS Defines complementary constraints 3 | % 4 | % F = COMPLEMENTS(C1,C2) 5 | 6 | F = complements(lmi(C1),lmi(C2)); 7 | -------------------------------------------------------------------------------- /extras/@constraint/depends.m: -------------------------------------------------------------------------------- 1 | function LinearVariables = depends(varargin) 2 | 3 | if nargin > 1 4 | LinearVariables = []; 5 | for i = 1:nargin 6 | LinearVariables_i = depends(varargin{i}); 7 | LinearVariables = [LinearVariables;LinearVariables_i(:)]; 8 | end 9 | LinearVariables = unique(LinearVariables); 10 | return 11 | else 12 | LinearVariables = depends(lmi(varargin{1})); 13 | end -------------------------------------------------------------------------------- /extras/@constraint/display.m: -------------------------------------------------------------------------------- 1 | function display(X) 2 | 3 | display(lmi(X)); 4 | -------------------------------------------------------------------------------- /extras/@constraint/dissect.m: -------------------------------------------------------------------------------- 1 | function X = dissect(Y) 2 | 3 | X = dissect_internal(Y); -------------------------------------------------------------------------------- /extras/@constraint/double.m: -------------------------------------------------------------------------------- 1 | function x = double(x); 2 | %DOUBLE (Overloaded) 3 | 4 | x = double(x.Evaluated{1}); 5 | 6 | if isessentiallyhermitian(x) 7 | x = min(eig(x)) >= 0; 8 | else 9 | x = min(x(:)) >= 0; 10 | end 11 | -------------------------------------------------------------------------------- /extras/@constraint/dual.m: -------------------------------------------------------------------------------- 1 | function sys = dual(X) 2 | %DUAL Extract dual variable 3 | % 4 | % Z = DUAL(F) Returns the dual variable for the constraint F 5 | % 6 | % See also SOLVESDP, DUALIZE 7 | 8 | sys = dual(lmi(X)); 9 | -------------------------------------------------------------------------------- /extras/@constraint/eq.m: -------------------------------------------------------------------------------- 1 | function F = eq(X,Y) 2 | % Internal class for constraint lists 3 | 4 | superiorto('sdpvar'); 5 | superiorto('double'); 6 | 7 | if isa(X,'sdpvar') 8 | if is(X,'binary') 9 | F=iff(X,Y); 10 | return; 11 | end 12 | end 13 | if isa(Y,'sdpvar') 14 | if is(Y,'binary') 15 | F=iff(Y,X); 16 | return; 17 | end 18 | end 19 | 20 | error('Equalities can not be used in double-sided constraints') 21 | -------------------------------------------------------------------------------- /extras/@constraint/flatten.m: -------------------------------------------------------------------------------- 1 | function sys = flatten(sys) 2 | 3 | % Go from an internal format which is hierarchical and performs better 4 | % when adding many constraint objects. 5 | sys = flatten(lmi(sys)); -------------------------------------------------------------------------------- /extras/@constraint/getbase.m: -------------------------------------------------------------------------------- 1 | function B = getbase(F) 2 | 3 | B = getbase(lmi(F)); -------------------------------------------------------------------------------- /extras/@constraint/getbounds.m: -------------------------------------------------------------------------------- 1 | function LU = getbounds(F,avoidequalitybounds) 2 | 3 | if nargin == 1 4 | LU = getbounds(lmi(F)); 5 | else 6 | LU = getbounds(lmi(F),avoidequalitybounds); 7 | end 8 | -------------------------------------------------------------------------------- /extras/@constraint/getcutflag.m: -------------------------------------------------------------------------------- 1 | function c = getcutflag(X) 2 | 3 | c = []; 4 | for i = 1:length(X.clauses) 5 | c = [c;X.clauses{i}.cut]; 6 | end -------------------------------------------------------------------------------- /extras/@constraint/getlist.m: -------------------------------------------------------------------------------- 1 | function [F,strict,LMIIdentifiers,tags] = getlist(X) 2 | % Internal class for constraint lists 3 | 4 | F = X.Evaluated; 5 | strict = X.strict; 6 | LMIIdentifiers = X.ConstraintID; 7 | tags = X.tag; 8 | 9 | % FIX : treat equalities better 10 | if isequal(X.List{2},'==') 11 | F{1}=sethackflag(F{1},3); 12 | end -------------------------------------------------------------------------------- /extras/@constraint/getvariables.m: -------------------------------------------------------------------------------- 1 | function var = getvariables(F) 2 | var = getvariables(lmi(F)); -------------------------------------------------------------------------------- /extras/@constraint/is.m: -------------------------------------------------------------------------------- 1 | function yesno = is(X,this) 2 | 3 | yesno = is(lmi(X),this); 4 | -------------------------------------------------------------------------------- /extras/@constraint/ismember.m: -------------------------------------------------------------------------------- 1 | function F = ismember(x,F) 2 | % Internal class for constraint list 3 | 4 | F = lmi(F); 5 | F = ismember(x,F); 6 | 7 | -------------------------------------------------------------------------------- /extras/@constraint/isreal.m: -------------------------------------------------------------------------------- 1 | function YESNO = isreal(F) 2 | %ISREAL (overloaded) 3 | 4 | YESNO = isreal(lmi(F)); -------------------------------------------------------------------------------- /extras/@constraint/kkt.m: -------------------------------------------------------------------------------- 1 | function [KKTConstraints, details] = kkt(F,h,parametricVariables,ops); 2 | %KKT Create KKT system 3 | % 4 | % [KKTConstraints, details] = kkt(Constraints,Objective,parameters) 5 | 6 | if nargin == 2 7 | [KKTConstraints, details] = kkt(lmi(F),h); 8 | elseif nargin==3 9 | [KKTConstraints, details] = kkt(lmi(F),h,parametricVariables); 10 | else 11 | [KKTConstraints, details] = kkt(lmi(F),h,parametricVariables,ops); 12 | end 13 | 14 | -------------------------------------------------------------------------------- /extras/@constraint/loadobj.m: -------------------------------------------------------------------------------- 1 | function out = loadobj(obj) 2 | %LOADOBJ (overloaded) 3 | out = []; 4 | -------------------------------------------------------------------------------- /extras/@constraint/lowrank.m: -------------------------------------------------------------------------------- 1 | function F = lowrank(F,x) 2 | % LOWRANK is used to declare that a semidefinite constraint uses data with low rank. 3 | % Used in combination with the solver SDPLR 4 | 5 | if nargin > 1 6 | F = lowrank(lmi(F),x); 7 | else 8 | F = lowrank(lmi(F)); 9 | end 10 | -------------------------------------------------------------------------------- /extras/@constraint/plotlattice.m: -------------------------------------------------------------------------------- 1 | function varargout = plotlattice(varargin) 2 | %PLOTLATTICE Plots an integer lattice 3 | % 4 | % p = plotlattice(C,which,c,size,options) 5 | % 6 | % Note that only convex sets C in R^2 are supported. 7 | % 8 | % C : Constraint object 9 | % which: 'inner' or 'outer' 10 | % color: color [double] ([r g b] format) or char from 'rymcgbk' 11 | % size : Size of marker 12 | % options: options structure from sdpsettings 13 | 14 | varargin{1} = lmi(varargin{1}); 15 | if nargout == 0 16 | plotlattice(varargin{:}); 17 | else 18 | varargout{1} = plotlattice(varargin{:}); 19 | end -------------------------------------------------------------------------------- /extras/@constraint/plus.m: -------------------------------------------------------------------------------- 1 | function F = plus(x,y) 2 | 3 | F = lmi(x) + lmi(y); -------------------------------------------------------------------------------- /extras/@constraint/polyhedron.m: -------------------------------------------------------------------------------- 1 | function P = polyhedron(C) 2 | %POLYHEDRON (Overloaded) 3 | 4 | P = Polyhedron(lmi(C)); -------------------------------------------------------------------------------- /extras/@constraint/polytope.m: -------------------------------------------------------------------------------- 1 | function P = polytope(C) 2 | %POLYTOPE (Overloaded) 3 | 4 | P = polytope(lmi(C)); -------------------------------------------------------------------------------- /extras/@constraint/problemclass.m: -------------------------------------------------------------------------------- 1 | function p = problemclass(F,h) 2 | 3 | p = problemclass(lmi(F),h); 4 | -------------------------------------------------------------------------------- /extras/@constraint/projection.m: -------------------------------------------------------------------------------- 1 | function F = projection(F,x,varargin) 2 | % projection Projects polytopic set object (Requires the Multi-parametric Toolbox). 3 | % 4 | % Fproj = projection(F,x) 5 | % 6 | % F : Polytopic set object 7 | % x : Variables to project on 8 | % method : See HELP PROJECTION 9 | 10 | F = projection(lmi(F),x,varargin{:}); 11 | -------------------------------------------------------------------------------- /extras/@constraint/replace.m: -------------------------------------------------------------------------------- 1 | function F = replace(F,x,w,expand) 2 | % Internal class for constraint list 3 | 4 | F = lmi(F); 5 | if nargin ==3 6 | F = replace(F,x,w); 7 | else 8 | F = replace(F,x,w,expand); 9 | end 10 | 11 | -------------------------------------------------------------------------------- /extras/@constraint/saveobj.m: -------------------------------------------------------------------------------- 1 | function out = saveobj(obj) 2 | %SAVEOBJ (overloaded) 3 | warning('YALMIP objects cannot be saved in binary format. You will run into troubles if you try to load this file later. You should clear all YALMIP objects first, or avoid having any YALMIP objects in the list of variables which you save.'); 4 | out = []; 5 | -------------------------------------------------------------------------------- /extras/@constraint/sdpvar.m: -------------------------------------------------------------------------------- 1 | function F = sdpvar(X) 2 | % Internal class for constraint list 3 | 4 | F = sdpvar(lmi(X)); 5 | -------------------------------------------------------------------------------- /extras/@constraint/set.m: -------------------------------------------------------------------------------- 1 | function F = set(varargin) 2 | %SET OBSOLETE 3 | 4 | disp('SET has been considered obsolete for many years, and the time has come...'); 5 | disp('Update your code. https://yalmip.github.io/tutorial/basics/'); 6 | error('Obsolete command') 7 | -------------------------------------------------------------------------------- /extras/@constraint/setcutflag.m: -------------------------------------------------------------------------------- 1 | function X = setcutflag(X,flag) 2 | %setcutlag Internal : defines a SET object as a CUT 3 | 4 | X = flatten(X); 5 | if nargin == 1 6 | flag = 1; 7 | end 8 | for i = 1:length(X.clauses) 9 | X.clauses{i}.cut = flag; 10 | end -------------------------------------------------------------------------------- /extras/@constraint/spy.m: -------------------------------------------------------------------------------- 1 | function S = spy(X) 2 | S = spy(lmi(X)); -------------------------------------------------------------------------------- /extras/@constraint/subsref.m: -------------------------------------------------------------------------------- 1 | function F = subsref(F,Y) 2 | %subsref Overloaded indexing 3 | 4 | F = subsref(lmi(F),Y); -------------------------------------------------------------------------------- /extras/@constraint/tag.m: -------------------------------------------------------------------------------- 1 | function F = tag(F,t) 2 | 3 | if nargin > 1 4 | F = tag(lmi(F),t); 5 | else 6 | F = tag(lmi(F)); 7 | end 8 | 9 | -------------------------------------------------------------------------------- /extras/@constraint/unblkdiag.m: -------------------------------------------------------------------------------- 1 | function F = unblkdiag(F) 2 | 3 | F = unblkdiag(lmi(F)); -------------------------------------------------------------------------------- /extras/@constraint/uncertain.m: -------------------------------------------------------------------------------- 1 | function sys = uncertain(F) 2 | %UNCERTAIN Declare all variables in a set of constraints as uncertain 3 | 4 | sys = recover(depends(F)); 5 | sys = [F, uncertain(sys)]; 6 | -------------------------------------------------------------------------------- /extras/@constraint/value.m: -------------------------------------------------------------------------------- 1 | function x = value(x); 2 | %VALUE (Overloaded) 3 | 4 | x = value(x.Evaluated{1}); 5 | 6 | if isessentiallysymmetric(x) 7 | x = min(eig(x)) >= 0; 8 | else 9 | x = min(x(:)) >= 0; 10 | end 11 | -------------------------------------------------------------------------------- /extras/@constraint/vertcat.m: -------------------------------------------------------------------------------- 1 | function F = vertcat(varargin) 2 | 3 | F = horzcat(varargin{:}); -------------------------------------------------------------------------------- /extras/@constraint/vertex.m: -------------------------------------------------------------------------------- 1 | function V = vertex(varargin) 2 | % VERTEX Computes vertices (very rudimentary implementation) 3 | % 4 | % V = VERTEX(P) 5 | % 6 | % P : Constraint object defining a polytope 7 | % 8 | % With a second argument x the projection of the vertices 9 | % to the x-space is returned. 10 | % 11 | % See also CHEBYBALL, BOUNDINGBOX, POLYTOPE 12 | 13 | varargin{1} = lmi(varargin{1}); 14 | V = vertex(varargin{:}); -------------------------------------------------------------------------------- /extras/@lmi/and.m: -------------------------------------------------------------------------------- 1 | function sys = and(X,Y) 2 | %AND Overloaded 3 | % 4 | % See also LMI 5 | 6 | % TODO : Check if binaries etc 7 | if isa(X,'sdpvar') 8 | X = true(X); 9 | end 10 | if isa(Y,'sdpvar') 11 | Y = true(Y); 12 | end 13 | 14 | if isa(X,'constraint') 15 | X = lmi(X); 16 | end 17 | if isa(Y,'constraint') 18 | Y = lmi(Y); 19 | end 20 | 21 | sys = plus(X,Y); -------------------------------------------------------------------------------- /extras/@lmi/assignschur.m: -------------------------------------------------------------------------------- 1 | function AConstraint = assignschur(AConstraint,thecompiler,varargin) 2 | AConstraint = flatten(AConstraint); 3 | AConstraint.clauses{1}.schurfun = thecompiler; 4 | AConstraint.clauses{1}.schurdata = varargin; -------------------------------------------------------------------------------- /extras/@lmi/chanceconstraint.m: -------------------------------------------------------------------------------- 1 | function C = chanceconstraint(C,level) 2 | C = flatten(C); 3 | C.clauses{1}.jointprobabilistic = C.LMIid; 4 | C.clauses{1}.confidencelevel = level; 5 | for i = 2:length(C.clauses) 6 | C.clauses{i}.jointprobabilistic = C.LMIid; 7 | C.clauses{i}.confidencelevel = level; 8 | end -------------------------------------------------------------------------------- /extras/@lmi/checkset.m: -------------------------------------------------------------------------------- 1 | function [p,d] = checkset(X) 2 | % OBSOLETE USE CHECK 3 | 4 | switch nargout 5 | case 0 6 | check(X); 7 | case 1 8 | p = check(X); 9 | case 2 10 | [p,d] = check(X); 11 | end 12 | -------------------------------------------------------------------------------- /extras/@lmi/clean.m: -------------------------------------------------------------------------------- 1 | function F = clean(F,tol) 2 | %CLEAN Remove terms with small coefficients 3 | % 4 | % F = clean(F,tol) removes all terms with a coefficient smaller than tol 5 | 6 | for j = 1:length(F.clauses) 7 | for i = 1:length(F.clauses{j}) 8 | X = clean(F.clauses{j}{i}.data,tol); 9 | F.clauses{j}{i}.data = X; 10 | end 11 | end -------------------------------------------------------------------------------- /extras/@lmi/clear_poly_dep.m: -------------------------------------------------------------------------------- 1 | function F = clear_poly_dep(F,x,order) 2 | 3 | F = flatten(F); 4 | F.clauses{1}.data = clear_poly_dep(F.clauses{1}.data,x,order); -------------------------------------------------------------------------------- /extras/@lmi/cleardual.m: -------------------------------------------------------------------------------- 1 | function id = cleardual(F) 2 | 3 | for i = 1:length(F.LMIid) 4 | yalmip('cleardual',F.LMIid(i)); 5 | end 6 | -------------------------------------------------------------------------------- /extras/@lmi/colon.m: -------------------------------------------------------------------------------- 1 | function F = colon(F,tag) 2 | % COLON Overloaded 3 | 4 | % Allows the syntax (x>0):Tag in order to give names/descriptions to 5 | % constraints 6 | 7 | F = flatten(F); 8 | for i = 1:length(F.clauses) 9 | F.clauses{i}.handle = tag; 10 | end 11 | -------------------------------------------------------------------------------- /extras/@lmi/complements.m: -------------------------------------------------------------------------------- 1 | function sys = complements(C1,C2) 2 | %COMPLEMENTS Defines complementary constraints 3 | % 4 | % F = COMPLEMENTS(C1,C2) 5 | % 6 | % Example: F = complements(x >= 0, A*x <= b) 7 | 8 | if ~(isa(C1,'lmi') & isa(C2,'lmi')) 9 | error('both arguments in complements must be linear (in)equalities') 10 | end 11 | 12 | C1 = flatten(C1); 13 | C2 = flatten(C2); 14 | sys = C1; 15 | sys.clauses{1}.data = [C1.clauses{1}.data(:) C2.clauses{1}.data(:)]; 16 | sys.clauses{1}.extra.indicators = binvar(length(C1.clauses{1}.data(:)),1); 17 | sys.clauses{1}.type = 55; -------------------------------------------------------------------------------- /extras/@lmi/constraintclass.m: -------------------------------------------------------------------------------- 1 | function LIST = constraintclass(F,property) 2 | %CONSTRAINTCLASS Returns a list describing the constraints 3 | 4 | F = flatten(F); 5 | if isempty(F.clauses) 6 | LIST = []; 7 | else 8 | LIST = []; 9 | for i = 1:length(F.clauses) 10 | LIST = [LIST;F.clauses{i}.type]; 11 | end 12 | end 13 | 14 | -------------------------------------------------------------------------------- /extras/@lmi/convertlorentz.m: -------------------------------------------------------------------------------- 1 | function [F,changed] = convertlorentz(F) 2 | %convertlorentz Internal function: converts rotated Lorentz to SOCC 3 | 4 | changed = 0; 5 | F = flatten(F); 6 | Counter = length(F.LMIid); 7 | for i = 1:Counter 8 | % Yep, Lorentz 9 | if (F.clauses{i}.type==5) 10 | changed=1; 11 | xyz = sdpvar(F.clauses{i}.data); 12 | x = xyz(1); 13 | y = xyz(2); 14 | z = xyz(3:end); 15 | F.clauses{i}.data = [(x+y)/sqrt(2);(x-y)/sqrt(2);z]; 16 | F.clauses{i}.type = 4; 17 | end 18 | end 19 | 20 | -------------------------------------------------------------------------------- /extras/@lmi/convertsocp.m: -------------------------------------------------------------------------------- 1 | function [F,changed] = convertsocp(F) 2 | %catsdp Internal function: converts SOCP to LMI 3 | 4 | changed = 0; 5 | F = flatten(F); 6 | Counter = length(F.LMIid); 7 | for i = 1:Counter 8 | if (F.clauses{i}.type==4) 9 | changed=1; 10 | xy = F.clauses{i}.data; 11 | y = xy(1); 12 | x = xy(2:end); 13 | F.clauses{i}.data = [y x';x eye(length(x))*y]; 14 | F.clauses{i}.type = 1; 15 | end 16 | end 17 | 18 | -------------------------------------------------------------------------------- /extras/@lmi/cut.m: -------------------------------------------------------------------------------- 1 | function F = cut(F) 2 | F = setcutflag(F); -------------------------------------------------------------------------------- /extras/@lmi/degree.m: -------------------------------------------------------------------------------- 1 | function d = degree(varargin) 2 | 3 | F = varargin{1}; 4 | F = flatten(F); 5 | d = subdegree(F.clauses); 6 | 7 | function d = subdegree(clauses) 8 | d = -inf; 9 | for i = 1:length(clauses) 10 | d = max(d,degree(sdpvar(clauses{i}.data))); 11 | end -------------------------------------------------------------------------------- /extras/@lmi/dissect.m: -------------------------------------------------------------------------------- 1 | function X = dissect(Y) 2 | 3 | X = dissect_internal(Y); -------------------------------------------------------------------------------- /extras/@lmi/double.m: -------------------------------------------------------------------------------- 1 | function sys = double(X) 2 | %double Overloaded. 3 | 4 | X = flatten(X); 5 | nlmi = length(X.LMIid); 6 | 7 | if (nlmi == 0) 8 | sys = NaN; 9 | end 10 | 11 | if nlmi>1 12 | error('Double not applicable on list of constraints') 13 | end 14 | 15 | sys = double(X.clauses{1}.data); 16 | -------------------------------------------------------------------------------- /extras/@lmi/eliminateBinary.m: -------------------------------------------------------------------------------- 1 | function F = eliminateBinary(F,binaries) 2 | 3 | F = flatten(F); 4 | for i = 1:length(F.clauses) 5 | data = eliminateBinary(F.clauses{i}.data,binaries); 6 | F.clauses{i}.data = data; 7 | end -------------------------------------------------------------------------------- /extras/@lmi/end.m: -------------------------------------------------------------------------------- 1 | function index = end(X,position,numindices) 2 | %end Overloaded 3 | 4 | switch numindices 5 | case 1 6 | % User has written someting like X(end) 7 | index = length(X); 8 | case 2 9 | index = length(X); 10 | otherwise 11 | error('Indexation dimension cannot exceed 2'); 12 | end 13 | -------------------------------------------------------------------------------- /extras/@lmi/eq.m: -------------------------------------------------------------------------------- 1 | function sys = eq(X,Y) 2 | %EQ Overloaded 3 | 4 | dX = binvar(1); 5 | dY = binvar(1); 6 | sys = [iff(dX,X), iff(dY,Y), dX == dY]; 7 | -------------------------------------------------------------------------------- /extras/@lmi/expanded.m: -------------------------------------------------------------------------------- 1 | function X = expanded(F,state) 2 | 3 | F = flatten(F); 4 | if nargin == 1 5 | if length(F.LMIid) == 0 6 | X = []; 7 | else 8 | for i = 1:length(F.clauses) 9 | X(i,1) = F.clauses{i}.expanded; 10 | end 11 | end 12 | else 13 | X = F; 14 | for i = 1:length(F.clauses) 15 | X.clauses{i}.expanded = state; 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /extras/@lmi/expandmeta.m: -------------------------------------------------------------------------------- 1 | function F = expandmeta(F) 2 | 3 | F = flatten(F); 4 | meta = find(is(F,'meta')); 5 | Fnew = {}; 6 | for i = meta(:)' 7 | Fnew{i} = feval(F.clauses{i}.data{1},'expand',[],F.clauses{i}.data{2:end}); 8 | end 9 | F.clauses = {F.clauses{setdiff(1:size(F.clauses,2),meta)}}; 10 | F.LMIid(meta) = []; 11 | F = [F,Fnew{:}]; -------------------------------------------------------------------------------- /extras/@lmi/extractRandomDefinitions.m: -------------------------------------------------------------------------------- 1 | function S = extractRandomDefinitions(F) 2 | F = flatten(F); 3 | S = {}; 4 | for i = 1:length(F) 5 | S{i}.variables = F.clauses{i}.data; 6 | S{i}.distribution = struct(F.clauses{1}.data).extra.distribution; 7 | end 8 | -------------------------------------------------------------------------------- /extras/@lmi/extractglobalboundsmeta.m: -------------------------------------------------------------------------------- 1 | function Fout = extractglobalboundsmeta(F) 2 | 3 | Fout = []; 4 | F = flatten(F); 5 | meta = find(is(F,'meta')); 6 | Fnew = {}; 7 | for i = meta(:)' 8 | if isequal(F.clauses{i}.data{1},'implies') 9 | S = F.clauses{i}.data{end}; 10 | if isa(S,'lmi') 11 | try 12 | Fout = [Fout, extsubsref(S,'Global bound')]; 13 | catch 14 | end 15 | elseif isa(S,'constraint') 16 | g = struct(S).tag; 17 | if isequal(g,{'Global bound'}) 18 | Fout = [Fout, S]; 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /extras/@lmi/fastcat.m: -------------------------------------------------------------------------------- 1 | function X = fastcat(varargin) 2 | 3 | X = varargin{1}; 4 | X = flatten(X); 5 | nTOT = length(X.clauses); 6 | for i = 2:nargin 7 | X.clauses{i} = varargin{i}.clauses{1}; 8 | nTOT = nTOT + length(varargin{i}.clauses); 9 | X.LMIid = [X.LMIid varargin{i}.LMIid]; 10 | end 11 | 12 | % VERY FAST UNIQUE BECAUSE THIS IS CALLED A LOT OF TIMES.... 13 | i = sort(X.LMIid); 14 | i = i(diff([i NaN])~=0); 15 | if length(i)0 6 | if isa(sys.clauses{1},'cell') 7 | sys.clauses = [sys.clauses{:}]; 8 | end 9 | end -------------------------------------------------------------------------------- /extras/@lmi/getComplementarityTerms.m: -------------------------------------------------------------------------------- 1 | function [x,y] = getComplementarityTerms(F) 2 | 3 | F = flatten(F); 4 | xy = F.clauses{1}.data; 5 | x = xy(:,1); 6 | y = xy(:,2); 7 | -------------------------------------------------------------------------------- /extras/@lmi/getbase.m: -------------------------------------------------------------------------------- 1 | function B = getbase(F) 2 | 3 | F = flatten(F); 4 | if length(F.clauses)>1 5 | error('GETBASE can only be applied to a list with 1 constraint') 6 | else 7 | B = getbase(F.clauses{1}.data); 8 | end 9 | -------------------------------------------------------------------------------- /extras/@lmi/getcutflag.m: -------------------------------------------------------------------------------- 1 | function c = getcutflag(X) 2 | 3 | X = flatten(X); 4 | c = []; 5 | for i = 1:length(X.clauses) 6 | c = [c;X.clauses{i}.cut]; 7 | end -------------------------------------------------------------------------------- /extras/@lmi/getlmiid.m: -------------------------------------------------------------------------------- 1 | function id = getlmiid(F) 2 | 3 | id = F.LMIid; 4 | -------------------------------------------------------------------------------- /extras/@lmi/getlrdata.m: -------------------------------------------------------------------------------- 1 | function lrdata = getlrdata(F) 2 | F = flatten(F); 3 | k = 1; 4 | lrdata = []; 5 | for i = 1:length(F.clauses) 6 | if F.clauses{i}.type == 14 7 | lrdata{end+1} = F.clauses{i}.data; 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /extras/@lmi/indicators.m: -------------------------------------------------------------------------------- 1 | function s = indicators(F) 2 | 3 | F = flatten(F); 4 | try 5 | s = F.clauses{1}.extra.indicators; 6 | catch 7 | s = []; 8 | end -------------------------------------------------------------------------------- /extras/@lmi/isfeasible.m: -------------------------------------------------------------------------------- 1 | function [feasible,feaslistLMI] = isfeasible(F,tol) 2 | 3 | if nargin == 1 4 | tol = 0; 5 | end 6 | feaslistLMI = check(F); 7 | feasible = all(feaslistLMI >= -tol); 8 | -------------------------------------------------------------------------------- /extras/@lmi/isinterval.m: -------------------------------------------------------------------------------- 1 | function YESNO = isinterval(F) 2 | %ISINTERVAL (overloaded) 3 | 4 | F = flatten(F); 5 | if isempty(F.clauses) 6 | YESNO = 1; 7 | else 8 | YESNO = 1; 9 | i = 1; 10 | while (i<=length(F.clauses)) & YESNO 11 | Fi = F.clauses{i}; 12 | YESNO = YESNO & is(Fi.data,'interval'); 13 | i = i+1; 14 | end 15 | end 16 | 17 | -------------------------------------------------------------------------------- /extras/@lmi/islinear.m: -------------------------------------------------------------------------------- 1 | function itslinear=islinear(F) 2 | %ISLINEAR Check if all constraints are linear 3 | % 4 | % p = islinear(F) 5 | % 6 | % F : SET object 7 | % p : boolean 0/1 8 | 9 | [monomtable,variabletype] = yalmip('monomtable'); 10 | itslinear = 1; 11 | i = 1; 12 | F = flatten(F); 13 | while itslinear && (i<=length(F.LMIid)) 14 | Fi = F.clauses{i}; 15 | xvars = getvariables(Fi.data); 16 | itslinear = itslinear & ~any(variabletype(xvars)); 17 | i = i + 1; 18 | end -------------------------------------------------------------------------------- /extras/@lmi/ismember.m: -------------------------------------------------------------------------------- 1 | function F = ismember(x,F) 2 | % Internal class for constraint list 3 | 4 | F = replace(F,recover(depends(F)),x); 5 | -------------------------------------------------------------------------------- /extras/@lmi/isnan.m: -------------------------------------------------------------------------------- 1 | function YESNO = isnan(F) 2 | YESNO=0; -------------------------------------------------------------------------------- /extras/@lmi/isreal.m: -------------------------------------------------------------------------------- 1 | function YESNO = isreal(F) 2 | %ISREAL (overloaded) 3 | 4 | F = flatten(F); 5 | if isempty(F.clauses) 6 | YESNO = 1; 7 | else 8 | YESNO = 1; 9 | i = 1; 10 | while (i<=length(F.clauses)) & YESNO 11 | Fi = F.clauses{i}; 12 | YESNO = YESNO & is(Fi.data,'real'); 13 | i = i+1; 14 | end 15 | end 16 | 17 | -------------------------------------------------------------------------------- /extras/@lmi/issigmonial.m: -------------------------------------------------------------------------------- 1 | function itssigmonial=issigmonial(F) 2 | %ISSIGMONIAL Check if all constraints are sigmonial 3 | % 4 | % p = islinear(F) 5 | % 6 | % F : SET object 7 | % p : boolean 0/1 8 | 9 | monomtable = yalmip('monomtable'); 10 | xvars = []; 11 | 12 | itssigmonial = 1; 13 | i = 1; 14 | F = flatten(F); 15 | while itssigmonial & (i<=length(F.clauses)) 16 | Fi = F.clauses{i}; 17 | xvars = getvariables(Fi.data); 18 | monomtableX = monomtable(xvars,:); 19 | YESNO = any(find(any(0>monomtableX,2) | any(monomtableX-fix(monomtableX),2))); 20 | itssigmonial = itssigmonial & full(YESNO); 21 | i = i + 1; 22 | end -------------------------------------------------------------------------------- /extras/@lmi/length.m: -------------------------------------------------------------------------------- 1 | function varargout=length(varargin) 2 | 3 | F = varargin{1}; 4 | varargout{1} = length(F.LMIid); 5 | -------------------------------------------------------------------------------- /extras/@lmi/lifted.m: -------------------------------------------------------------------------------- 1 | function X = lifted(F,state) 2 | 3 | F = flatten(F); 4 | if nargin == 1 5 | if length(F.clauses) == 0 6 | X = []; 7 | else 8 | for i = 1:length(F.clauses) 9 | X(i,1) = F.clauses{i}.lift; 10 | end 11 | end 12 | else 13 | X = F; 14 | for i = 1:length(F.clauses) 15 | X.clauses{i}.lift = state; 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /extras/@lmi/linearize.m: -------------------------------------------------------------------------------- 1 | function [F,changed] = linearize(F) 2 | %LINEARIZE Linearizes all constraints 3 | 4 | changed = 0; 5 | F = flatten(F); 6 | Counter = length(F.LMIid); 7 | for i = 1:Counter 8 | switch F.clauses{i}.type 9 | case {1,2,3} 10 | Fi = F.clauses{i}.data; 11 | if ~is(Fi,'linear') 12 | Flin = linearize(Fi); 13 | F.clauses{i}.data = Flin; 14 | end 15 | otherwise 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /extras/@lmi/loadobj.m: -------------------------------------------------------------------------------- 1 | function out = loadobj(obj) 2 | %LOADOBJ (overloaded) 3 | out = []; -------------------------------------------------------------------------------- /extras/@lmi/minus.m: -------------------------------------------------------------------------------- 1 | function sys = minus(X,Y) 2 | %MINUS (overloaded) 3 | 4 | if isempty(X) 5 | sys = ([]); 6 | return 7 | end 8 | 9 | if isempty(Y) 10 | sys = X; 11 | return 12 | end 13 | 14 | if isa(Y,'double') || isa(X,'double') 15 | error('You cannot substract a point from a set of constraint. Constraint substraction is only used removal of constraints. To translate a set, use REPLACE') 16 | end 17 | 18 | idX = getlmiid(X); 19 | idY = getlmiid(Y); 20 | YinX = find(~ismember(idX,idY)); 21 | % Get the correct subsref... 22 | sys = subsref(X,struct('type','()','subs',{{YinX}})); 23 | -------------------------------------------------------------------------------- /extras/@lmi/or.m: -------------------------------------------------------------------------------- 1 | function varargout = or(varargin) 2 | %OR (overloaded) 3 | 4 | % Models OR using a nonlinear operator definition 5 | if nargin == 1 6 | varargout{1} = varargin{1}; 7 | else 8 | varargout{1} = (yalmip('define','lmior',varargin{:}) == 1); 9 | end 10 | -------------------------------------------------------------------------------- /extras/@lmi/problemclass.m: -------------------------------------------------------------------------------- 1 | function p = problemclass(F,h) 2 | % PROBLEMCLASS Derives an optimization object and determines the class 3 | 4 | if nargin < 2 5 | h = []; 6 | end 7 | [aux1,aux2,aux3,model] = export(F,h); 8 | p = problemclass(model); 9 | -------------------------------------------------------------------------------- /extras/@lmi/registerjacobian.m: -------------------------------------------------------------------------------- 1 | function [F] = registerjacobian(F) 2 | %REGISTERJACOBIAN Register jacobians to all constraints 3 | 4 | F = flatten(F); 5 | Counter = length(F.LMIid); 6 | for i = 1:Counter 7 | switch F.clauses{i}.type 8 | case {1,2,3} 9 | Fi = F.clauses{i}.data; 10 | F.clauses{i}.data = registerjacobian(Fi); 11 | otherwise 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /extras/@lmi/remap.m: -------------------------------------------------------------------------------- 1 | function F = remap(F,old,new) 2 | 3 | F = flatten(F); 4 | for i = 1:length(F.clauses) 5 | X = F.clauses{i}.data; 6 | X = sdpvarremap(X,old,new); 7 | F.clauses{i}.data = X; 8 | end -------------------------------------------------------------------------------- /extras/@lmi/saveobj.m: -------------------------------------------------------------------------------- 1 | function out = saveobj(obj) 2 | %SAVEOBJ (overloaded) 3 | warning('YALMIP objects cannot be saved in binary format. You will run into troubles if you try to load this file later. You should clear all YALMIP objects first, or avoid having any YALMIP objects in the list of variables which you save.'); 4 | out = []; 5 | -------------------------------------------------------------------------------- /extras/@lmi/sdpvar.m: -------------------------------------------------------------------------------- 1 | function X = sdpvar(F) 2 | 3 | F = flatten(F); 4 | if isa(F.clauses{1}.data,'double') 5 | X = F.clauses{1}.data; 6 | else 7 | X = []; 8 | for i = 1:length(F.LMIid) 9 | 10 | Xi = F.clauses{i}.data; 11 | 12 | if size(F.clauses,2)>1 13 | if isempty(X) 14 | X = reshape(Xi,[],1); 15 | else 16 | X = [X;reshape(Xi,[],1)]; 17 | end 18 | else 19 | X = Xi; 20 | end 21 | 22 | end 23 | end 24 | 25 | X = sethackflag(X,0); -------------------------------------------------------------------------------- /extras/@lmi/see.m: -------------------------------------------------------------------------------- 1 | function see(F) 2 | %see Displays internal structure of matrix variable in a constraint 3 | 4 | F = flatten(F); 5 | if length(F.LMIid)>1 6 | disp('Can only apply SEE on set objects with one constraint'); 7 | else 8 | see(F.clauses{1}.data); 9 | end -------------------------------------------------------------------------------- /extras/@lmi/set.m: -------------------------------------------------------------------------------- 1 | function F = set(F,tag) 2 | 3 | disp('SET has been considered obsolete for many years, and the time has come...'); 4 | disp('Update your code. http://users.isy.liu.se/johanl/yalmip/pmwiki.php?n=Commands.set'); 5 | error('Obsolete command') 6 | -------------------------------------------------------------------------------- /extras/@lmi/setcutflag.m: -------------------------------------------------------------------------------- 1 | function X = setcutflag(X,flag) 2 | %setcutlag Internal : defines a SET object as a CUT 3 | 4 | if nargin == 1 5 | flag = 1; 6 | end 7 | X = flatten(X); 8 | for i = 1:length(X.clauses) 9 | X.clauses{i}.cut = flag; 10 | end -------------------------------------------------------------------------------- /extras/@lmi/setdualize.m: -------------------------------------------------------------------------------- 1 | function sys = setdualize(sys,state) 2 | 3 | sys.dualized = state; -------------------------------------------------------------------------------- /extras/@lmi/setupMeta.m: -------------------------------------------------------------------------------- 1 | function F = setupMeta(F,operator,varargin) 2 | 3 | F = flatten(F); 4 | F.clauses{1}.type = 56; 5 | F.clauses{1}.data = {operator, varargin{:}}; 6 | F.LMIid = yalmip('lmiid'); 7 | -------------------------------------------------------------------------------- /extras/@lmi/size.m: -------------------------------------------------------------------------------- 1 | function varargout=size(varargin) 2 | %size Returns the number of constraints 3 | % 4 | % n = SIZE(F) Returns the number of constraints 5 | % [n,m] = SIZE(F) Returns the number of constraints, m=1 6 | 7 | F = flatten(varargin{1}); 8 | switch (nargout) 9 | case {0,1} 10 | varargout{1} = [length(F.clauses) 1]; 11 | case 2 12 | varargout{1} = length(F.clauses); 13 | varargout{2} = 1; 14 | otherwise 15 | error('>2 outputs in size?'); 16 | end 17 | -------------------------------------------------------------------------------- /extras/@lmi/sosd.m: -------------------------------------------------------------------------------- 1 | function [h,parvar,Q,v] = sosd(X) 2 | % SOSD Returns sum-of-squares decomposition (if available) 3 | 4 | if ~is(X,'sos') 5 | error('SOS decompositions are only available for SOS objects'); 6 | else 7 | [h,parvar,Q,v] = sosd(sdpvar(X)); 8 | end -------------------------------------------------------------------------------- /extras/@lmi/spy.m: -------------------------------------------------------------------------------- 1 | function S = spy(X) 2 | %SPY (overloaded) 3 | 4 | F = flatten(X); 5 | if length(X)>1 6 | S = []; 7 | for i = 1:length(X) 8 | S = blkdiag(S,spy(X.clauses{1}.data)); 9 | end 10 | if nargout == 0 11 | spy(S); 12 | end 13 | else 14 | X = spy(sdpvar(X)); 15 | if nargout==0 16 | spy(X); 17 | else 18 | S = X; 19 | end 20 | end -------------------------------------------------------------------------------- /extras/@lmi/tag.m: -------------------------------------------------------------------------------- 1 | function F = tag(F,text) 2 | % TAG 3 | % 4 | % Sets the tag on a constraint. 5 | 6 | F = flatten(F); 7 | if nargin == 1 8 | F = F.clauses{1}.handle; 9 | else 10 | for i = 1:length(F.clauses) 11 | if ~isequal(F.clauses{i}.handle,'placeholder') 12 | F.clauses{i}.handle = text; 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /extras/@lmi/uncertain.m: -------------------------------------------------------------------------------- 1 | function sys = uncertain(F) 2 | %UNCERTAIN Declare all variables in a set of constraints as uncertain 3 | 4 | sys = recover(depends(F)); 5 | sys = [F, uncertain(sys)]; 6 | -------------------------------------------------------------------------------- /extras/@lmi/uplus.m: -------------------------------------------------------------------------------- 1 | function X = uplus(X) 2 | %UPLUS (overloaded) -------------------------------------------------------------------------------- /extras/@lmi/usedvariables.m: -------------------------------------------------------------------------------- 1 | function used = lmi(F) 2 | 3 | used = []; 4 | F = flatten(F); 5 | for i = 1:length(F.clauses) 6 | Fi = F.clauses{i}; 7 | used = unique([used;getvariables(Fi.data)']); 8 | end 9 | -------------------------------------------------------------------------------- /extras/@lmi/value.m: -------------------------------------------------------------------------------- 1 | function sys = value(X) 2 | %double Overloaded. 3 | 4 | X = flatten(X); 5 | nlmi = length(X.LMIid); 6 | 7 | if (nlmi == 0) 8 | sys = NaN; 9 | end 10 | 11 | if nlmi>1 12 | error('Double not applicable on list of constraints') 13 | end 14 | 15 | sys = value(X.clauses{1}.data); 16 | -------------------------------------------------------------------------------- /extras/@lmi/variablereplace.m: -------------------------------------------------------------------------------- 1 | function F = variablereplace(F,oldVar,newVar) 2 | 3 | for i = 1:length(F.clauses) 4 | if isa(F.clauses{i},'cell') 5 | for j = 1:length(F.clauses{i}) 6 | F.clauses{i}{j}.data = variablereplace(F.clauses{i}{j}.data,oldVar,newVar); 7 | end 8 | else 9 | F.clauses{i}.data = variablereplace(F.clauses{i}.data,oldVar,newVar); 10 | end 11 | end -------------------------------------------------------------------------------- /extras/@lmi/vertcat.m: -------------------------------------------------------------------------------- 1 | function F = vertcat(varargin) 2 | 3 | F = horzcat(varargin{:}); -------------------------------------------------------------------------------- /extras/@logdet/depends.m: -------------------------------------------------------------------------------- 1 | function v = depends(X) 2 | 3 | v = depends(X.cx); 4 | for i = 1:length(X.P) 5 | v = [v depends(X.P{i})]; 6 | end 7 | v = unique(v); 8 | -------------------------------------------------------------------------------- /extras/@logdet/display.m: -------------------------------------------------------------------------------- 1 | function display(X) 2 | %display Overloaded 3 | 4 | P = X.P; 5 | classification = 'Logdet-term '; 6 | [n,m] = size(P); 7 | classification = [classification num2str(n) 'x' num2str(m)]; 8 | 9 | value = double(X); 10 | if ~isnan(value); 11 | classification = [classification ' (current value: ' num2str(value) ')']; 12 | end 13 | disp(classification); -------------------------------------------------------------------------------- /extras/@logdet/double.m: -------------------------------------------------------------------------------- 1 | function value = double(X); 2 | %double Overloaded 3 | 4 | if isempty(X.cx) 5 | value = 0; 6 | else 7 | value = double(X.cx); 8 | end 9 | for i = 1:length(X.P); 10 | value = value + X.gain(i)*log(det(double(X.P{i}))); 11 | end 12 | -------------------------------------------------------------------------------- /extras/@logdet/getP.m: -------------------------------------------------------------------------------- 1 | function cx = getP(X) 2 | %display Overloaded 3 | 4 | cx = X.P; 5 | -------------------------------------------------------------------------------- /extras/@logdet/getcx.m: -------------------------------------------------------------------------------- 1 | function cx = getcx(X) 2 | 3 | cx = X.cx; 4 | -------------------------------------------------------------------------------- /extras/@logdet/getgain.m: -------------------------------------------------------------------------------- 1 | function cx = getgain(X) 2 | 3 | cx = X.gain; 4 | -------------------------------------------------------------------------------- /extras/@logdet/logdet.m: -------------------------------------------------------------------------------- 1 | function sys = logdet(P) 2 | 3 | % Create an object 4 | if isa(P,'sdpvar') 5 | if is(P,'hermitian') 6 | superiorto('double') 7 | superiorto('sdpvar') 8 | sys.P = {P}; 9 | sys.cx = []; 10 | sys.gain = 1; 11 | sys = class(sys,'logdet'); 12 | else 13 | error('logdet can only be applied to Hermitian SDPVAR objects') 14 | end 15 | elseif isa(P,'double') 16 | if isessentiallyhermitian(P) 17 | sys = sum(log(abs(real(eig(P))))); 18 | else 19 | error('logdet can only be applied to Hermitian objects') 20 | end 21 | end 22 | 23 | 24 | -------------------------------------------------------------------------------- /extras/@logdet/mtimes.m: -------------------------------------------------------------------------------- 1 | function Z = mtimes(A,B) 2 | %plus Overloaded 3 | 4 | % Standard case A.cx + A.logdetP + (B.cx + B.logdetP) 5 | 6 | if ~(isa(A,'double') | isa(B,'double')) 7 | error('LOGDET objects can only be multiplied with constants') 8 | end 9 | 10 | if isa(A,'logdet') 11 | temp = A; 12 | A = B; 13 | B = temp; 14 | end 15 | 16 | % OK, constant*logdet 17 | % end 18 | B.gain = B.gain*A; 19 | B.cx = B.cx*A; 20 | Z = B; -------------------------------------------------------------------------------- /extras/@logdet/uminus.m: -------------------------------------------------------------------------------- 1 | function Z = uminus(P) 2 | %display Overloaded 3 | 4 | Z = P; 5 | Z.cx = - Z.cx; 6 | Z.gain = -Z.gain; 7 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/abs.m: -------------------------------------------------------------------------------- 1 | function X = abs(X) 2 | %ABS (overloaded) 3 | 4 | X = reshape(abs(reshape(X,prod(X.dim),1)),X.dim); 5 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/alldifferent.m: -------------------------------------------------------------------------------- 1 | function t = alldifferent(X) 2 | % alldifferent (overloaded) 3 | 4 | t = alldifferent(sdpvar(X)); -------------------------------------------------------------------------------- /extras/@ndsdpvar/assign.m: -------------------------------------------------------------------------------- 1 | function assign(x,y) 2 | % assign (overloaded) 3 | 4 | assign(sdpvar(x),y(:)); -------------------------------------------------------------------------------- /extras/@ndsdpvar/binary.m: -------------------------------------------------------------------------------- 1 | function x = binary(x) 2 | % binary (overloaded) 3 | 4 | x = binary(sdpvar(x)); -------------------------------------------------------------------------------- /extras/@ndsdpvar/circshift.m: -------------------------------------------------------------------------------- 1 | function X = circshift(varargin) 2 | % CIRCSHIFT (overloaded) 3 | 4 | Y = varargin{1}; 5 | X = Y; 6 | X.basis = []; 7 | for i = 1:size(Y.basis,2) 8 | base = reshape(full(Y.basis(:,i)),X.dim); 9 | base = circshift(base,varargin{2:end}); 10 | X.basis = [X.basis sparse(base(:))]; 11 | end 12 | X.dim = size(base); 13 | X.conicinfo = [0 0]; 14 | X = clean(X); -------------------------------------------------------------------------------- /extras/@ndsdpvar/depends.m: -------------------------------------------------------------------------------- 1 | function v = depends(X) 2 | % depends (overloaded) 3 | 4 | v = depends(sdpvar(X)); -------------------------------------------------------------------------------- /extras/@ndsdpvar/diff.m: -------------------------------------------------------------------------------- 1 | function X = diff(varargin) 2 | % DIFF (overloaded) 3 | 4 | Y = varargin{1}; 5 | X = Y; 6 | X.basis = []; 7 | for i = 1:size(Y.basis,2) 8 | base = reshape(full(Y.basis(:,i)),X.dim); 9 | base = diff(base,varargin{2:end}); 10 | X.basis = [X.basis sparse(base(:))]; 11 | end 12 | X.dim = size(base); 13 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/display.m: -------------------------------------------------------------------------------- 1 | function F = display(X) 2 | % DISPLAY Overloaded 3 | 4 | d = X.dim; 5 | disp(['Multi-dimensional SDPVAR object ' sizestring(d)]) 6 | 7 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/double.m: -------------------------------------------------------------------------------- 1 | function X = double(X) 2 | % DOUBLE (overloaded) 3 | 4 | X = reshape(double(sdpvar(X)),X.dim); -------------------------------------------------------------------------------- /extras/@ndsdpvar/end.m: -------------------------------------------------------------------------------- 1 | function index = end(X,position,numindices) 2 | %END (overloaded) 3 | 4 | if nargin == 2 5 | index = X.dim(position); 6 | else 7 | if numindices == 1 8 | index = prod(X.dim); 9 | elseif numindices == length(X.dim) 10 | index = X.dim(position); 11 | else 12 | error('Indexing logic not supported yet'); 13 | end 14 | end -------------------------------------------------------------------------------- /extras/@ndsdpvar/eq.m: -------------------------------------------------------------------------------- 1 | function y = eq(X,Y) 2 | %EQ (overloaded) 3 | 4 | if isa(X,'ndsdpvar') 5 | X = sdpvar(X); 6 | elseif isa(X,'double') 7 | X = X(:); 8 | end 9 | 10 | if isa(Y,'ndsdpvar') 11 | Y = sdpvar(Y); 12 | elseif isa(Y,'double') 13 | Y = Y(:); 14 | end 15 | 16 | try 17 | y = constraint(X,'==',Y); 18 | catch 19 | error(lasterr) 20 | end 21 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/ge.m: -------------------------------------------------------------------------------- 1 | function y = ge(X,Y) 2 | %GE (overloaded) 3 | 4 | if isa(X,'ndsdpvar') 5 | X = sdpvar(X); 6 | elseif isa(X,'double') 7 | X = X(:); 8 | end 9 | 10 | if isa(Y,'ndsdpvar') 11 | Y = sdpvar(Y); 12 | elseif isa(Y,'double') 13 | Y = Y(:); 14 | end 15 | 16 | try 17 | y = constraint(X,'>=',Y); 18 | catch 19 | error(lasterr) 20 | end 21 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/getbasematrix.m: -------------------------------------------------------------------------------- 1 | function Q=getbasematrix(X,ind) 2 | %GETBASEMATRIX Internal function to extract basematrix for variable IND 3 | 4 | if ind==0 5 | base = X.basis(:,1); 6 | Q = reshape(base,X.dim); 7 | return; 8 | end 9 | 10 | here = find(X.lmi_variables==ind); 11 | if isempty(here) 12 | error 13 | else 14 | base = X.basis(:,here+1); 15 | Q = reshape(base,X.dim); 16 | end 17 | 18 | 19 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/gethackflag.m: -------------------------------------------------------------------------------- 1 | function y = gethackflag(X) 2 | %GETHACKFLAG Internal function to extract constraint type 3 | 4 | y = X.typeflag; 5 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/getvariables.m: -------------------------------------------------------------------------------- 1 | function v = getvariables(X) 2 | % getvariables (overloaded) 3 | 4 | v = getvariables(sdpvar(X)); 5 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/gt.m: -------------------------------------------------------------------------------- 1 | function y = gt(X,Y) 2 | error('Strict inequalities are not supported (learn why)') -------------------------------------------------------------------------------- /extras/@ndsdpvar/horzcat.m: -------------------------------------------------------------------------------- 1 | function x = horzcat(varargin) 2 | % horzcat (overloaded) 3 | 4 | x = cat(2,varargin{:}); -------------------------------------------------------------------------------- /extras/@ndsdpvar/imag.m: -------------------------------------------------------------------------------- 1 | function X = imag(X) 2 | % REAL (overloaded) 3 | 4 | X.basis = imag(X.basis); 5 | X.conicinfo = [0 0]; 6 | X = clean(X); -------------------------------------------------------------------------------- /extras/@ndsdpvar/integer.m: -------------------------------------------------------------------------------- 1 | function x = integer(x) 2 | % integer (overloaded) 3 | 4 | x = sdpvar(x); 5 | x = binary(x); -------------------------------------------------------------------------------- /extras/@ndsdpvar/is.m: -------------------------------------------------------------------------------- 1 | function YESNO = is(X,property,additional) 2 | %IS Check property of variable. 3 | % d = IS(x,property) returns 1 if 'property' holds 4 | % 5 | % Properties possible to test are: 'complex' 6 | 7 | switch property 8 | case 'complex' 9 | YESNO = ~isreal(X.basis); 10 | otherwise 11 | error('Wrong input argument.'); 12 | end 13 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/isreal.m: -------------------------------------------------------------------------------- 1 | function v = isreal(X) 2 | % isreal (overloaded) 3 | 4 | v = isreal(sdpvar(X)); -------------------------------------------------------------------------------- /extras/@ndsdpvar/le.m: -------------------------------------------------------------------------------- 1 | function y = le(X,Y) 2 | %LE (overloaded) 3 | 4 | if isa(X,'ndsdpvar') 5 | X = sdpvar(X); 6 | elseif isa(X,'double') 7 | X = X(:); 8 | end 9 | 10 | if isa(Y,'ndsdpvar') 11 | Y = sdpvar(Y); 12 | elseif isa(Y,'double') 13 | Y = Y(:); 14 | end 15 | 16 | try 17 | y = constraint(X,'<=',Y); 18 | catch 19 | error(lasterr) 20 | end 21 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/length.m: -------------------------------------------------------------------------------- 1 | function v = length(X) 2 | % length (overloaded) 3 | 4 | v = max(X.dim); -------------------------------------------------------------------------------- /extras/@ndsdpvar/lt.m: -------------------------------------------------------------------------------- 1 | function y = lt(X,Y) 2 | error('Strict inequalities are not supported (learn why)') -------------------------------------------------------------------------------- /extras/@ndsdpvar/ndims.m: -------------------------------------------------------------------------------- 1 | function n=ndims(X) 2 | %NDIM (overloaded) 3 | 4 | n = length(X.dim); -------------------------------------------------------------------------------- /extras/@ndsdpvar/numel.m: -------------------------------------------------------------------------------- 1 | function s = numel(X) 2 | % NUMEL (overloaded) 3 | 4 | s = prod(X.dim); -------------------------------------------------------------------------------- /extras/@ndsdpvar/permute.m: -------------------------------------------------------------------------------- 1 | function X=permute(X,p) 2 | %PERMUTE (overloaded) 3 | 4 | if length(X.dim) < length(p) 5 | X.dim = [X.dim ones(1,length(p)-length(X.dim))]; 6 | end 7 | i = 1:prod(X.dim); 8 | i = reshape(i,X.dim); 9 | i = permute(i,p); 10 | X.basis = X.basis(i,:); 11 | X.dim = X.dim(p); 12 | while length(size(X)) > 2 && X.dim(end) == 1; 13 | X.dim = X.dim(1:end-1); 14 | if length(X.dim)==2 15 | X = reshape(sdpvar(X),X.dim); 16 | end 17 | end -------------------------------------------------------------------------------- /extras/@ndsdpvar/power.m: -------------------------------------------------------------------------------- 1 | function X = power(X,d) 2 | % POWER (overloaded) 3 | 4 | % Vectorize x if d is vector 5 | if numel(X)==1 & (numel(d)>1) 6 | X = X.*ones(size(d)); 7 | end 8 | % Vectorize if x is a vector 9 | if numel(d)==1 & (numel(X)>1) 10 | d = d.*ones(size(X)); 11 | end 12 | s = size(X); 13 | if isa(X,'ndsdpvar') 14 | X = sdpvar(X); 15 | else 16 | X = X(:); 17 | end 18 | d = reshape(d,[],1); 19 | X = power(X,d); 20 | X = reshape(X,s); -------------------------------------------------------------------------------- /extras/@ndsdpvar/real.m: -------------------------------------------------------------------------------- 1 | function X = real(X) 2 | % REAL (overloaded) 3 | 4 | X.basis = real(X.basis); 5 | X.conicinfo = [0 0]; 6 | X = clean(X); -------------------------------------------------------------------------------- /extras/@ndsdpvar/repmat.m: -------------------------------------------------------------------------------- 1 | function Y=repmat(varargin) 2 | %REPMAT (overloaded) 3 | 4 | Y = varargin{1}; 5 | dim = Y.dim; 6 | resize = [varargin{2:end}]; 7 | index = (1:size(Y.basis,1))'; 8 | index = reshape(index,Y.dim); 9 | index = repmat(index,resize); 10 | Y.basis = Y.basis(index(:),:); 11 | Y.dim = size(index); 12 | % Reset info about conic terms 13 | Y.conicinfo = [0 0]; 14 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/reshape.m: -------------------------------------------------------------------------------- 1 | function Y=reshape(varargin) 2 | %RESHAPE (overloaded) 3 | 4 | Y = varargin{1}; 5 | % simple hack to figure out new sizes 6 | temp = reshape(ones(size(Y.basis,1),1),varargin{2:end}); 7 | Y.conicinfo = [0 0]; 8 | Y.dim = size(temp); 9 | Y = clean(Y); -------------------------------------------------------------------------------- /extras/@ndsdpvar/sdpvar.m: -------------------------------------------------------------------------------- 1 | function F = sdpvar(X) 2 | % SDPVAR Converts a NDSDPVAR variable to standard SDPVAR 3 | 4 | F = sdpvar(prod(X.dim),1,[],X.lmi_variables,X.basis); -------------------------------------------------------------------------------- /extras/@ndsdpvar/see.m: -------------------------------------------------------------------------------- 1 | function see(X) 2 | % SEE (overloaded) 3 | 4 | disp('Constant matrix');disp(' ') 5 | disp(full(getbasematrix(X,0))) 6 | disp('Base matrices');disp(' ') 7 | for i = 1:length(X.lmi_variables); 8 | disp(full(getbasematrix(X,X.lmi_variables(i)))) 9 | disp(' ') 10 | end; 11 | disp('Used variables');disp(' ') 12 | disp(X.lmi_variables) -------------------------------------------------------------------------------- /extras/@ndsdpvar/shiftdim.m: -------------------------------------------------------------------------------- 1 | function [X,n] = shiftdim(varargin) 2 | % SHIFTDIM (overloaded) 3 | 4 | Y = varargin{1}; 5 | X = Y; 6 | X.basis = []; 7 | for i = 1:size(Y.basis,2) 8 | base = reshape(full(Y.basis(:,i)),X.dim); 9 | [base,n] = shiftdim(base,varargin{2:end}); 10 | X.basis = [X.basis sparse(base(:))]; 11 | end 12 | X.dim = size(base); 13 | X.conicinfo = [0 0]; 14 | X = clean(X); -------------------------------------------------------------------------------- /extras/@ndsdpvar/sqrt.m: -------------------------------------------------------------------------------- 1 | function X = abs(X) 2 | % sqrt (overloaded) 3 | 4 | X = reshape(sqrt(reshape(X,prod(X.dim),1)),X.dim); 5 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/squeeze.m: -------------------------------------------------------------------------------- 1 | function X = squeeze(X) 2 | % squeeze (overloaded) 3 | 4 | dummy = reshape(ones(prod(X.dim),1),X.dim); 5 | dummy = squeeze(dummy); 6 | X.dim = size(dummy); 7 | X = clean(X); 8 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/times.m: -------------------------------------------------------------------------------- 1 | function F = times(X,Y) 2 | % times (overloaded) 3 | 4 | if isa(X,'ndsdpvar') 5 | dim = X.dim; 6 | X = sdpvar(X); 7 | else 8 | X = X(:); 9 | end 10 | if isa(Y,'ndsdpvar') 11 | dim = Y.dim; 12 | Y = sdpvar(Y); 13 | else 14 | Y = Y(:); 15 | end 16 | 17 | F = X.*Y; 18 | F = reshape(F,dim); -------------------------------------------------------------------------------- /extras/@ndsdpvar/uminus.m: -------------------------------------------------------------------------------- 1 | function X = uminus(X) 2 | % UMINUS (overloaded) 3 | 4 | X.basis = -X.basis; -------------------------------------------------------------------------------- /extras/@ndsdpvar/value.m: -------------------------------------------------------------------------------- 1 | function X = value(X) 2 | % VALUE (overloaded) 3 | 4 | X = reshape(value(sdpvar(X)),X.dim); -------------------------------------------------------------------------------- /extras/@ndsdpvar/vec.m: -------------------------------------------------------------------------------- 1 | function x = vec(x) 2 | 3 | x.dim = [prod(x.dim) 1]; 4 | -------------------------------------------------------------------------------- /extras/@ndsdpvar/vertcat.m: -------------------------------------------------------------------------------- 1 | function x = vertcat(varargin) 2 | % horzcat (overloaded) 3 | 4 | x = cat(1,varargin{:}); -------------------------------------------------------------------------------- /extras/@optimizer/cat.m: -------------------------------------------------------------------------------- 1 | function sys = cat(varargin) 2 | 3 | if nargin == 1 4 | sys = varargin{1}; 5 | return 6 | end 7 | 8 | y = horzcat(varargin{:}); -------------------------------------------------------------------------------- /extras/@optimizer/display.m: -------------------------------------------------------------------------------- 1 | function display(X) 2 | %display Overloaded 3 | 4 | n = 0; 5 | for i = 1:length(X.diminOrig) 6 | n = n + prod(X.diminOrig{i}); 7 | end 8 | m = 0; 9 | for i = 1:length(X.dimoutOrig) 10 | m = m + prod(X.dimoutOrig{i}); 11 | end 12 | text = ['Optimizer object with ' num2str(n) ' inputs (' num2str(length(X.diminOrig)) ' blocks) and ' num2str(m) ' outputs (' num2str(length(X.dimoutOrig)) ' blocks).']; 13 | if isempty(X.ParametricSolution) 14 | text = [text ' Solver: ' upper(X.model.solver.tag)]; 15 | else 16 | text = [text ' Parametric solution computed.' ]; 17 | end 18 | disp(text) 19 | -------------------------------------------------------------------------------- /extras/@optimizer/kkt.m: -------------------------------------------------------------------------------- 1 | function [KKTConstraints, details] = kkt(P) 2 | %DUAL Create KKT system for optimizer P 3 | % 4 | % [KKTConstraints, details] = kkt(P) 5 | 6 | [KKTConstraints, details] = kkt(P.F,P.h,P.output.expression); 7 | 8 | -------------------------------------------------------------------------------- /extras/@optimizer/loadobj.m: -------------------------------------------------------------------------------- 1 | function P = loadobj(P) 2 | if isstruct(P), 3 | P = class(P,'optimizer'); 4 | end -------------------------------------------------------------------------------- /extras/@optimizer/numel.m: -------------------------------------------------------------------------------- 1 | function N=numel(varargin) 2 | %NUMEL (overloaded) 3 | 4 | N = 1; -------------------------------------------------------------------------------- /extras/@optimizer/saveobj.m: -------------------------------------------------------------------------------- 1 | function P = saveobj(P) -------------------------------------------------------------------------------- /extras/@optimizer/updatemodel.m: -------------------------------------------------------------------------------- 1 | function p = updatemodel(p,model) 2 | 3 | p.model = model; 4 | -------------------------------------------------------------------------------- /extras/@optimizer/vertcat.m: -------------------------------------------------------------------------------- 1 | function P = vertcat(varargin) 2 | 3 | P = horzcat(varargin{:}); -------------------------------------------------------------------------------- /extras/@optproblem/feasible.m: -------------------------------------------------------------------------------- 1 | function diagnostics = feasible(OptimizationProblem,Options) 2 | %FEASIBLE Computes feasible solution of in an optimization problem 3 | % 4 | % DIAGNOSTICS = FEASIBLE(P,Options) 5 | % 6 | % Example 7 | % 8 | % The following code creates an optimization problem, and then finds a 9 | % feasible solution 10 | % 11 | % x = sdpvar(1);P = optproblem(1 >= x >= 0, x^2);feasible(P) 12 | 13 | if nargin < 2 14 | diagnostics = solvesdp(OptimizationProblem.Constraints,[],OptimizationProblem.Options); 15 | else 16 | diagnostics = solvesdp(OptimizationProblem.Constraints,[],Options); 17 | end 18 | -------------------------------------------------------------------------------- /extras/@optproblem/horzcat.m: -------------------------------------------------------------------------------- 1 | function P = horzcat(varargin) 2 | %MINIMIZSE Adds constraint to optimization problem 3 | % 4 | % P = [P,Constraint] 5 | 6 | 7 | P = varargin{1}; 8 | for i = 2:nargin 9 | if isa(varargin{i},'optproblem') 10 | P.Constraints = [P.Constraints, varargin{i}.Constraints]; 11 | else 12 | P.Constraints = [P.Constraints, varargin{i}]; 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /extras/@optproblem/kkt.m: -------------------------------------------------------------------------------- 1 | function [KKTConstraints, details] = kkt(P,x,ops) 2 | %KKT Create KKT system for optimization system P with parametric variables x 3 | % 4 | % [KKTConstraints, details] = kkt(Constraints,Objective,parameters,options) 5 | 6 | if nargin < 2 7 | [KKTConstraints, details] = kkt(P.Constraints,P.Objective); 8 | elseif nargin < 3 9 | [KKTConstraints, details] = kkt(P.Constraints,P.Objective,x); 10 | else 11 | [KKTConstraints, details] = kkt(P.Constraints,P.Objective,x,ops); 12 | end 13 | -------------------------------------------------------------------------------- /extras/@optproblem/linearize.m: -------------------------------------------------------------------------------- 1 | function P = linearize(P) 2 | %LINEARIZE Linearize constraints and objective around current solution 3 | % 4 | % P = LINEARIZE(P) 5 | 6 | P.Objective = linearize(P.Objective); 7 | P.Constraints = linearize(P.Constraints); 8 | 9 | -------------------------------------------------------------------------------- /extras/@optproblem/maximize.m: -------------------------------------------------------------------------------- 1 | function diagnostics = maximize(OptimizationProblem,Options) 2 | %MINIMIZSE Maximize the objective in an optimization problem 3 | % 4 | % DIAGNOSTICS = MAXIMIZE(P) 5 | % 6 | % Example 7 | % 8 | % The following code creates an optimization problem, and then maximizes 9 | % the objective function 10 | % 11 | % x = sdpvar(1);P = optproblem(1 >= x >= 0, x);maximize(P) 12 | 13 | if nargin < 2 14 | diagnostics = solvesdp(OptimizationProblem.Constraints,-OptimizationProblem.Objective,OptimizationProblem.Options); 15 | else 16 | diagnostics = solvesdp(OptimizationProblem.Constraints,-OptimizationProblem.Objective,Options); 17 | end 18 | -------------------------------------------------------------------------------- /extras/@optproblem/minimize.m: -------------------------------------------------------------------------------- 1 | function diagnostics = minimize(OptimizationProblem,Options) 2 | %MINIMIZSE Minimize the objective in an optimization problem 3 | % 4 | % DIAGNOSTICS = MINIMIZE(P,Options) 5 | % 6 | % Example 7 | % 8 | % The following code creates an optimization problem, and then minimizes 9 | % the objective function 10 | % 11 | % x = sdpvar(1);P = optproblem(x >= 0, x^2);minimize(P) 12 | 13 | if nargin < 2 14 | diagnostics = solvesdp(OptimizationProblem.Constraints,OptimizationProblem.Objective,OptimizationProblem.Options); 15 | else 16 | diagnostics = solvesdp(OptimizationProblem.Constraints,OptimizationProblem.Objective,Options); 17 | end 18 | -------------------------------------------------------------------------------- /extras/@optproblem/optimize.m: -------------------------------------------------------------------------------- 1 | function diagnostics = optimize(OptimizationProblem,Options) 2 | %OPTIMIZE Minimize the objective in an optimization problem 3 | % 4 | % DIAGNOSTICS = OPTIMIZE(P) 5 | % 6 | % Example 7 | % 8 | % The following code creates an optimization problem, and then minimizes 9 | % the objective function 10 | % 11 | % x = sdpvar(1);P = optproblem(x >= 0, x^2);optimize(P) 12 | 13 | if nargin < 2 14 | diagnostics = solvesdp(OptimizationProblem.Constraints,OptimizationProblem.Objective,OptimizationProblem.Options); 15 | else 16 | diagnostics = solvesdp(OptimizationProblem.Constraints,OptimizationProblem.Objective,Options); 17 | end 18 | -------------------------------------------------------------------------------- /extras/@optproblem/robustify.m: -------------------------------------------------------------------------------- 1 | function P = robustify(P) 2 | %ROBUSTIFY Derives robust counterpart. 3 | 4 | [P.Constraints,P.Objective] = robustify(P.Constraints,P.Objective,P.Options); 5 | -------------------------------------------------------------------------------- /extras/@probability/display.m: -------------------------------------------------------------------------------- 1 | function sys = display(c) 2 | display('Probabilistic expression') -------------------------------------------------------------------------------- /extras/@probability/ge.m: -------------------------------------------------------------------------------- 1 | function ChanceConstraint = gt(P,level) 2 | if isa(P,'double') & isa(level,'probability') 3 | error('Currently only supports p(F) >= level') 4 | end 5 | if level < 0 | level > 1 6 | error('The confidence level must be between 0 and 1'); 7 | end 8 | ChanceConstraint = chanceconstraint(lmi(P.Constraint),level); 9 | 10 | -------------------------------------------------------------------------------- /extras/@probability/horzcat.m: -------------------------------------------------------------------------------- 1 | function ChanceConstraint = horzcat(varargin) 2 | 3 | if nargin == 2 4 | ChanceConstraint = varargin{1}; 5 | for i = 1:length(varargin{2}.P) 6 | ChanceConstraint.P{end+1} = varargin{2}.P{i}; 7 | ChanceConstraint.level{end+1} = varargin{2}.level{i}; 8 | end 9 | else 10 | ChanceConstraint = horzcat(varargin{1},horzcat(varargin{2:end})); 11 | end -------------------------------------------------------------------------------- /extras/@probability/le.m: -------------------------------------------------------------------------------- 1 | function ChanceConstraint = le(level,P) 2 | 3 | if isa(P,'double') & isa(level,'probability') 4 | error('Currently only supports level <= p(F)') 5 | temp = P; 6 | P = level; 7 | level = temp; 8 | end 9 | 10 | if level < 0 | level > 1 11 | error('The confidence level must be between 0 and 1'); 12 | end 13 | ChanceConstraint = chance(P.Constraint,level); 14 | 15 | -------------------------------------------------------------------------------- /extras/InstantiateElementWiseUnitary.m: -------------------------------------------------------------------------------- 1 | function y = InstantiateElementWiseUnitary(funName,varargin); 2 | 3 | args = varargin{1}; 4 | dims = size(args); 5 | y = yalmip('defineVectorizedUnitary',funName,varargin{:}); 6 | y = reshape(y,dims); 7 | -------------------------------------------------------------------------------- /extras/RecoverNonlinearSolverSolution.m: -------------------------------------------------------------------------------- 1 | function x = RecoverNonlinearSolverSolution(model,xout); 2 | 3 | if isempty(model.nonlinearindicies) 4 | x = xout(:); 5 | else 6 | x = zeros(length(model.c),1); 7 | for i = 1:length(model.linearindicies) 8 | x(model.linearindicies(i)) = xout(i); 9 | end 10 | x = x(1:length(model.c)); 11 | end 12 | -------------------------------------------------------------------------------- /extras/adjoint.m: -------------------------------------------------------------------------------- 1 | function A = adjoint(X) 2 | % ADJOINT Computes adjoint matrix 3 | % 4 | % A = ADJOINT(X) 5 | % 6 | % Brute-force implementation 7 | 8 | [n,m] = size(X); 9 | if n~=m 10 | error('Matrix must be square'); 11 | end 12 | 13 | A = []; 14 | if n == 1 15 | A = 1; 16 | return 17 | end 18 | 19 | % Ugly brute-force 20 | for i = 1:n 21 | temp = []; 22 | noti = setdiff(1:n,i); 23 | for j = 1:n 24 | notj = setdiff(1:n,j); 25 | temp = [temp det(X(noti,notj))*((-1)^(i+j))]; 26 | end 27 | A = [A;temp]; 28 | end 29 | A = A'; 30 | 31 | -------------------------------------------------------------------------------- /extras/allvariables.m: -------------------------------------------------------------------------------- 1 | function y = allvariables(varargin) 2 | % ALLVARIABLES Return a vector with all variables used in expressions 3 | % 4 | % y = allvariables(A,B,...) 5 | % 6 | % Returns variables used in the objects A, B, ... 7 | % 8 | % The arguments can be SDPVARs or constraints 9 | % 10 | % Example 11 | % 12 | % x = sdpvar(3,1);y = sdpvar(1); 13 | % Model = [-1 <= x <=1, y == sum(x)]; 14 | % Obj = sum(x) + y^2; 15 | % Obj2 = Obj + norm(allvariables(Model,Obj)) 16 | 17 | y = depends(varargin{:}); 18 | y = recover(y); -------------------------------------------------------------------------------- /extras/anyCones.m: -------------------------------------------------------------------------------- 1 | function y = anyCones(K) 2 | 3 | y = any(K.q) || any(K.e) || any(K.p) || any(K.s); -------------------------------------------------------------------------------- /extras/argmin.m: -------------------------------------------------------------------------------- 1 | function solution=argmin(x,Constraints,Objective,options); 2 | 3 | if isempty(x) 4 | x = recover(unique([depends(Constraints);depends(Objective)])); 5 | end 6 | if nargin < 4 7 | options = sdpsettings('verbose',0); 8 | end 9 | solvesdp(Constraints,Objective,options); 10 | solution = double(x); 11 | -------------------------------------------------------------------------------- /extras/assertProperty.m: -------------------------------------------------------------------------------- 1 | function properties = assertProperty(properties,checkfor,default) 2 | if ~isfield(properties,checkfor) 3 | properties = setfield(properties,checkfor,default); 4 | end -------------------------------------------------------------------------------- /extras/binary.m: -------------------------------------------------------------------------------- 1 | function x = binary(x) 2 | %BINARY Overloaded 3 | 4 | if isempty(x) 5 | x = []; 6 | else 7 | error('BINARY can only be applied to SDPVAR objects or empty doubles'); 8 | end -------------------------------------------------------------------------------- /extras/clean.m: -------------------------------------------------------------------------------- 1 | function Z=clean(Z,tol) 2 | %CLEAN Remove terms with small coefficients 3 | % 4 | % Z = clean(X,tol) removes all variables with a coefficient smaller than tol 5 | % 6 | % 7 | 8 | if nargin == 1 9 | tol = 0; 10 | end 11 | basis_real = real(Z); 12 | basis_imag = imag(Z); 13 | basis_real(abs(basis_real)= 1 6 | p.F_struc = varargin{1}; 7 | end 8 | if nargin >= 2 9 | p.K = varargin{2}; 10 | end 11 | -------------------------------------------------------------------------------- /extras/create_CHS.m: -------------------------------------------------------------------------------- 1 | function [H,S]=create_CHS(A,B,C,N,M); 2 | % CREATE_CHS Internal function to define matrices for MPC problem 3 | 4 | % How many states 5 | n=length(A);p=size(C,1); 6 | [dummy,m]=size(B); 7 | 8 | H=zeros(N*p,length(A)); 9 | S=zeros(N*p,N*m); 10 | 11 | Acum=A; 12 | for j=1:N, 13 | H(1+p*(j-1):p*j,:)=C*Acum; 14 | Acum=Acum*A; 15 | end; 16 | 17 | for j=1:N, 18 | Acum=eye(n); 19 | for k=j:-1:1, 20 | S(1+p*(j-1):p*j,1+m*(k-1):k*m)=C*Acum*B; 21 | Acum=Acum*A; 22 | end; 23 | end; 24 | -------------------------------------------------------------------------------- /extras/create_HS.m: -------------------------------------------------------------------------------- 1 | function [H,S]=create_HS(A,B,N,M); 2 | % CREATE_HS Internal function to define matrices for MPC problem 3 | 4 | % How many states 5 | n=length(A);C = eye(n);p=size(C,1); 6 | [dummy,m]=size(B); 7 | 8 | H=zeros(N*p,length(A)); 9 | S=zeros(N*p,N*m); 10 | 11 | Acum=A; 12 | for j=1:N, 13 | H(1+p*(j-1):p*j,:)=C*Acum; 14 | Acum=Acum*A; 15 | end; 16 | 17 | for j=1:N, 18 | Acum=eye(n); 19 | for k=j:-1:1, 20 | S(1+p*(j-1):p*j,1+m*(k-1):k*m)=C*Acum*B; 21 | Acum=Acum*A; 22 | end; 23 | end; 24 | -------------------------------------------------------------------------------- /extras/create_trivial_initial.m: -------------------------------------------------------------------------------- 1 | function x0 = create_trivial_initial(model) 2 | x0 = (model.lb+model.ub)/2; 3 | x0(isinf(model.ub)) = model.lb(isinf(model.ub))+1; 4 | x0(isinf(model.lb)) = model.ub(isinf(model.lb))-1; 5 | x0(isinf(x0)) = 0; 6 | if any(model.variabletype == 4) 7 | problematic = find(any(model.monomtable(:,model.linearindicies) < 0 ,1)); 8 | if ~isempty(problematic) 9 | problematic = problematic(find(x0(problematic)==0)); 10 | Oneisfeas = problematic(find(model.ub(problematic) > 1)); 11 | x0(Oneisfeas) = 1; 12 | end 13 | end 14 | x0(find(model.lb==model.ub)) = model.lb(find(model.lb==model.ub)); 15 | end -------------------------------------------------------------------------------- /extras/dd.m: -------------------------------------------------------------------------------- 1 | function Constraint = dd(X) 2 | 3 | if issymmetric(X) 4 | W = X-diag(diag(X)); 5 | Z = sdpvar(length(X)); 6 | Constraint = [-Z(:) <= W(:) <= Z(:), diag(X) >= sum(Z,2)]; 7 | else 8 | error('dd requires a symmetric argument.'); 9 | end -------------------------------------------------------------------------------- /extras/deadhub.m: -------------------------------------------------------------------------------- 1 | function f = deadhub(p,lambda) 2 | 3 | f = -(invsathub(p,lambda)-lambda*abs(p)); 4 | 5 | 6 | -------------------------------------------------------------------------------- /extras/dec2decbin.m: -------------------------------------------------------------------------------- 1 | function s=dec2decbin(d,n) 2 | %DEC2BIN Internal function generate binary matrices 3 | 4 | [f,e]=log2(max(d)); % How many digits do we need to represent the numbers? 5 | s=rem(floor(d(:)*pow2(1-max(n,e):0)),2); 6 | -------------------------------------------------------------------------------- /extras/definecreationtime.m: -------------------------------------------------------------------------------- 1 | function t = definecreationtime 2 | 3 | t = now; 4 | -------------------------------------------------------------------------------- /extras/depends.m: -------------------------------------------------------------------------------- 1 | function p = depends(x) 2 | %DEPENDS Returns indicies to variables used in an SDPVAR object 3 | % 4 | % i = depends(x) 5 | % 6 | % Input 7 | % x : SDPVAR object 8 | % Output 9 | % i : DOUBLE 10 | 11 | p=[]; 12 | -------------------------------------------------------------------------------- /extras/det_internal.m: -------------------------------------------------------------------------------- 1 | function varargout = det_internal(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'double' 6 | X = varargin{1}; 7 | X = reshape(X,sqrt(length(X)),[]); 8 | varargout{1} = det(X); 9 | 10 | case 'char' % YALMIP send 'model' when it wants the epigraph or hypograph 11 | 12 | operator = CreateBasicOperator('callback'); 13 | 14 | varargout{1} = []; 15 | varargout{2} = operator; 16 | varargout{3} = varargin{3}; 17 | 18 | otherwise 19 | error([upper(mfilename) ' called with weird argument']); 20 | end 21 | -------------------------------------------------------------------------------- /extras/detn.m: -------------------------------------------------------------------------------- 1 | function d = detn(X) 2 | %DETN Internal function used in construction of MAXDET formulations 3 | 4 | [n,m]=size(X); 5 | 6 | if n~=m 7 | error 8 | else 9 | if n==2 10 | d = X(1,1)*X(2,2)-X(1,2)*X(2,1); 11 | else 12 | d = 0; 13 | for i = 1:n 14 | d = d + (-1)^(i+1)*X(i,1)*detn(X([1:1:i-1 i+1:1:n],2:end)); 15 | end 16 | end 17 | end -------------------------------------------------------------------------------- /extras/double2sdpvar.m: -------------------------------------------------------------------------------- 1 | function sys = double2sdpvar(varargin) 2 | sys = sdpvar(1); 3 | sys = struct(sys); 4 | sys.dim = size(varargin{1}); 5 | sys.lmi_variables = []; 6 | sys.basis = varargin{1}(:); 7 | sys = sdpvar(sys); 8 | -------------------------------------------------------------------------------- /extras/eigv.m: -------------------------------------------------------------------------------- 1 | function [v,Model] = eigv(X) 2 | % v(i) epigraph of i-th largest eigenvalue of X 3 | [n,m] = size(X); 4 | v = sdpvar(n,1); 5 | Model = [trace(X)==sum(v), v(1:end-1) >= v(2:end)]; 6 | for k = 1:n-1 7 | Z = sdpvar(n); 8 | s = sdpvar(1); 9 | t = sum(v(1:k)); 10 | Model = [Model, (t-k*s-trace(Z) >= 0) + (Z >= 0) + (Z-X+s*eye(n) >= 0)]; 11 | end -------------------------------------------------------------------------------- /extras/ellipplot.m: -------------------------------------------------------------------------------- 1 | function [xe,ye]=ellipplot(P,gamma,ecolor,xc) 2 | %ELLIPPLOT Internal function for plotting ellipsoid 3 | 4 | if nargin<4 5 | xc = zeros(length(P),1); 6 | end 7 | 8 | if nargin<3 9 | ecolor = [1 0 0]; 10 | end 11 | 12 | if nargin<2 13 | gamma = 1; 14 | end 15 | 16 | P=P/gamma; 17 | P=chol(P); 18 | 19 | theta = linspace(-pi,pi,1000); 20 | z = [cos(theta); sin(theta)]; 21 | 22 | x = inv(P)*z; 23 | for n=1:length(x) 24 | x(:,n)=x(:,n)+xc; 25 | end; 26 | 27 | fill(x(1,:),x(2,:),ecolor) -------------------------------------------------------------------------------- /extras/emptyNumericalModel.m: -------------------------------------------------------------------------------- 1 | function p = emptyNumericalModel 2 | p.F_struc = []; 3 | p.K.f = 0; 4 | p.K.l = 0; 5 | p.K.q = []; 6 | p.K.p = []; 7 | p.K.e = 0; 8 | p.K.s = 0; -------------------------------------------------------------------------------- /extras/endOfLPCone.m: -------------------------------------------------------------------------------- 1 | function top = endOfLPCone(K) 2 | 3 | top = K.f+K.l; -------------------------------------------------------------------------------- /extras/even.m: -------------------------------------------------------------------------------- 1 | function YESNO = even(x,order,d) 2 | %EVEN Check if all numbers are even 3 | 4 | if (nargin==2) | (nargin==3) 5 | switch order 6 | case 'rows' 7 | YESNO = ~any(rem(x,d),2); 8 | case 'cols' 9 | YESNO = ~any(rem(x,d),1); 10 | otherwise 11 | error 12 | end 13 | else 14 | YESNO = nnz(rem(x,2))==0; 15 | end 16 | 17 | -------------------------------------------------------------------------------- /extras/expanded.m: -------------------------------------------------------------------------------- 1 | function X = expanded(F,state) 2 | 3 | if nargin == 1 4 | X = 1; 5 | else 6 | X = []; 7 | end -------------------------------------------------------------------------------- /extras/extractConstraints.m: -------------------------------------------------------------------------------- 1 | function F = extractConstraints(F,type) 2 | 3 | if ~isempty(F) 4 | if isa(type,'cell') 5 | answer = is(F,type{1}); 6 | for i = 2:length(type) 7 | answer = answer | is(F,type{i}); 8 | end 9 | F = F(find(answer)); 10 | else 11 | F = F(find(is(F,type))); 12 | end 13 | end -------------------------------------------------------------------------------- /extras/extractSemiContBounds.m: -------------------------------------------------------------------------------- 1 | function [F_struc,K,lb,ub,semicont_variables] = extractSemiContBounds(F_struc,K,lb,ub,semicont_variables); 2 | if ~isempty(semicont_variables) 3 | % Bounds must be placed in LB/UB 4 | [lb,ub,cand_rows_eq,cand_rows_lp] = find_lp_bounds(F_struc,K,lb,ub); 5 | F_struc(K.f+cand_rows_lp,:)=[]; 6 | F_struc(cand_rows_eq,:)=[]; 7 | K.l = K.l-length(cand_rows_lp); 8 | K.f = K.f-length(cand_rows_eq); 9 | redundant = find(lb<=0 & ub>=0); 10 | semicont_variables = setdiff(semicont_variables,redundant); 11 | end -------------------------------------------------------------------------------- /extras/extract_bounds_from_max_operator.m: -------------------------------------------------------------------------------- 1 | function LU = extract_bounds_from_max_operator(LU,extstruct,extvariables,i); 2 | arg = extstruct(i).arg{1}; 3 | epi = getvariables(extstruct(i).var); 4 | [M,m] = derivebounds(arg,LU); 5 | LU(epi,1) = max(m); 6 | LU(epi,2) = max(M); 7 | 8 | -------------------------------------------------------------------------------- /extras/extract_bounds_from_milpsubsref_operator.m: -------------------------------------------------------------------------------- 1 | function LU = extract_bounds_from_milpsubsref_operator(LU,extstruct,extvariables,i) 2 | arg = extstruct(i).arg{1}; 3 | epi = getvariables(extstruct(i).var); 4 | [M,m] = derivebounds(reshape(arg,[],1),LU); 5 | LU(epi,1) = min(m); 6 | LU(epi,2) = max(M); 7 | for j = 1:length(extstruct(i).arg{2}.subs) 8 | index = extstruct(i).arg{2}.subs{j}; 9 | if isa(index,'sdpvar') 10 | if isequal(getbase(index),[0 1]) 11 | LU(getvariables(index),1) = max(LU(getvariables(index),1),1); 12 | LU(getvariables(index),2) = min(LU(getvariables(index),2),numel(arg)); 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /extras/extract_bounds_from_min_operator.m: -------------------------------------------------------------------------------- 1 | function LU = extract_bounds_from_min_operator(LU,extstruct,extvariables,i); 2 | arg = extstruct(i).arg{1}; 3 | epi = getvariables(extstruct(i).var); 4 | [M,m] = derivebounds(arg,LU); 5 | LU(epi,1) = min(m); 6 | LU(epi,2) = min(M); 7 | -------------------------------------------------------------------------------- /extras/extract_bounds_from_norm_operator.m: -------------------------------------------------------------------------------- 1 | function LU = extract_bounds_from_norm_operator(LU,extstruct,extvariables,i); 2 | arg = extstruct(i).arg{1}; 3 | if min(size(arg))==1 & length(extstruct(i).arg)>1 4 | p = extstruct(i).arg{2}; 5 | % Maximize each element conservatively, and use the norm of 6 | % that worst-case vector 7 | U = max(abs(LU(getvariables(arg),:)),[],2); 8 | if ~all(isinf(U)) 9 | xmax = abs(getbase(arg))*[1;U]; 10 | LU(extvariables(i),2) = min([norm(xmax,p) LU(extvariables(i),2)]); 11 | end 12 | end 13 | % norms are positive... 14 | LU(extvariables(i),1) = max([0 LU(extvariables(i),1)]); 15 | 16 | -------------------------------------------------------------------------------- /extras/extsubsref.m: -------------------------------------------------------------------------------- 1 | function z=extsubsref(x,i,j); 2 | 3 | if nargin < 3 4 | z = x(i); 5 | else 6 | z=x(i,j); 7 | end 8 | -------------------------------------------------------------------------------- /extras/eyev.m: -------------------------------------------------------------------------------- 1 | function ei=eyev(n,i) 2 | %EYEV Internal function to generate unit vector 3 | 4 | if i>n 5 | disp('Error in eyev') 6 | return 7 | else 8 | ei = zeros(n,1);ei(i)=1; 9 | end; 10 | 11 | -------------------------------------------------------------------------------- /extras/findhash.m: -------------------------------------------------------------------------------- 1 | function pos = findhash(T,t,dummy) 2 | 3 | if isempty(T) 4 | pos = []; % Random warnings on 6.1 5 | else 6 | pos = find(T==t); 7 | end 8 | -------------------------------------------------------------------------------- /extras/fiordos_call.m: -------------------------------------------------------------------------------- 1 | function x = fiordos_call(solver,param,B0,b0,mask,map,dimout) 2 | 3 | mparams.be = b0 + B0*param(mask); 4 | mres = solver(mparams); 5 | allx = [nan;mres.x];% map=0 corresponds to stuff that really weren't in the model 6 | x = reshape(allx(1+map),dimout); 7 | 8 | -------------------------------------------------------------------------------- /extras/fmincon_fungp.m: -------------------------------------------------------------------------------- 1 | function [f,df] = fmincon_fungp(x,prob) 2 | 3 | z = prob.Afun*x; 4 | w = exp(z); 5 | f = full(log(prob.bfun'*w)); 6 | df = full(((1/(sum(prob.bfun.*w)))*(prob.bfun.*w)'*prob.Afun)); -------------------------------------------------------------------------------- /extras/gammainc_a.m: -------------------------------------------------------------------------------- 1 | function varargout = gammainc_a(varargin) 2 | %GAMMAINC_A 3 | 4 | switch class(varargin{1}) 5 | 6 | case 'double' 7 | varargout{1} = gammainc(varargin{2},varargin{1}); 8 | 9 | case 'char' 10 | 11 | operator = CreateBasicOperator('decreasing','positive','callback'); 12 | operator.range = [0 1]; 13 | operator.domain = [0 inf]; 14 | 15 | varargout{1} = []; 16 | varargout{2} = operator; 17 | varargout{3} = varargin{3}; 18 | 19 | otherwise 20 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 21 | end 22 | -------------------------------------------------------------------------------- /extras/gammainc_x.m: -------------------------------------------------------------------------------- 1 | function varargout = gammainc_x(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'double' 6 | varargout{1} = gammainc(varargin{1},varargin{2}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('increasing','positive','callback'); 11 | operator.range = [0 1]; 12 | operator.domain = [0 inf]; 13 | 14 | varargout{1} = []; 15 | varargout{2} = operator; 16 | varargout{3} = varargin{3}; 17 | 18 | otherwise 19 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 20 | end 21 | -------------------------------------------------------------------------------- /extras/gammaincinv_a.m: -------------------------------------------------------------------------------- 1 | function varargout = gammaincinv_a(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'double' 6 | varargout{1} = gammaincinv(varargin{2},varargin{1}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('increasing','positive','callback'); 11 | operator.range = [0 inf]; 12 | operator.domain = [0 inf]; 13 | 14 | varargout{1} = []; 15 | varargout{2} = operator; 16 | varargout{3} = varargin{3}; 17 | 18 | otherwise 19 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 20 | end 21 | -------------------------------------------------------------------------------- /extras/gammaincinv_x.m: -------------------------------------------------------------------------------- 1 | function varargout = gammaincinv_x(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'double' 6 | varargout{1} = gammaincinv(varargin{1},varargin{2}); 7 | 8 | case 'char' 9 | 10 | operator = CreateBasicOperator('increasing','positive','callback'); 11 | operator.range = [0 inf]; 12 | operator.domain = [0 1]; 13 | 14 | varargout{1} = []; 15 | varargout{2} = operator; 16 | varargout{3} = varargin{3}; 17 | 18 | otherwise 19 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 20 | end 21 | -------------------------------------------------------------------------------- /extras/gcdfactor.m: -------------------------------------------------------------------------------- 1 | function d = gcdfactor(A) 2 | d = A(1); 3 | if d~=round(d) 4 | d = 1;return 5 | end 6 | for n = 2:numel(A) 7 | if d == 1 8 | return 9 | elseif A(n)~=round(A(n)) 10 | d = 1; 11 | return 12 | else 13 | d = gcd(d,A(n)); 14 | end 15 | end -------------------------------------------------------------------------------- /extras/getbase.m: -------------------------------------------------------------------------------- 1 | function y = getbase(x) 2 | %GETBASE (overloaded sdpvar/getbase on double) 3 | 4 | y = x(:); -------------------------------------------------------------------------------- /extras/getbasematrix.m: -------------------------------------------------------------------------------- 1 | function y = getbasematrix(x,ind) 2 | %GETBASEMATRIX (overloaded sdpvar/getbasematrix on double) 3 | 4 | if ind == 0 5 | y = x; 6 | else 7 | y = spalloc(size(x,1),size(x,2),0); 8 | end 9 | -------------------------------------------------------------------------------- /extras/getexponentbase.m: -------------------------------------------------------------------------------- 1 | function [exponents,base]=getexponentbase(p,x) 2 | %GETEXPONENTBASE Internal function used in SOS programs 3 | 4 | if isempty(p) 5 | exponents=[]; 6 | base=[]; 7 | else 8 | p_vars = getvariables(p); 9 | x_vars = getvariables(x); 10 | 11 | base = getbase(p); 12 | 13 | monom_table = yalmip('monomtable'); 14 | exponents = monom_table(p_vars,x_vars); 15 | if any(base(:,1))%base(1)~=0 16 | exponents = [spalloc(1,size(exponents,2),0);exponents]; 17 | else 18 | base = base(:,2:end); 19 | end 20 | end -------------------------------------------------------------------------------- /extras/getvariables.m: -------------------------------------------------------------------------------- 1 | function vars = getvariables(X,var) 2 | %GETVARIABLES (overloads sdpvar/getvariables on double) 3 | 4 | vars = []; 5 | -------------------------------------------------------------------------------- /extras/gmset.m: -------------------------------------------------------------------------------- 1 | function F = gmset(t,x1,x2) 2 | %GMSET Internal function used for MAXDET formulation 3 | 4 | F = (cone([t;(x1-x2)/2],(x1+x2)/2)); -------------------------------------------------------------------------------- /extras/integer.m: -------------------------------------------------------------------------------- 1 | function x = integer(x) 2 | %INTEGER Overloaded 3 | 4 | if isempty(x) 5 | x = []; 6 | else 7 | error('INTEGER can only be applied to SDPVAR objects or empty doubles'); 8 | end -------------------------------------------------------------------------------- /extras/invsathub.m: -------------------------------------------------------------------------------- 1 | function f = invsathub(p,lambda) 2 | 3 | absp = abs(p); 4 | f = lambda*absp; 5 | case2=find(absp>lambda); 6 | f(case2) = -0.25*(p(case2).^2-6*lambda*absp(case2)+lambda^2); 7 | case3=find(absp>3*lambda); 8 | f(case3) = 2*lambda^2; 9 | 10 | -------------------------------------------------------------------------------- /extras/ipopt_callback_df.m: -------------------------------------------------------------------------------- 1 | function df = ipopt_callback_df(x,model) 2 | 3 | global latest_x_f 4 | global latest_df 5 | 6 | x = x(:); 7 | if isequal(x,latest_x_f) 8 | df = latest_df; 9 | else 10 | [f,df] = fmincon_fun_liftlayer(x,model); 11 | end -------------------------------------------------------------------------------- /extras/ipopt_callback_f.m: -------------------------------------------------------------------------------- 1 | function f = ipopt_callback_f(x,model) 2 | 3 | global latest_x_f 4 | global latest_df 5 | 6 | x = x(:); 7 | [f,latest_df] = fmincon_fun_liftlayer(x,model); 8 | latest_x_f = x; -------------------------------------------------------------------------------- /extras/ipoptgp_callback_df.m: -------------------------------------------------------------------------------- 1 | function df = ipoptgp_callback_df(x,model) 2 | 3 | global latest_x_f 4 | global latest_df 5 | 6 | x = x(:); 7 | if isequal(x,latest_x_f) 8 | df = latest_df; 9 | else 10 | [f,df] = fmincon_fungp(x,model); 11 | latest_df = df; 12 | end 13 | 14 | 15 | -------------------------------------------------------------------------------- /extras/ipoptgp_callback_dg.m: -------------------------------------------------------------------------------- 1 | function G = ipoptgp_callback_dg(x,prob) 2 | 3 | % Compute the nonlinear terms in the constraints 4 | [g,geq,dg,dgeq] = fmincon_congp(x,prob); 5 | G = [dg';dgeq']; 6 | G = sparse(G); 7 | -------------------------------------------------------------------------------- /extras/ipoptgp_callback_f.m: -------------------------------------------------------------------------------- 1 | function f = ipoptgp_callback_f(x,prob) 2 | 3 | global latest_x_f 4 | global latest_df 5 | 6 | x = x(:); 7 | [f,latest_df] = fmincon_fungp(x,prob); 8 | latest_x_f = x; -------------------------------------------------------------------------------- /extras/ipoptgp_callback_g.m: -------------------------------------------------------------------------------- 1 | function g = ipoptgp_callback_g(x,model) 2 | 3 | % Should be made faster by re-using results from dg computation... 4 | 5 | % Compute the nonlinear terms in the constraints 6 | [g,geq] = fmincon_congp(x,model); 7 | 8 | % Append with linear constraints 9 | g = [g;geq]; -------------------------------------------------------------------------------- /extras/isessentiallyhermitian.m: -------------------------------------------------------------------------------- 1 | function isherm=isessentiallyhermitian(X) 2 | %ISHERMITIAN Check if variable is essentially Hermitian 3 | 4 | [n,m] = size(X); 5 | issym = 0; 6 | 7 | if (n==m) 8 | isherm = norm(X-X',1)<1e-10; % Should be scaled with size maybe 9 | end 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /extras/isessentiallysymmetric.m: -------------------------------------------------------------------------------- 1 | function issym=isessentiallysymmetric(X) 2 | %ISESSENTIALLYSYMMETRIC Check if variable is essentially symmetric 3 | 4 | % Weird name to account for MATLAB2014 and later where issymmetric exist 5 | 6 | [n,m] = size(X); 7 | issym = 0; 8 | 9 | if (n==m) 10 | issym = norm(X-X.',1)<1e-10; % Should be scaled with size maybe 11 | end 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /extras/isinterval.m: -------------------------------------------------------------------------------- 1 | function res = isinterval(Y) 2 | %ISINTERVAL (overloaded) 3 | 4 | res = isa(Y,'intval'); 5 | -------------------------------------------------------------------------------- /extras/islinear.m: -------------------------------------------------------------------------------- 1 | function p = islinear(x) 2 | p = (1==1); 3 | -------------------------------------------------------------------------------- /extras/ismembcYALMIP.m: -------------------------------------------------------------------------------- 1 | function members=ismembcYALMIP(a,b) 2 | 3 | % ismembc is fast, but does not exist in octave 4 | % however, try-catch is very slow in Octave, 5 | % Octave user: Just replace the whole code here 6 | % with "members = ismember(a,b);" 7 | try 8 | members = ismembc(a,b); 9 | catch 10 | members = ismember(a,b); 11 | end 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /extras/isoutside_internal.m: -------------------------------------------------------------------------------- 1 | function Model = isoutside_internal(P) 2 | %ISOUSIDE_INTERNAL Helper for ISOUTSIDE 3 | 4 | % Get representation A*x <= b 5 | B = getbase(sdpvar(P)); 6 | b = B(:,1); 7 | A = -B(:,2:end); 8 | x = recover(P); 9 | 10 | % Derive big-M for some Ai*x-bi >= 0 11 | d = binvar(length(b),1); 12 | violation = A*x-b; 13 | [M,m] = derivebounds(violation); 14 | Model = [sum(d)==1, violation >= m.*(1-d)]; 15 | -------------------------------------------------------------------------------- /extras/knitro_callback_f.m: -------------------------------------------------------------------------------- 1 | function [f,df] = knitro_callback_f(x,model) 2 | 3 | global latest_x_f 4 | global latest_df 5 | global latest_f 6 | 7 | x = x(:); 8 | if isequal(x,latest_x_f) 9 | df = latest_df; 10 | f = latest_f; 11 | else 12 | [f,df] = fmincon_fun_liftlayer(x,model); 13 | latest_x_f = x; 14 | latest_f = f; 15 | latest_df = df; 16 | end -------------------------------------------------------------------------------- /extras/knitro_callback_g.m: -------------------------------------------------------------------------------- 1 | function [g,geq,dg,dgeq] = knitro_callback_g(x,model) 2 | 3 | global latest_x_g 4 | global latest_dg 5 | global latest_g 6 | global latest_geq 7 | global latest_dgeq 8 | 9 | x = x(:); 10 | if exist('latest_x_g') && isequal(x,latest_x_g) 11 | % Jacobian was computed earlier 12 | g = latest_g; 13 | dg = latest_dg; 14 | geq = latest_geq; 15 | dgeq = latest_dgeq; 16 | else 17 | % Compute the nonlinear terms in the constraints 18 | [g,geq,dg,dgeq,xevaled] = fmincon_con(x,model); 19 | latest_x_g = x; 20 | latest_g = g; 21 | latest_dg = dg; 22 | latest_geq = geq; 23 | latest_dgeq = dgeq; 24 | end -------------------------------------------------------------------------------- /extras/lifted.m: -------------------------------------------------------------------------------- 1 | function X = lifted(F,state) 2 | 3 | if nargin == 1 4 | X = 1; 5 | else 6 | X = []; 7 | end -------------------------------------------------------------------------------- /extras/lmiBasis.m: -------------------------------------------------------------------------------- 1 | function basis = lmiBasis(n) 2 | Y = reshape(1:n^2,n,n); 3 | Y = tril(Y); 4 | Y = (Y+Y')-diag(sparse(diag(Y))); 5 | [uu,oo,pp] = unique(Y(:)); 6 | basis = sparse(1:n^2,pp+1,1); -------------------------------------------------------------------------------- /extras/map_to_original.m: -------------------------------------------------------------------------------- 1 | function dfdx_sort = map_to_original(dfdx,x, x_indep); 2 | 3 | for i = 1:length(x(:)) 4 | x_origvar(i) = getvariables(x(i)); 5 | end 6 | x_var = getvariables(x_indep); 7 | dfdx_sort = []; 8 | for i = 1:length(x_origvar) 9 | dfdx_sort = [dfdx_sort dfdx(:,find(x_origvar(i) == x_var))]; 10 | end -------------------------------------------------------------------------------- /extras/mid.m: -------------------------------------------------------------------------------- 1 | function m=mid(m) 2 | m = m; -------------------------------------------------------------------------------- /extras/milpalreadydone.m: -------------------------------------------------------------------------------- 1 | function done = milpalreadydone(i) 2 | global ALREADY_MODELLED REMOVE_THESE_IN_THE_END 3 | done = 0; 4 | if length(ALREADY_MODELLED) >= i 5 | if ~isempty(ALREADY_MODELLED{i}) 6 | if isequal(ALREADY_MODELLED{i}.method,'milp') 7 | done = 1; 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /extras/minimize.m: -------------------------------------------------------------------------------- 1 | function minimize(varargin) 2 | disp('Functin not implemented') -------------------------------------------------------------------------------- /extras/mytestNEW.m: -------------------------------------------------------------------------------- 1 | function y = mytestNEW(B,X) 2 | 3 | y = B - X*X; -------------------------------------------------------------------------------- /extras/mytestOLD.m: -------------------------------------------------------------------------------- 1 | function y = mytestOLD(X,B) 2 | 3 | y = B - X*X; -------------------------------------------------------------------------------- /extras/newvariabletypegen.m: -------------------------------------------------------------------------------- 1 | function newvariabletype = newvariabletypegen(newmt) 2 | newvariabletype = spalloc(size(newmt,1),1,0)'; 3 | nonlinear = ~(sum(newmt,2)==1 & sum(newmt~=0,2)==1); 4 | if ~isempty(nonlinear) 5 | newvariabletype(nonlinear) = 3; 6 | quadratic = sum(newmt,2)==2; 7 | newvariabletype(quadratic) = 2; 8 | bilinear = max(newmt,[],2)<=1; 9 | newvariabletype(bilinear & quadratic) = 1; 10 | sigmonial = any(0>newmt,2) | any(newmt-fix(newmt),2); 11 | newvariabletype(sigmonial) = 4; 12 | end -------------------------------------------------------------------------------- /extras/penlab_callback_con.m: -------------------------------------------------------------------------------- 1 | function [G,model] = penlab_callback_con(x,model) 2 | 3 | global latest_x_g 4 | global latest_G 5 | global latest_g 6 | x = x(:); 7 | 8 | G = [model.Aeq;model.A]*x; 9 | -------------------------------------------------------------------------------- /extras/penlab_callback_dcon.m: -------------------------------------------------------------------------------- 1 | function [G,model] = penlab_callback_dcon(x,model) 2 | 3 | global latest_x_g 4 | global latest_G 5 | global latest_g 6 | x = x(:); 7 | 8 | G = [model.Aeq;model.A]; 9 | -------------------------------------------------------------------------------- /extras/penlab_callback_dcon2.m: -------------------------------------------------------------------------------- 1 | function [G,model] = penlab_callback_dcon2(x,k,model) 2 | 3 | global latest_x_g 4 | global latest_G 5 | global latest_g 6 | x = x(:); 7 | 8 | G = spalloc(length(model.c),length(model.c),0); 9 | -------------------------------------------------------------------------------- /extras/penlab_callback_df.m: -------------------------------------------------------------------------------- 1 | function [df,model] = penlab_callback_df(x,model) 2 | 3 | global latest_x_f 4 | global latest_df 5 | 6 | x = x(:); 7 | if isequal(x,latest_x_f) 8 | df = latest_df; 9 | else 10 | [f,df] = fmincon_fun(x,model); 11 | end 12 | df = df(:); -------------------------------------------------------------------------------- /extras/penlab_callback_df2.m: -------------------------------------------------------------------------------- 1 | function [H,model] = penlab_callback_df2(x,model) 2 | 3 | global latest_x_f 4 | global latest_df 5 | 6 | H = speye(2); -------------------------------------------------------------------------------- /extras/penlab_callback_dff.m: -------------------------------------------------------------------------------- 1 | function H = penlab_callback_dff(x,model) 2 | 3 | global latest_x_f 4 | global latest_df 5 | 6 | x = x(:); 7 | if isequal(x,latest_x_f) 8 | df = latest_df; 9 | else 10 | [f,df] = fmincon_fun(x,model); 11 | end -------------------------------------------------------------------------------- /extras/penlab_callback_f.m: -------------------------------------------------------------------------------- 1 | function [f,model] = penlab_callback_f(x,model) 2 | 3 | global latest_x_f 4 | global latest_df 5 | 6 | x = x(:); 7 | [f,latest_df] = fmincon_fun(x,model); 8 | latest_x_f = x; -------------------------------------------------------------------------------- /extras/penlab_callback_matrixG.m: -------------------------------------------------------------------------------- 1 | function [G,model] = penlab_callback_matrixG(x,k,model) 2 | 3 | global latest_xevaled 4 | global latest_x_xevaled 5 | x = x(:); 6 | 7 | if isequal(x,latest_x_xevaled) 8 | xevaled = latest_xevaled; 9 | else 10 | xevaled = zeros(1,length(model.c)); 11 | xevaled(model.linearindicies) = x; 12 | xevaled = apply_recursive_evaluation(model,xevaled); 13 | latest_x_xevaled = x; 14 | latest_xevaled = xevaled; 15 | end 16 | 17 | vecG = model.vecF{k}*[1;xevaled]; 18 | G = reshape(vecG,model.K.s(k),model.K.s(k)); 19 | -------------------------------------------------------------------------------- /extras/penlab_callback_matrixdG.m: -------------------------------------------------------------------------------- 1 | function [dG,model] = penlab_callback_matrixdG(x,k,i,model) 2 | 3 | global latest_x_g 4 | global latest_G 5 | global latest_g 6 | x = x(:); 7 | 8 | vecG = model.vecF{k}(:,i+1); 9 | dG = reshape(vecG,model.K.s(k),model.K.s(k)); 10 | -------------------------------------------------------------------------------- /extras/pennlp_con.m: -------------------------------------------------------------------------------- 1 | function g = pennlp_con(i,x) 2 | 3 | g = datasaver(4,x,i); 4 | 5 | 6 | -------------------------------------------------------------------------------- /extras/pennlp_congrad.m: -------------------------------------------------------------------------------- 1 | function [nnz,ind, val] = pennlp_congrad(i,x) 2 | 3 | 4 | try 5 | f = datasaver(5,x,i+1); 6 | [ind,dummy,val] = find(f(:)); 7 | nnz = length(ind); 8 | catch 9 | 10 | end 11 | 12 | %[nnz,ind, val] = dg(i,x); 13 | 14 | -------------------------------------------------------------------------------- /extras/pennlp_conhess.m: -------------------------------------------------------------------------------- 1 | function [nnz, row, col, val] = pennlp_conhess(i,x) 2 | 3 | try 4 | H = datasaver(6,x,i+1); 5 | H = reshape(H,sqrt(length(H)),sqrt(length(H))); 6 | [row,col,val] = find(tril(H)); 7 | nnz = length(val); 8 | row = row'; 9 | col = col'; 10 | val = val'; 11 | catch 12 | end 13 | 14 | %[nnz, row, col, val] = hg(i,x); 15 | 16 | -------------------------------------------------------------------------------- /extras/pennlp_fun.m: -------------------------------------------------------------------------------- 1 | function f = pennlp_fun(x) 2 | 3 | f = datasaver(1,x); -------------------------------------------------------------------------------- /extras/pennlp_fungrad.m: -------------------------------------------------------------------------------- 1 | function [nnz,ind,val] = pennlp_fungrad(x) 2 | 3 | 4 | f = datasaver(2,x); 5 | [ind,dummy,val] = find(f(:)); 6 | nnz = length(ind); -------------------------------------------------------------------------------- /extras/pennlp_funhess.m: -------------------------------------------------------------------------------- 1 | function [nnz,row, col, val] = pennlp_funhess(x) 2 | 3 | 4 | H = datasaver(3,x); 5 | H = reshape(H,sqrt(length(H)),sqrt(length(H))); 6 | [row,col,val] = find(tril(H)); 7 | nnz = length(val); 8 | row = row'; 9 | col = col'; 10 | val = val'; -------------------------------------------------------------------------------- /extras/pennonm_callback_df.m: -------------------------------------------------------------------------------- 1 | function [nnz,ind,val] = pennonm_callback_df(x,model_in) 2 | 3 | global latest_x 4 | global latest_df 5 | 6 | persistent model 7 | if nargin>1 8 | model = model_in; 9 | return 10 | end 11 | 12 | x = x(:); 13 | if isequal(x,latest_x) 14 | df = latest_df; 15 | else 16 | [f,df] = fmincon_fun(x,model); 17 | end 18 | 19 | nnz = length(df); 20 | ind = 1:length(df); 21 | val = full(df); 22 | -------------------------------------------------------------------------------- /extras/pennonm_callback_f.m: -------------------------------------------------------------------------------- 1 | function f = pennonm_callback_f(x,model_in) 2 | 3 | global latest_x 4 | global latest_df 5 | 6 | persistent model 7 | if nargin>1 8 | model = model_in; 9 | return 10 | end 11 | 12 | % We compute both function value and gradient. If pennon calls later to get 13 | % gradient, we have saved in a global variable (yea, I know, globals suck) 14 | x = x(:); 15 | [f,latest_df] = fmincon_fun(x,model); 16 | latest_x = x; 17 | -------------------------------------------------------------------------------- /extras/plottruss.m: -------------------------------------------------------------------------------- 1 | function plottruss(where,text,p,x) 2 | try 3 | subplot(2,2,where) 4 | title(text) 5 | cla; 6 | pic(p.options.truss,x(union(p.integer_variables,p.binary_variables))); 7 | drawnow 8 | catch 9 | end -------------------------------------------------------------------------------- /extras/portfoliodata.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yalmip/YALMIP/c9fa6d8f641908454ea7b9b2baa6db8ba78d0cd0/extras/portfoliodata.mat -------------------------------------------------------------------------------- /extras/portfoliodata.txt: -------------------------------------------------------------------------------- 1 | Data from EuroStoxx50 2 | 3 | Weekly returns (r) and covariance (R) for N=48 stocks during 264 weeks from March 2003 to March 2008. An artificial risk-free asset r0 is also included. 4 | 5 | Data suppplied by 6 | Fabio Tardella 7 | Professor of Operations Research 8 | University of Rome "La Sapienza" 9 | http://w3.uniroma1.it/Tardella/datasets.html -------------------------------------------------------------------------------- /extras/prunecplexoptions.m: -------------------------------------------------------------------------------- 1 | function options = prunecplexoptions(options) 2 | 3 | try 4 | if strfind(version,'2016') 5 | o1 = cplexoptimset; 6 | else 7 | o1 = cplexoptimset('cplex'); 8 | end 9 | o2 = options.cplex; 10 | n = fieldnames(o1); 11 | for i = 1:length(n) 12 | if isequal(o1.(n{i}),o2.(n{i})) 13 | options.cplex = rmfield(options.cplex,n{i}); 14 | end 15 | end 16 | catch 17 | end -------------------------------------------------------------------------------- /extras/pwasos2.m: -------------------------------------------------------------------------------- 1 | function [y,F] = pwasos2(fi,xi,x) 2 | 3 | fi = fi(:); 4 | xi = xi(:); 5 | 6 | n = length(fi)-1; 7 | lambda = sdpvar(n+1,1); 8 | reg = binvar(n,1); 9 | 10 | F = [sum(lambda)==1,lambda>0,sum(reg)==1]; 11 | 12 | F = [F,lambda(0+1) <= reg(1)]; 13 | for l =1:n-1 14 | F = [F,lambda(l+1)-reg(l)-reg(l+1) < 0]; 15 | end 16 | F = [F,lambda(end)0 5 | fprintf('+ %s\n',thetext); 6 | end 7 | -------------------------------------------------------------------------------- /extras/sizestring.m: -------------------------------------------------------------------------------- 1 | function info = sizestring(d) 2 | 3 | info = num2str(d(1)); 4 | for i = 2:length(d) 5 | info = [info 'x' num2str(d(i))]; 6 | end -------------------------------------------------------------------------------- /extras/snoptgp_callback.m: -------------------------------------------------------------------------------- 1 | function [F,G] = snoptgp_callback(x,mmodel) 2 | 3 | persistent model 4 | if nargin > 1 5 | model = mmodel; 6 | return 7 | end 8 | 9 | [f,df] = fmincon_fungp(x,model); 10 | [g,geq,dg,dgeq] = fmincon_congp(x,model); 11 | F = [f;g;geq]; 12 | n = length(x); 13 | m = length(g); 14 | p = length(geq); 15 | G = [reshape(df,1,n);dg';dgeq']; -------------------------------------------------------------------------------- /extras/solverCapable.m: -------------------------------------------------------------------------------- 1 | function featureSupported = solverCapable(solverList,solverName,feature); 2 | 3 | i = 1; 4 | featureSupported = 1; 5 | while i <= length(solverList) 6 | if strcmpi(solverList(i).tag,solverName) 7 | % dynamic fields not supported in old versions... 8 | featureSupported = eval(['solverList(i).' feature]); 9 | return 10 | end 11 | i = i+1; 12 | end 13 | -------------------------------------------------------------------------------- /extras/startofEXPCone.m: -------------------------------------------------------------------------------- 1 | function top = startofEXPCone(K) 2 | 3 | top = 1 + K.f + K.l + sum(K.q); -------------------------------------------------------------------------------- /extras/startofLPCone.m: -------------------------------------------------------------------------------- 1 | function top = startofLPCone(K) 2 | 3 | top = 1 + K.f; -------------------------------------------------------------------------------- /extras/startofPOWCone.m: -------------------------------------------------------------------------------- 1 | function top = startofPOWCone(K) 2 | 3 | top = 1 + K.f + K.l + sum(K.q) + 3*K.e; -------------------------------------------------------------------------------- /extras/startofSDPCone.m: -------------------------------------------------------------------------------- 1 | function top = startofSDPCone(K) 2 | 3 | top = 1 + K.f + K.l + sum(K.q) + 3*K.e + sum(K.p); -------------------------------------------------------------------------------- /extras/startofSOCPCone.m: -------------------------------------------------------------------------------- 1 | function top = startofSOCPCone(K) 2 | 3 | top = 1 + K.f + K.l; -------------------------------------------------------------------------------- /extras/strmatch_octavesafe.m: -------------------------------------------------------------------------------- 1 | function idx = strmatch_octavesafe(S, A, exact) 2 | if nargin < 3 3 | idx = find(strncmp(S, A, numel(S))); 4 | else 5 | % Exact match 6 | idx = find(strcmp(S, A)); 7 | end 8 | end 9 | 10 | -------------------------------------------------------------------------------- /extras/threeletterwords.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yalmip/YALMIP/c9fa6d8f641908454ea7b9b2baa6db8ba78d0cd0/extras/threeletterwords.mat -------------------------------------------------------------------------------- /extras/unionstripped.m: -------------------------------------------------------------------------------- 1 | function c = unionstripped(a,b) 2 | %UNIONSTRIPPED Internal function (version without checkings etc.) 3 | 4 | c = uniquestripped([a(:)' b(:)']); 5 | 6 | 7 | -------------------------------------------------------------------------------- /extras/uniquestripped.m: -------------------------------------------------------------------------------- 1 | function b = uniquestripped(a) 2 | %UNIQUESTRIPPED Internal function (version without checkings etc.) 3 | 4 | b = sort(a(:)'); 5 | i = diff([b NaN])~=0; 6 | if ~all(i) 7 | b = b(i); 8 | end 9 | 10 | -------------------------------------------------------------------------------- /extras/value.m: -------------------------------------------------------------------------------- 1 | function x = value(x) 2 | %VALUE Overloaded from sdpvar/value -------------------------------------------------------------------------------- /extras/yalmipbandwidth.m: -------------------------------------------------------------------------------- 1 | function b = yalmipbandwidth(S) 2 | 3 | if isa(S,'sdpvar') 4 | S = spy(S); 5 | end 6 | [i,j] = find(triu((S))); 7 | b = max(abs(i-j)); 8 | 9 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yalmip/YALMIP/c9fa6d8f641908454ea7b9b2baa6db8ba78d0cd0/license.txt -------------------------------------------------------------------------------- /modules/dummy.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yalmip/YALMIP/c9fa6d8f641908454ea7b9b2baa6db8ba78d0cd0/modules/dummy.m -------------------------------------------------------------------------------- /modules/global/DeriveMonotonicityFromShape.m: -------------------------------------------------------------------------------- 1 | function monotonicity = DeriveMonotonicityFromShape(properties,xL,xU) 2 | 3 | monotonicity = 'none'; 4 | if isequal(properties.shape,'bell-shape') 5 | if xU <= properties.stationary(1) 6 | monotonicity = 'increasing'; 7 | elseif xL >= properties.stationary(1) 8 | monotonicity = 'decreasing'; 9 | end 10 | elseif isequal(properties.convexity,'v-shape') 11 | if xU <= properties.stationary(1) 12 | monotonicity = 'decreasing'; 13 | elseif xL >= properties.stationary(1) 14 | monotonicity = 'increasing'; 15 | end 16 | end -------------------------------------------------------------------------------- /modules/global/DeriveMonotonicityFromStationary.m: -------------------------------------------------------------------------------- 1 | function monotonicity = DeriveMonotonicityFromStationary(properties,xL,xU) 2 | 3 | monotonicity = 'none'; 4 | if isequal(properties.convexity,'convex') 5 | if xU <= properties.stationary(1) 6 | monotonicity = 'decreasing'; 7 | elseif xL >= properties.stationary(1) 8 | monotonicity = 'increasing'; 9 | end 10 | elseif isequal(properties.convexity,'concave') 11 | if xU <= properties.stationary(1) 12 | monotonicity = 'increasing'; 13 | elseif xL >= properties.stationary(1) 14 | monotonicity = 'decreasing'; 15 | end 16 | end -------------------------------------------------------------------------------- /modules/global/addComplementarityCuts.m: -------------------------------------------------------------------------------- 1 | function p = addComplementarityCuts(p) 2 | 3 | if size(p.complementary,1)>0 4 | p_cut = emptyNumericalModel; 5 | for i = 1:size(p.complementary,1) 6 | variables = p.complementary(i,:); 7 | if p.lb(variables(1))>0 & p.lb(variables(2))>0 8 | p_cut.F_struc(end+1,1)=p.ub(variables(2)); 9 | p_cut.F_struc(end,1+variables(1))=-p.ub(variables(2))/p.ub(variables(1)); 10 | p_cut.F_struc(end,1+variables(2))=-1; 11 | p_cut.K.l = p_cut.K.l + 1; 12 | end 13 | end 14 | p = mergeNumericalModels(p,p_cut); 15 | end -------------------------------------------------------------------------------- /modules/global/addEquality.m: -------------------------------------------------------------------------------- 1 | function p = addEquality(p,row) 2 | % Equalities on top so easy 3 | p.F_struc = [row;p.F_struc]; 4 | p.K.f = p.K.f + size(row,1); -------------------------------------------------------------------------------- /modules/global/adjustMaxTime.m: -------------------------------------------------------------------------------- 1 | function p = adjustMaxTime(p,maxtime,elapsed) 2 | 3 | % Allow the solver at-least 1 second 4 | remaining = maxtime-elapsed; 5 | budgetForSolver = max(1,ceil(remaining)); 6 | 7 | % TODO: Support more solvers 8 | p.options.copt.TimeLimit = budgetForSolver; 9 | p.options.cplex.timelimit = budgetForSolver; 10 | p.options.mosek.MSK_DPAR_MIO_MAX_TIME = budgetForSolver; 11 | p.options.gurobi.TimeLimit = budgetForSolver; 12 | -------------------------------------------------------------------------------- /modules/global/classifyrows.m: -------------------------------------------------------------------------------- 1 | function p = classifyrows(p) 2 | if p.K.f > 0 3 | 4 | end 5 | if p.K.l > 0 6 | 7 | end -------------------------------------------------------------------------------- /modules/global/clean_bounds.m: -------------------------------------------------------------------------------- 1 | function p = clean_bounds(p) 2 | if 0 % Scary. This is not correct, casuses #1146 3 | close = 1e-10>abs(p.ub - round(p.ub)); 4 | p.ub(close) = round(p.ub(close)); 5 | close = 1e-10>abs(p.lb - round(p.lb)); 6 | p.lb(close) = round(p.lb(close)); 7 | p.ub(p.binary_variables) = floor(p.ub(p.binary_variables) + 1e-2); 8 | p.lb(p.lb<-1e12) = -inf; 9 | p.ub(p.ub>1e12) = inf; 10 | end -------------------------------------------------------------------------------- /modules/global/complementmodel.m: -------------------------------------------------------------------------------- 1 | function p = complementmodel(p) 2 | 3 | % Extend model to include complemented binary 4 | % Used when doing clique analysis 5 | A = p.F_struc(:,2:end); 6 | B = A(:,p.binary_variables); 7 | p.F_struc(:,1+p.binary_variables) = min(0,B); 8 | B = -max(B,0); 9 | p.F_struc = [p.F_struc B]; 10 | p.F_struc(:,1) = p.F_struc(:,1) - sum(B,2); 11 | p.binary_variables = [p.binary_variables length(p.c) + p.binary_variables]; 12 | p.isbinary = [p.isbinary p.isbinary ]; 13 | lb = p.lb; 14 | ub = p.ub; 15 | p.lb = [p.lb;1-ub]; 16 | p.ub = [p.ub;1-lb]; 17 | p.cliques = [p.cliques;p.cliques*0]; 18 | p.c = [p.c;p.c]; 19 | 20 | -------------------------------------------------------------------------------- /modules/global/computecost.m: -------------------------------------------------------------------------------- 1 | function cost = computecost(f,c,Q,x,p) 2 | 3 | if isempty(f) 4 | f = 0; 5 | end 6 | cost = f+c'*x+x'*Q*x; 7 | if ~isequal(p.K.m,0) 8 | top = size(p.F_struc,1)-sum(p.K.m.^2)+1; 9 | for i = 1:length(p.K.m) 10 | X = p.F_struc(top:top + p.K.m(i)^2-1,:)*[1;x]; 11 | X = reshape(X,p.K.m(i),p.K.m(i)); 12 | cost = cost + p.K.maxdetgain(i)*sum(real(log(real(eig(X))))); 13 | top = top + p.K.m(i)^2; 14 | end 15 | end -------------------------------------------------------------------------------- /modules/global/convexhullFromSampled.m: -------------------------------------------------------------------------------- 1 | function [Ax,Ay,b,K] = convexhullFromSampled(z,fz,xL,xU); 2 | 3 | k1 = max((fz(2:end)-fz(1))./(z(2:end)-xL))+1e-12; 4 | k2 = min((fz(2:end)-fz(1))./(z(2:end)-xL))-1e-12; 5 | k3 = min((fz(1:end-1)-fz(end))./(z(1:end-1)-xU))+1e-12; 6 | k4 = max((fz(1:end-1)-fz(end))./(z(1:end-1)-xU))-1e-12; 7 | Ax = [-k1;k2;-k3;k4]; 8 | Ay = [1;-1;1;-1]; 9 | b = [k1*(-z(1)) + fz(1);-(k2*(-z(1)) + fz(1));k3*(-z(end)) + fz(end);-(k4*(-z(end)) + fz(end))]; 10 | K.f = 0; 11 | K.l = length(b); -------------------------------------------------------------------------------- /modules/global/convexhullGeneral.m: -------------------------------------------------------------------------------- 1 | function [Ax,Ay,b,K] = convexhullGeneral(xL,xU,f) 2 | 3 | z = linspace(xL,xU,100); 4 | fz = f(z); 5 | [minval,minpos] = min(fz); 6 | [maxval,maxpos] = max(fz); 7 | xtestmin = linspace(z(max([1 minpos-5])),z(min([100 minpos+5])),100); 8 | xtestmax = linspace(z(max([1 maxpos-5])),z(min([100 maxpos+5])),100); 9 | 10 | fz1 = f(xtestmin); 11 | fz2 = f(xtestmax); 12 | z = [z(:);xtestmin(:);xtestmax(:)]; 13 | fz = [fz(:);fz1(:);fz2(:)]; 14 | [z,sorter] = sort(z); 15 | fz = fz(sorter); 16 | [z,ii,jj]=unique(z); 17 | fz = fz(ii); 18 | 19 | [Ax,Ay,b,K] = convexhullFromSampled(z,fz,xL,xU); -------------------------------------------------------------------------------- /modules/global/createConvexHullMethodConcave.m: -------------------------------------------------------------------------------- 1 | function [Ax,Ay,b,K] = createConvexHullMethodConcave(xL,xU,f,df,dummy) 2 | % dummy is operator struct sent by blackbox 3 | xM = (xL+xU)/2; 4 | fL = real(f(xL)); 5 | fM = real(f(xM)); 6 | fU = real(f(xU)); 7 | dfL = real(df(xL)); 8 | dfM = real(df(xM)); 9 | dfU = real(df(xU)); 10 | x1 = xL;x2 = xU; 11 | goal_derivative = (fU-fL)/(xU-xL); 12 | for i = 1:4 13 | if dfMgoal_derivative 14 | x2 = xM;xM = (x1+x2)/2;fM = real(f(xM));dfM = real(df(xM)); 15 | else 16 | x1 = xM;xM = (x1+x2)/2;fM = real(f(xM));dfM = real(df(xM)); 17 | end 18 | end 19 | [Ax,Ay,b,K] = convexhullConvex(xL,xM,xU,fL,fM,fU,dfL,dfM,dfU); 20 | -------------------------------------------------------------------------------- /modules/global/decreasing_except_at.m: -------------------------------------------------------------------------------- 1 | function mono = decreasing_except_at(xL,xU,p) 2 | 3 | if xU <= p || xL >= p 4 | mono = 'decreasing'; 5 | else 6 | mono = 'none'; 7 | end -------------------------------------------------------------------------------- /modules/global/exclusionCut.m: -------------------------------------------------------------------------------- 1 | function [b,a] = exclusionCut(x,thesign) 2 | % Returns cut [b a]*[1;x] which is infeasible 3 | % for given binary 4 | % thesign = -1 models same for negated binary 5 | 6 | zv = find(abs(x) <= 1e-5); 7 | nz = find(abs(x) > 1e-5); 8 | a = spalloc(1,length(x),length(zv)); 9 | b = length(x)-length(zv)-1; 10 | a = sparse(1,zv,1,1,length(x))-sparse(1,nz,1,1,length(x)); 11 | if thesign == -1 12 | a = -a; 13 | end -------------------------------------------------------------------------------- /modules/global/findAtmostGroup.m: -------------------------------------------------------------------------------- 1 | function [g,b] = findAtmostGroup(p,s) 2 | g = [];b = []; 3 | if ~isempty(p.atmost) 4 | for i = 1:length(p.atmost.groups) 5 | if all(ismember(s,p.atmost.groups{i})) 6 | g = p.atmost.groups{i}; 7 | b = p.atmost.bounds(i); 8 | return 9 | end 10 | end 11 | end -------------------------------------------------------------------------------- /modules/global/find_gub_groups.m: -------------------------------------------------------------------------------- 1 | function [variables, index] = findGUBGroup(p,s) 2 | variables = [];index = []; 3 | for i = find((p.knapsack.type == 3) | (p.knapsack.type == 5)) 4 | if all(ismember(s,p.knapsack.variables{i})) 5 | variables = p.knapsack.variables{i}; 6 | index = i; 7 | return 8 | end 9 | end -------------------------------------------------------------------------------- /modules/global/fix_binary_products.m: -------------------------------------------------------------------------------- 1 | function x = set_binary_products(p,x) 2 | if ~isempty(p.binaryProduct) 3 | x(p.binaryProduct(:,1)) = prod(x(p.binaryProduct(:,2:3)),2); 4 | end -------------------------------------------------------------------------------- /modules/global/fix_downforce.m: -------------------------------------------------------------------------------- 1 | function x = fix_downforce(p,x) 2 | % ensure x1 + x2 + ... <= y 3 | for i = 1:length(p.downForce) 4 | forcing = p.downForce{i}.forcing; 5 | if x(forcing)==0 6 | forced = p.downForce{i}.forced; 7 | x(forced)=0; 8 | end 9 | end -------------------------------------------------------------------------------- /modules/global/fixedInfeasibleEquality.m: -------------------------------------------------------------------------------- 1 | function r = fixedInfeasibleEquality(p) 2 | % Find a == 0*x. Typically used after smashFixed 3 | if any(p.K.f) 4 | r = find(~any(p.F_struc(1:p.K.f,2:end),2)); 5 | if ~isempty(r) 6 | r = r(find(p.F_struc(r,1)) >= 1e-10); 7 | end 8 | else 9 | r = []; 10 | end -------------------------------------------------------------------------------- /modules/global/increasing_except_at.m: -------------------------------------------------------------------------------- 1 | function mono = increasing_except_at(xL,xU,p) 2 | 3 | if xU <= p || xL >= p 4 | mono = 'increasing'; 5 | else 6 | mono = 'none'; 7 | end -------------------------------------------------------------------------------- /modules/global/integer_relax.m: -------------------------------------------------------------------------------- 1 | function relaxed_p = integer_relax(p) 2 | relaxed_p = p; 3 | relaxed_p.integer_variables = []; 4 | relaxed_p.binary_variables = []; 5 | relaxed_p.semicont_variables = []; -------------------------------------------------------------------------------- /modules/global/intvmul.m: -------------------------------------------------------------------------------- 1 | function C = intvmul(A,B) 2 | a = A(1); 3 | b = A(2); 4 | c = B(1); 5 | d = B(2); 6 | C = [min([a*c, a*d, b*c, b*d]), max([a*c, a*d, b*c, b*d])]; 7 | -------------------------------------------------------------------------------- /modules/global/knapsack_cheapcut.m: -------------------------------------------------------------------------------- 1 | function cut = knapsack_cheapcut(row) 2 | % Dedicated easy cut for sum ai xi >= 0 3 | % which appears effective on some models 4 | if all(row(2:end)>=0) & row(1)<=0 5 | a = row(2:end); 6 | b = -row(1); 7 | [val,loc] = sort(a,'ascend'); 8 | g = cumsum(val); 9 | m = max(find(g < -row(1))); 10 | ok = setdiff(loc,loc(1:m)); 11 | b_cut = -1; 12 | a_cut = spalloc(1,length(val),0); 13 | a_cut(ok) = 1; 14 | cut = [b_cut a_cut]; 15 | else 16 | cut = []; 17 | end -------------------------------------------------------------------------------- /modules/global/knapsack_cover_lift_balas.m: -------------------------------------------------------------------------------- 1 | function q = knapsack_cover_lift_balas(a,Cset) 2 | Nset = setdiff(1:length(a),Cset); 3 | S = cumsum(sort(a(Cset),'descend')); 4 | S = [0 S(:)']; 5 | q = zeros(1,length(a)); 6 | q(Cset)=1; 7 | for k = Nset 8 | lambda = max(find(a(k) >= S))-1; 9 | q(k) = lambda; 10 | end 11 | -------------------------------------------------------------------------------- /modules/global/powerbound.m: -------------------------------------------------------------------------------- 1 | function bound = powerbound(lb,ub,powers) 2 | vars = find(powers); 3 | bound = [1 1]; 4 | for k = 1:length(vars) 5 | bound = intvmul(bound,intvpower([lb(vars(k)) ub(vars(k))],powers(vars(k)))); 6 | end -------------------------------------------------------------------------------- /modules/global/presolveOneMagicRound.m: -------------------------------------------------------------------------------- 1 | function p = presolveOneMagicRound(p); 2 | 3 | p = presolve_bounds_from_domains(p); 4 | p = presolve_bounds_from_modelbounds(p); 5 | p = propagate_bounds_from_convex_quadratic_ball(p); 6 | p = propagate_bounds_from_evaluations(p); 7 | p = update_monomial_bounds(p); 8 | p = propagate_bounds_from_equalities(p); 9 | p = presolve_bounds_from_inequalities(p); 10 | p = propagate_bounds_from_evaluations(p); 11 | p = update_monomial_bounds(p); 12 | p = propagate_bounds_from_evaluations(p); 13 | p = update_monomial_bounds(p); 14 | p = propagate_bounds_from_arbitrary_quadratics(p); -------------------------------------------------------------------------------- /modules/global/presolve_binaryinteger.m: -------------------------------------------------------------------------------- 1 | function p = presolve_binaryinteger(p) 2 | % Promote integers to binary if possible 3 | if ~isempty(p.integer_variables) 4 | binary_integer = find(p.ub(p.integer_variables)<=1 & p.lb(p.integer_variables)>=0); 5 | if ~isempty(binary_integer) 6 | p.binary_variables = union(p.binary_variables,p.integer_variables(binary_integer)); 7 | p.isinteger(p.integer_variables(binary_integer)) = 0; 8 | p.integer_variables(binary_integer) = []; 9 | p.isbinary(p.binary_variables) = 1; 10 | end 11 | end -------------------------------------------------------------------------------- /modules/global/propagate_atmost.m: -------------------------------------------------------------------------------- 1 | function p = propagate_atmost(p) 2 | 3 | if p.feasible 4 | for j = 1:length(p.atmost.groups) 5 | xy = p.atmost.groups{j}; 6 | locked = p.lb(xy) == 1; 7 | if any(locked) 8 | % locked = find(p.lb(xy) == 1); 9 | m = nnz(locked); 10 | if m > p.atmost.bounds(j) 11 | p.feasible = 0; 12 | return 13 | elseif m == p.atmost.bounds(j) 14 | p.ub(p.atmost.groups{j}) = 0; 15 | p.ub(xy(locked))=1; 16 | p.lb(xy(locked))=1; 17 | end 18 | end 19 | end 20 | end -------------------------------------------------------------------------------- /modules/global/propagate_bounds_from_evaluations.m: -------------------------------------------------------------------------------- 1 | function p = propagate_bounds_from_evaluations(p) 2 | 3 | if ~isempty(p.evalVariables) 4 | for i = 1:length(p.evalMap) 5 | p = update_one_eval_bound(p,i); 6 | p = update_one_inverseeval_bound(p,i); 7 | end 8 | end -------------------------------------------------------------------------------- /modules/global/propagate_downforce.m: -------------------------------------------------------------------------------- 1 | function p = propagate_downforce(p) 2 | 3 | % Find inconsistency of x1 + x2 + ... <= y 4 | if p.feasible 5 | for i = 1:length(p.downForce) 6 | forcing = p.downForce{i}.forcing; 7 | if p.ub(forcing)==0 8 | forced = p.downForce{i}.forced; 9 | if any(p.lb(forced)==1) 10 | p.feasible = 0; 11 | return 12 | else 13 | p.ub(forced)=0; 14 | end 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /modules/global/propagate_second_order_cover.m: -------------------------------------------------------------------------------- 1 | function [L,U] = propagate_second_order_cover(cuts,p) 2 | L = -inf(length(p.c),1); 3 | U = inf(length(p.c),1); 4 | if cuts.K.l>0 && ~isinf(p.binarycardinality.up) 5 | for i = 1:cuts.K.l 6 | row = cuts.F_struc(cuts.K.f+i,:); 7 | [L_,U_] = presolve_glover_sherali_cover(row,p); 8 | if ~isempty(L_) 9 | if any(L_>L) 10 | L = max(L,L_); 11 | end 12 | if any(U_ p.K.f); 9 | p.K.f = p.K.f - nnz(zero_row <= p.K.f); 10 | end 11 | end -------------------------------------------------------------------------------- /modules/global/removeSDPcuts.m: -------------------------------------------------------------------------------- 1 | function p = removeSDPcuts(p) 2 | 3 | if length(p.KCut.s)>0 4 | starts = p.K.f+p.K.l + [1 1+cumsum((p.K.s).^2)]; 5 | remove_these = []; 6 | for i = 1:length(p.KCut.s) 7 | j = p.KCut.s(i); 8 | remove_these = [remove_these;(starts(j):starts(j+1)-1)']; 9 | end 10 | p.F_struc(remove_these,:)=[]; 11 | p.K.s(p.KCut.s) = []; 12 | end -------------------------------------------------------------------------------- /modules/global/remove_objective.m: -------------------------------------------------------------------------------- 1 | function p = remove_objective(p) 2 | p.c = p.c*0; 3 | p.Q = p.Q*0; -------------------------------------------------------------------------------- /modules/global/round_solution.m: -------------------------------------------------------------------------------- 1 | function x = round_solution(x,p) 2 | 3 | x(p.integer_variables) = round(x(p.integer_variables)); 4 | x(p.binary_variables) = round(x(p.binary_variables)); 5 | 6 | -------------------------------------------------------------------------------- /modules/global/sdpextendsolution.m: -------------------------------------------------------------------------------- 1 | function [xtemp,fail] = sdpextendsolution(p,xtemp) 2 | % Given z and H0 + H*x + Hz*z try to find scalar x 3 | % such that SDP is feasible 4 | % Used in MISDP heuristics 5 | fail = 1; 6 | if p.sdpextendable 7 | Hy = p.sdpfix.H0 + reshape(p.sdpfix.Hz*xtemp(p.integral_variables),p.K.s(1),p.K.s(1)); 8 | s = eig(full(p.sdpfix.Hx),full(Hy)); 9 | s(isinf(s))=[]; 10 | s(isnan(s))=[]; 11 | if any(s) 12 | xtemp(p.noninteger_variables) = min(-1./s(s~=0)); 13 | fail = 0; 14 | end 15 | end -------------------------------------------------------------------------------- /modules/global/smashQPOjective.m: -------------------------------------------------------------------------------- 1 | function p = smashQPOjective(p,removethese) 2 | p.f = p.f + p.c(removethese)'*p.lb(removethese); 3 | p.c(removethese)=[]; 4 | if nnz(p.Q)>0 5 | p.c = p.c + 2*p.Q(find(~removethese),removethese)*p.lb(removethese); 6 | p.f = p.f + p.lb(removethese)'*p.Q(removethese,removethese)*p.lb(removethese); 7 | p.Q(:,find(removethese))=[]; 8 | p.Q(find(removethese),:)=[]; 9 | else 10 | p.Q = spalloc(length(p.c),length(p.c),0); 11 | end -------------------------------------------------------------------------------- /modules/global/update_semicont_bounds.m: -------------------------------------------------------------------------------- 1 | function p = update_semicont_bounds(p) 2 | if p.feasible && ~isempty(p.semicont_variables) 3 | redundant = find(p.lb<=0 & p.ub>=0); 4 | p.semicont_variables = setdiff(p.semicont_variables,redundant); 5 | % Now relax the model and generate hull including 0 6 | p.semibounds.lb = p.lb(p.semicont_variables); 7 | p.semibounds.ub = p.ub(p.semicont_variables); 8 | p.lb(p.semicont_variables) = min(p.lb(p.semicont_variables),0); 9 | p.ub(p.semicont_variables) = max(p.ub(p.semicont_variables),0); 10 | end 11 | -------------------------------------------------------------------------------- /modules/global/widenSmashedBox.m: -------------------------------------------------------------------------------- 1 | function p = widenSmashedBox(p) 2 | closeBad = find(abs(p.lb - p.ub) < 1e-6 & p.lb > p.ub); 3 | if ~isempty(closeBad) 4 | c = (p.lb(closeBad) + p.ub(closeBad))/2; 5 | r = ones(length(closeBad),1)*1e-6; 6 | p.lb(closeBad) = c-r; 7 | p.ub(closeBad) = c+r; 8 | end 9 | -------------------------------------------------------------------------------- /modules/parametric/mpt_clean_optmizer.m: -------------------------------------------------------------------------------- 1 | function [Fi,Gi] = mpt_clean_optmizer(Fi,Gi); 2 | if length(Fi)>0 3 | for i = 1:length(Fi) 4 | Fi{i} = round(1e10*Fi{i})/1e10; 5 | Gi{i} = round(1e10*Gi{i})/1e10; 6 | end 7 | end -------------------------------------------------------------------------------- /modules/parametric/mpt_select_rows.m: -------------------------------------------------------------------------------- 1 | function [Fi,Gi] = mpt_select_rows(Fi,Gi,requested_variables); 2 | if length(Fi) > 0 3 | for i = 1:length(Fi) 4 | Fi{i} = Fi{i}(requested_variables,:); 5 | Gi{i} = Gi{i}(requested_variables,:); 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /modules/parametric/removeExplorationConstraints.m: -------------------------------------------------------------------------------- 1 | function Matrices = removeExplorationConstraints(Matrices); 2 | candidates = find((~any(Matrices.G,2)) & (sum(Matrices.E | Matrices.E,2) == 1)); 3 | if ~isempty(candidates) 4 | Matrices.bndA = -Matrices.E(candidates,:); 5 | Matrices.bndb = Matrices.W(candidates,:); 6 | Matrices.G(candidates,:) = []; 7 | Matrices.E(candidates,:) = []; 8 | Matrices.W(candidates,:) = []; 9 | end -------------------------------------------------------------------------------- /modules/robust/dilate.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yalmip/YALMIP/c9fa6d8f641908454ea7b9b2baa6db8ba78d0cd0/modules/robust/dilate.m -------------------------------------------------------------------------------- /modules/robust/dilate2.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yalmip/YALMIP/c9fa6d8f641908454ea7b9b2baa6db8ba78d0cd0/modules/robust/dilate2.m -------------------------------------------------------------------------------- /modules/robust/getEFfromSET.m: -------------------------------------------------------------------------------- 1 | function [E,F] = getEFfromSET(Z); 2 | 3 | vars = getvariables(Z); 4 | E = []; 5 | for i = 1:length(vars) 6 | F{i} = []; 7 | end 8 | 9 | for j = 1:length(Z) 10 | Zi = sdpvar(Z(j)); 11 | E = blkdiag(E,getbasematrix(Zi,0)); 12 | for i = 1:length(vars) 13 | F{i} = blkdiag(F{i},-getbasematrix(Zi,vars(i))); 14 | end 15 | end -------------------------------------------------------------------------------- /modules/robust/getFzxfromSET.m: -------------------------------------------------------------------------------- 1 | function [F0,Fz,Fx,Fxz] = getFzxfromSET(F,z,x) 2 | 3 | F = sdpvar(F); 4 | F0 = -getbasematrix(F,0); 5 | zvars = getvariables(z); 6 | xvars = getvariables(x); 7 | 8 | for i = 1:length(xvars) 9 | Fx{i} = -getbasematrix(F,xvars(i)); 10 | end 11 | 12 | for i = 1:length(zvars) 13 | Fz{i} = -getbasematrix(F,zvars(i)); 14 | end 15 | 16 | for i = 1:length(xvars) 17 | for j = 1:length(zvars) 18 | Fxz{i,j} = -getbasematrix(F,getvariables(x(i)*z(j))); 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /modules/sos/deriveBasis.m: -------------------------------------------------------------------------------- 1 | function H = deriveBasis(A_equ) 2 | [L,U,P] = lu(A_equ); 3 | [L,U,P] = lu(A_equ'); 4 | r = colspaces(L'); 5 | AA = L'; 6 | H1 = AA(:,r); 7 | H2 = AA(:,setdiff(1:size(AA,2),r)); 8 | H = P'*[-H1\H2;speye(size(H2,2))]; 9 | function [indx]=colspaces(A) 10 | indx = []; 11 | for i = 1:size(A,2) 12 | s = max(find(A(:,i))); 13 | indx = [indx s]; 14 | end 15 | indx = unique(indx); -------------------------------------------------------------------------------- /modules/sos/genmonoms.m: -------------------------------------------------------------------------------- 1 | function monom = genmonoms(newton_m,x); 2 | %GENMONOMS Internal function used in SOS programs 3 | 4 | precalc = []; 5 | monom = []; 6 | for i = 1:size(newton_m,2) 7 | powers = unique(newton_m(:,i)); 8 | for j = 1:length(powers) 9 | precalc{1+powers(j),i} = x(i)^powers(j); 10 | end 11 | end 12 | 13 | monom = []; 14 | for i = 1:size(newton_m,1) 15 | temp = 1; 16 | for j = 1:size(newton_m,2) 17 | temp = temp*precalc{newton_m(i,j)+1,j};%x(j)^newton_m(i,j); 18 | end 19 | monom = [monom;temp]; 20 | end -------------------------------------------------------------------------------- /modules/sos/newtonmonoms.m: -------------------------------------------------------------------------------- 1 | function v = newtonmonoms(p) 2 | % NEWTONMONOMS Computes all monoms inside half Newton polytope 3 | % 4 | % V = NEWTONMONOMS(P) 5 | % 6 | % Input 7 | % P : Scalar SDPVAR object 8 | % 9 | % Output 10 | % V : Vector with SDPVAR objects 11 | % 12 | % Example: 13 | % 14 | % sdpvar x y 15 | % sdisplay(newtonmonoms(1+x^4*y^2+x^2*y^4)) 16 | % 17 | % See also NEWTONREDUCE, CONSISTENT, CONGRUENCEBLOCKS 18 | 19 | if isa(p,'double') 20 | v = 1; 21 | else 22 | x = recover(depends(p)); 23 | v = monolist(x,degree(p)/2); 24 | v = newtonreduce(v,p); 25 | end 26 | 27 | -------------------------------------------------------------------------------- /modules/sos/sparsenull.m: -------------------------------------------------------------------------------- 1 | function [Z,Q1,R] = sparsenull(A) 2 | 3 | [Q,R] = qr(A'); 4 | n = max(find(sum(abs(R),2))); 5 | Q1 = Q(:,1:n); 6 | R = R(1:n,:); 7 | Z = Q(:,n+1:end); % New basis -------------------------------------------------------------------------------- /operators/beta_w.m: -------------------------------------------------------------------------------- 1 | function varargout=beta_w(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'double' 6 | varargout{1} = beta(varargin{2},varargin{1}); 7 | 8 | case 'char' 9 | operator = CreateBasicOperator('convex','decreasing','positive','callback'); 10 | operator.domain = [0 inf]; 11 | varargout{1} = []; 12 | varargout{2} = operator; 13 | varargout{3} = varargin{3}; 14 | 15 | otherwise 16 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 17 | end -------------------------------------------------------------------------------- /operators/beta_z.m: -------------------------------------------------------------------------------- 1 | function varargout=beta_z(varargin) 2 | 3 | switch class(varargin{1}) 4 | 5 | case 'double' 6 | varargout{1} = beta(varargin{1},varargin{2}); 7 | 8 | case 'char' 9 | 10 | w = varargin{4}; 11 | operator = CreateBasicOperator('convex','decreasing','positive','callback'); 12 | operator.domain = [0 inf]; 13 | varargout{1} = []; 14 | varargout{2} = operator; 15 | varargout{3} = varargin{3}; 16 | 17 | otherwise 18 | error(['SDPVAR/' upper(mfilename) ' called with weird argument']); 19 | end -------------------------------------------------------------------------------- /operators/binary_implies_linearequality.m: -------------------------------------------------------------------------------- 1 | function F = binary_implies_linearequality(f,X,M,m,eps); 2 | 3 | if nargin < 3 || isempty(M) 4 | [M,m,infbound] = derivebounds(f); 5 | if infbound 6 | warning('You have unbounded variables in an implication leading to a lousy big-M relaxation.'); 7 | end 8 | end 9 | 10 | if all(m==0) 11 | lhs = m; 12 | elseif all(m==1) 13 | lhs = 1-X; 14 | else 15 | lhs = m.*(1-X); 16 | end 17 | if all(M==0) 18 | rhs = M; 19 | elseif all(M==1) 20 | rhs = 1-X; 21 | else 22 | rhs = M.*(1-X); 23 | end 24 | F = [f <= rhs, -f <= -lhs]; -------------------------------------------------------------------------------- /operators/binary_implies_linearnegativeconstraint.m: -------------------------------------------------------------------------------- 1 | function F = binary_implies_linearnegativeconstraint(f,X,M,m,eps); 2 | % Big-M for f<=0 iff X==1. Assumes f and X vectors of same size 3 | 4 | if nargin < 3 || isempty(M) 5 | [M,m,infbound,lowerinf,upperinf] = derivebounds(f); 6 | if upperinf 7 | warning('You have unbounded variables in an implication leading to a lousy big-M relaxation.'); 8 | end 9 | end 10 | 11 | if all(M == 0) 12 | F = [f <= 0]; 13 | elseif all(M == 1) 14 | F = [f <= (1-X)]; 15 | else 16 | F = [f <= M.*(1-X)]; 17 | end -------------------------------------------------------------------------------- /operators/huber.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yalmip/YALMIP/c9fa6d8f641908454ea7b9b2baa6db8ba78d0cd0/operators/huber.m -------------------------------------------------------------------------------- /operators/matrix_sdpvar_sort.m: -------------------------------------------------------------------------------- 1 | function [y,loc] = matrix_sdpvar_sort(varargin) 2 | 3 | % Called from sort to do matrix sorts using repeated vector sorts 4 | X = varargin{1}; 5 | if nargin > 1 6 | dim = varargin{2}; 7 | else 8 | dim = 1; 9 | end 10 | 11 | if dim == 2 12 | [y,loc] = matrix_sdpvar_sort(X',1); 13 | y = y'; 14 | loc = loc'; 15 | else 16 | y = []; 17 | loc = []; 18 | for i = 1:size(X,2) 19 | [yi,loci] = sort(X(:,i)); 20 | y = [y yi]; 21 | loc = [loc loci]; 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /operators/mpower_internal.m: -------------------------------------------------------------------------------- 1 | function varargout = mpower_internal(varargin) 2 | switch class(varargin{1}) 3 | case 'double' 4 | varargout{1} = varargin{1}; 5 | case 'char' 6 | % Note, the order here is assumed in GP formulation 7 | varargout{1} = (varargin{3} == varargin{2}); 8 | varargout{2} = struct('convexity','none','monotonicity','none','definiteness','none','model','exact'); 9 | varargout{3} = varargin{3}; 10 | otherwise 11 | end 12 | -------------------------------------------------------------------------------- /operators/negated_perspective_log.m: -------------------------------------------------------------------------------- 1 | function z = negated_perspective_log(x) 2 | if isequal(x(1),[0]) 3 | z = 0; 4 | else 5 | z = x(1)*log(x(1)/x(2)); 6 | end -------------------------------------------------------------------------------- /operators/pow10.m: -------------------------------------------------------------------------------- 1 | function varargout = pow10(varargin) 2 | 3 | varargout{1} = 10.^varargin{1}; 4 | -------------------------------------------------------------------------------- /operators/powerinternalhelper.m: -------------------------------------------------------------------------------- 1 | function y = powerinternalhelper(d,x); 2 | 3 | y = []; 4 | for i = 1:prod(size(d)) 5 | y = [y x(i).^d(i)]; 6 | end 7 | y = reshape(y,size(d)); -------------------------------------------------------------------------------- /operators/sdpfun.m: -------------------------------------------------------------------------------- 1 | function y = sdpfun(varargin) 2 | %SDPFUN Obsolete - changed to blackbox 3 | 4 | y = blackbox(varargin{:}); -------------------------------------------------------------------------------- /operators/sqrtm_internal.m: -------------------------------------------------------------------------------- 1 | function y = sqrtm_internal(x) 2 | 3 | if x>=0 4 | y = sqrt(x); 5 | else 6 | y = -x.^2; 7 | end 8 | -------------------------------------------------------------------------------- /operators/tplus.m: -------------------------------------------------------------------------------- 1 | function C = tplus(varargin) 2 | % TPLUS Tropical addition (max-plus algebra) 3 | % 4 | % C = TPLUS(A,B) Computes tropical addition C(i,j) = max(A(i,:) + B(:,j)'); 5 | % 6 | % Note that TPLUS can just as well can be replaced with C = MAX(A,B) 7 | % 8 | % See also ttimes 9 | 10 | if nargin == 2 11 | C = max(varargin{1},varargin{2}); 12 | else 13 | C = max(varargin{1},varargin{2}); 14 | for i = 3:nargin 15 | C = max(C,varargin{i}); 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /operators/ttimes.m: -------------------------------------------------------------------------------- 1 | function C = ttimes(A,B) 2 | % TTIMES Tropical multiplication (max-plus algebra) 3 | % 4 | % C = TTIMES(A,B) Computes the tropical multiplication of the matrices A 5 | % and B, AB(i,j) = max(A(i,:) + B(:,j)'); 6 | % 7 | % See also tplus 8 | 9 | n = size(A,1); 10 | m = size(B,2); 11 | C = reshape(max(kron(ones(m,1),A)+kron(B',ones(n,1)),[],2),n,m); 12 | -------------------------------------------------------------------------------- /operators/ventropy.m: -------------------------------------------------------------------------------- 1 | function f = ventropy(x) 2 | 3 | f = []; 4 | d = size(x); 5 | x = x(:); 6 | for i = 1:length(x) 7 | f = [f;entropy(x(i))]; 8 | end 9 | f = reshape(f,d); -------------------------------------------------------------------------------- /solvers/callnone.m: -------------------------------------------------------------------------------- 1 | function output = callnone(interfacedata) 2 | 3 | % Standard interface 4 | output.Primal = zeros(length(interfacedata.c),1); 5 | output.Dual = []; 6 | output.Slack = []; 7 | output.problem = -2; 8 | output.infostr = yalmiperror(-2,'YALMIP'); 9 | output.solverinput = []; 10 | output.solveroutput= []; 11 | output.solvertime = 0; -------------------------------------------------------------------------------- /solvers/yalmip2csdp.m: -------------------------------------------------------------------------------- 1 | function model = yalmip2csdp(interfacedata); 2 | 3 | pars = interfacedata.options.csdp; 4 | pars.printlevel=interfacedata.options.verbose; 5 | model.At = -interfacedata.F_struc(:,2:end); 6 | model.b = -interfacedata.c; 7 | model.C = interfacedata.F_struc(:,1); 8 | model.K = interfacedata.K; 9 | model.pars = pars; -------------------------------------------------------------------------------- /solvers/yalmip2dsdp.m: -------------------------------------------------------------------------------- 1 | function model = yalmip2dsdp(interfacedata); 2 | 3 | [C,A,b,blk] = sedumi2dsdp(interfacedata.F_struc,interfacedata.c,interfacedata.K); 4 | interfacedata.options.dsdp.dual_quadratic=spalloc(length(interfacedata.c),length(interfacedata.c),0); 5 | interfacedata.options.dsdp.printyes = (interfacedata.options.verbose>0); 6 | model.A = A; 7 | model.C = C; 8 | model.b = b; 9 | model.options = interfacedata.options.dsdp 10 | -------------------------------------------------------------------------------- /solvers/yalmip2pensdp.m: -------------------------------------------------------------------------------- 1 | function model = yalmip2pensdp(interfacedata); 2 | 3 | penstruct = sedumi2pen(interfacedata.F_struc,interfacedata.K,interfacedata.c,interfacedata.x0); 4 | ops = struct2cell(interfacedata.options.pensdp);ops = [ops{1:end}]; 5 | penstruct.ioptions = ops(1:8); 6 | penstruct.foptions = ops(9:end); 7 | penstruct.ioptions(4) = interfacedata.options.verbose; 8 | penstruct.ioptions = penstruct.ioptions; 9 | penstruct.foptions = penstruct.foptions; 10 | if penstruct.mconstr == 0 11 | penstruct.msizes = []; 12 | end 13 | model.penstruct = penstruct; -------------------------------------------------------------------------------- /solvers/yalmip2piqp.m: -------------------------------------------------------------------------------- 1 | function model = yalmip2piqp(interfacedata); 2 | 3 | quadprog_model = yalmip2quadprog(interfacedata); 4 | 5 | model.options = interfacedata.options.piqp; 6 | model.P = quadprog_model.Q; 7 | model.c = quadprog_model.c; 8 | model.A = quadprog_model.Aeq; 9 | model.b = quadprog_model.beq; 10 | model.G = quadprog_model.A; 11 | model.h = quadprog_model.b; 12 | model.x_lb = quadprog_model.lb; 13 | model.x_ub = quadprog_model.ub; -------------------------------------------------------------------------------- /solvers/yalmip2powersolver.m: -------------------------------------------------------------------------------- 1 | function model = yalmip2powersolver(interfacedata); 2 | 3 | model.A = -interfacedata.F_struc(:,2:end); 4 | model.b = -interfacedata.c; 5 | model.C = interfacedata.F_struc(:,1); 6 | model.K = interfacedata.K; 7 | pars = interfacedata.options.powersolver; 8 | 9 | -------------------------------------------------------------------------------- /solvers/yalmip2sdpa.m: -------------------------------------------------------------------------------- 1 | function model = yalmip2sdpa(interfacedata); 2 | [mDIM,nBLOCK,bLOCKsTRUCT,c,F] = sedumi2sdpa(interfacedata.F_struc,interfacedata.c,interfacedata.K); 3 | if interfacedata.options.verbose==0 4 | interfacedata.options.sdpa.print = 'no'; 5 | else 6 | interfacedata.options.sdpa.print = 'display'; 7 | end 8 | model.mDIM = mDIM; 9 | model.nBLOCK = nBLOCK; 10 | model.bLOCKsTRUCT = bLOCKsTRUCT; 11 | model.c = c; 12 | model.F = F; 13 | model.x0 = []; 14 | model.X0 = []; 15 | model.Y0 = []; 16 | model.OPTIONS = interfacedata.options.sdpa; -------------------------------------------------------------------------------- /solvers/yalmip2sdpt3.m: -------------------------------------------------------------------------------- 1 | function model = yalmip2sdpt3(interfacedata) 2 | [blk,A,C,b,oldKs]=sedumi2sdpt3(interfacedata.F_struc(:,1),-interfacedata.F_struc(:,2:end),-interfacedata.c,interfacedata.K,interfacedata.options.sdpt3.smallblkdim); 3 | interfacedata.options.sdpt3.printyes=double(interfacedata.options.verbose); 4 | interfacedata.options.sdpt3.expon=interfacedata.options.sdpt3.expon(1); 5 | 6 | model.blk = blk; 7 | model.A = A; 8 | model.C = C; 9 | model.b = b; 10 | model.ops = interfacedata.options.sdpt3; -------------------------------------------------------------------------------- /solvers/yalmip2sedumi.m: -------------------------------------------------------------------------------- 1 | function model = yalmip2sedumi(interfacedata); 2 | 3 | model.A = -interfacedata.F_struc(:,2:end); 4 | model.b = -interfacedata.c; 5 | model.C = interfacedata.F_struc(:,1); 6 | model.K = interfacedata.K; 7 | pars = interfacedata.options.sedumi; 8 | pars.fid = double(interfacedata.options.verbose); 9 | model.pars = pars; 10 | 11 | -------------------------------------------------------------------------------- /yalmipdemo.m: -------------------------------------------------------------------------------- 1 | disp(sprintf('Please check out the on-line tutorials on the YALMIP Wiki')); 2 | --------------------------------------------------------------------------------