### Generate Convex.jl Documentation and Examples Source: https://github.com/jump-dev/convex.jl/blob/master/docs/README.md Run this command to generate all example notebooks and the documentation. It may take a significant amount of time. Set ENV["CONVEX_SKIP_EXAMPLES"]="true" to skip example generation. ```sh julia --project=docs -e 'using Pkg; Pkg.instantiate(); include("docs/make.jl")' ``` -------------------------------- ### Install a Solver Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/solvers.md Install a solver package using the Julia package manager. Replace "SCS" with the desired solver's package name. ```julia import Pkg Pkg.add("SCS") ``` -------------------------------- ### Configure GLPK Solver with Options Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/solvers.md Pass solver-specific options using MOI.OptimizerWithAttributes. This example sets a time limit for GLPK. ```julia import Convex: MOI solver = MOI.OptimizerWithAttributes(GLPK.Optimizer, "tm_lim" => 60_000.0) solve!(p, solver) ``` -------------------------------- ### Use GLPK Solver Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/solvers.md Example of using the GLPK solver for mixed-integer linear problems. Import GLPK and use its optimizer. ```julia using GLPK solve!(p, GLPK.Optimizer) ``` -------------------------------- ### Warmstarting for Performance Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/advanced.md This example demonstrates how to use the `warmstart=true` option in `solve!` to potentially speed up subsequent solves of the same problem structure with updated parameters. It compares a standard solve with a warmstarted solve. ```julia using Convex, SCS n = 1_000 y = rand(n); x = Variable(n) lambda = Variable(Positive()) fix!(lambda, 100) problem = minimize(sumsquares(y - x) + lambda * sumsquares(x - 10)) @time solve!(problem, SCS.Optimizer) # Now warmstart. If the solver takes advantage of warmstarts, this run will be # faster fix!(lambda, 105) @time solve!(problem, SCS.Optimizer; warmstart = true) ``` -------------------------------- ### Use SCS Solver Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/solvers.md Example of using the SCS solver to solve a minimization problem. Ensure both Convex and SCS are imported. ```julia using Convex, SCS x = Variable() p = minimize(x, [x >= 1]) solve!(p, SCS.Optimizer) ``` -------------------------------- ### Accessing Dual Variables Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/advanced.md This example shows how to retrieve the optimal dual variables associated with a constraint after solving a Convex.jl problem. Ensure the solver supports dual variables. ```repl using Convex, SCS x = Variable(); constraint = x >= 0; p = minimize(x, [constraint]); solve!(p, SCS.Optimizer; silent = true) constraint.dual ``` -------------------------------- ### Install Convex.jl Package Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/introduction/installation.md Use this command to add the Convex.jl package to your Julia environment. This step is required to use the Convex.jl modeling capabilities. ```julia using Pkg Pkg.add("Convex") ``` -------------------------------- ### Configure SCS Solver for Silent Mode Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/solvers.md Use MOI.OptimizerWithAttributes to pass solver-specific options. This example configures the SCS solver to run in silent mode. ```julia silent_scs = MOI.OptimizerWithAttributes(SCS.Optimizer, MOI.Silent() => true) solve!(p, silent_scs) ``` -------------------------------- ### Get Constraints Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Retrieves the constraints associated with an abstract variable. Returns a list of constraints. ```julia Convex.get_constraints ``` -------------------------------- ### Quick Example: Minimize Norm Squared Source: https://github.com/jump-dev/convex.jl/blob/master/README.md Solves a convex program to minimize the squared Euclidean norm of Ax - b subject to bounds on x. Requires Convex.jl and a solver like SCS.jl. ```julia using Convex, SCS m = 4; n = 5 A = randn(m, n); b = randn(m, 1) x = Variable(n) problem = minimize(sumsquares(A * x - b), [x >= 0, x <= 1]) solve!(problem, SCS.Optimizer) problem.status problem.optval ``` -------------------------------- ### Install SCS Solver Package Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/introduction/installation.md Add the SCS solver package to your Julia environment. This is necessary for solving certain types of convex optimization problems. ```julia Pkg.add("SCS") ``` -------------------------------- ### Alternating Minimization with Fixed Variables Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/advanced.md Use `fix!` and `free!` to implement alternating minimization for nonconvex problems. This example solves a nonnegative matrix factorization problem iteratively. ```julia n, k = 10, 1 A = rand(n, k) * rand(k, n) x = Variable(n, k) y = Variable(k, n) problem = minimize(sum_squares(A - x * y), [x >= 0, y >= 0]) # initialize value of y set_value!(y, rand(k, n)) # we'll do 10 iterations of alternating minimization for i in 1:10 # first solve for x. With y fixed, the problem is convex. fix!(y) solve!(problem, SCS.Optimizer; warmstart = i > 1 ? true : false) # Now solve for y with x fixed at the previous solution. free!(y) fix!(x) solve!(problem, SCS.Optimizer; warmstart = true) free!(x) end ``` -------------------------------- ### Optimize Quantum States with Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/complex-domain_optimization.md Define and optimize quantum states using complex matrix variables, `kron`, and `partialtrace`. This example sets constraints for a product state in a composite Hilbert space. ```julia using Convex, SCS A = [ 0.47213595 0.11469794+0.48586827im; 0.11469794-0.48586827im 0.52786405] B = ComplexVariable(2, 2) ρ = kron(A, B) constraints = [ partialtrace(ρ, 1, [2; 2]) == [1 0; 0 0], tr(ρ) == 1, isposdef(ρ), ] p = satisfy(constraints) solve!(p, SCS.Optimizer; silent = true) p.status ``` -------------------------------- ### Handling DCP Compliance Errors Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/advanced.md This example demonstrates a DCP violation error when an objective function is not in disciplined convex form. It shows the expected error message and stack trace. ```jldoctest julia> using Convex, SCS julia> x = Variable(); julia> y = Variable(); julia> p = minimize(log(x) + square(y), [x >= 0, y >= 0]); julia> solve!(p, SCS.Optimizer; silent = true) ┌ Warning: Problem not DCP compliant: objective is not DCP └ @ Convex ~/.julia/dev/Convex/src/problems.jl:73 ERROR: DCPViolationError: Expression not DCP compliant. This either means that your problem is not convex, or that we could not prove it was convex using the rules of disciplined convex programming. For a list of supported operations, see https://jump.dev/Convex.jl/stable/operations/. For help writing your problem as a disciplined convex program, please post a reproducible example on https://jump.dev/forum. Stacktrace: [...] ``` -------------------------------- ### Get Variable Type Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Retrieves the type of an abstract variable. ```julia Convex.vartype ``` -------------------------------- ### Get Variable Vexity Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Returns the vexity of an abstract variable, indicating its convexity properties. ```julia Convex.vexity ``` -------------------------------- ### Get Variable Value Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Retrieves the current value of an abstract variable. Ensure the variable has been assigned a value. ```julia Convex._value ``` -------------------------------- ### Run Tests Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Executes predefined tests within the ProblemDepot module. Useful for verifying solver behavior. ```julia Convex.ProblemDepot.run_tests ``` -------------------------------- ### Problem Depot Utilities Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Utilities for managing and running tests and benchmarks from the Convex.ProblemDepot. ```APIDOC ## Module: Convex.ProblemDepot ### Description Provides utilities for accessing, running, and benchmarking problems stored in the Convex.jl problem depot. ``` ```APIDOC ## Function: Convex.ProblemDepot.run_tests() ### Description Runs all the tests defined within the Convex.ProblemDepot. ``` ```APIDOC ## Function: Convex.ProblemDepot.benchmark_suite() ### Description Returns a benchmark suite for evaluating the performance of Convex.jl on various problems. ``` ```APIDOC ## Function: Convex.ProblemDepot.foreach_problem(func) ### Description Applies the given function `func` to each problem available in the Convex.ProblemDepot. ### Parameters - `func`: The function to apply to each problem. ``` ```APIDOC ## Constant: Convex.ProblemDepot.PROBLEMS ### Description A collection or list of all problems available in the Convex.ProblemDepot. ``` -------------------------------- ### List of Problems Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Provides access to a collection of predefined optimization problems within the ProblemDepot. ```julia Convex.ProblemDepot.PROBLEMS ``` -------------------------------- ### Run Tests on SCS Solver Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/developer/problem_depot.md Tests the SCS solver on all problems in the depot, excluding mixed-integer problems. Requires Convex, SCS, and Test packages. Problems are solved using `solve!` with specific attributes for the SCS optimizer. ```julia using Convex, SCS, Test const MOI = Convex.MOI @testset "SCS" begin Convex.ProblemDepot.run_tests(; exclude=[r"mip"]) do p solve!(p, MOI.OptimizerWithAttributes(SCS.Optimizer, "verbose" => 0, "eps_abs" => 1e-6)) end end ``` -------------------------------- ### Creating Convex Expressions Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/types.md Demonstrates the creation of basic Convex.jl expressions using variables and arithmetic operations. Ensure variables are properly declared before use. ```julia x = Variable(5) # The following are all expressions y = sum(x) z = 4 * x + y z_1 = z[1] ``` -------------------------------- ### Declaring Equality and Inequality Constraints Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/types.md Illustrates how to declare equality and inequality constraints between variables and expressions using standard comparison operators. Constraints apply elementwise. ```julia x = Variable(5, 5) # Equality constraint constraint = x == 0 # Inequality constraint constraint = x >= 1 ``` -------------------------------- ### Define a Benchmark-Only SDP Constraint Problem Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/developer/problem_depot.md Adds a problem specifically for benchmarking the time to add an SDP constraint. It is placed in the `benchmark` subdirectory and includes `benchmark` in its name, ensuring it's skipped during `run_tests`. Uses `args...` for flexible function signature. ```julia @add_problem constraints_benchmark function sdp_constraint(handle_problem!, args...) p = satisfy() x = Variable(44, 44) # 990 vectorized entries push!(p.constraints, x ⪰ 0) handle_problem!(p) nothing end ``` -------------------------------- ### Benchmark Suite Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Accesses the benchmark suite for performance evaluation of Convex.jl. ```julia Convex.ProblemDepot.benchmark_suite ``` -------------------------------- ### Generate a Single Jupyter Notebook Source: https://github.com/jump-dev/convex.jl/blob/master/docs/README.md Use Literate.notebook to create a single Jupyter notebook from a file. Set execute to true to run the code within the notebook. ```julia Literate.notebook(file_path, notebook_dir, execute=false) # or execute = true, to run the code ``` -------------------------------- ### Using Convex.jl with JuMP for Nonlinear Optimization Source: https://github.com/jump-dev/convex.jl/blob/master/README.md Reformulates a nonlinear JuMP model into a conic program using Convex.jl's experimental solver. Currently supports a limited subset of scalar nonlinear programs involving log and exp. ```julia using JuMP, Convex, Clarabel model = Model(() -> Convex.Optimizer(Clarabel.Optimizer)); set_silent(model) @variable(model, x >= 1); @variable(model, t); @constraint(model, t >= exp(x)) @objective(model, Min, t); optimize!(model) value(x), value(t) ``` -------------------------------- ### Adding Constraints to Variables Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/types.md Demonstrates how to add constraints directly to a variable using `add_constraint!`. These constraints will be automatically included in any problem that uses the variable. ```julia x = Variable(3) add_constraint!(x, sum(x) == 1) ``` -------------------------------- ### Solve with SCS in Silent Mode using Keyword Argument Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/solvers.md An alternative method to run the SCS solver in silent mode using the solver-independent `silent` keyword argument in `solve!`. ```julia solve!(p, SCS.Optimizer; silent=true) ``` -------------------------------- ### Write Problem to File Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Saves the optimization problem to a file in a specified format. Useful for debugging or sharing. ```julia Convex.write_to_file ``` -------------------------------- ### Evaluating Convex Expressions Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/types.md Shows how to define a problem, solve it, and then evaluate the value of a Convex.jl expression. This requires a solved problem object. ```julia x = Variable() y = Variable() z = Variable() expr = x + y + z problem = minimize(expr, x >= 1, y >= x, 4 * z >= y) solve!(problem, SCS.Optimizer) # Once the problem is solved, we can call evaluate() on expr: evaluate(expr) ``` -------------------------------- ### Constraining Matrices to be Positive Semidefinite Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/types.md Shows how to constrain a matrix formed by variables to be positive semidefinite using either the `isposdef` function or the `⪰` operator. This is useful for convex optimization problems involving semidefinite programming. ```julia x = Variable(3, 3) y = Variable(3, 1) z = Variable() # constrain [x y; y' z] to be positive semidefinite constraint = isposdef([x y; y' z]) # or equivalently, constraint = ([x y; y' z] ⪰ 0) ``` -------------------------------- ### Access Solution Results Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/types.md After solving, access the problem's status via `problem.status` and the optimal value via `problem.optval`. Evaluate individual variables or expressions using `evaluate(variable)` or `evaluate(expression)`. ```julia problem.status problem.optval evaluate(x) evaluate(expr) ``` -------------------------------- ### Pre-Order Depth-First Traversal Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/advanced.md Iterate through the nodes of a tree using `AbstractTrees.PreOrderDFS`, ensuring parents are visited before their children. Useful for processing tree structures from the root down to the leaves. ```julia for (i, node) in enumerate(AbstractTrees.PreOrderDFS(p)) println("Here's node $i via PreOrderDFS: $(summary(node))") end ``` -------------------------------- ### qol_elementwise Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Element-wise quadratic form. Used in optimization problems involving quadratic terms. ```APIDOC ## `qol_elementwise` ### Description Element-wise quadratic form. ### Signature ```julia Convex.qol_elementwise(::Convex.AbstractExpr, ::Convex.AbstractExpr) ``` ``` -------------------------------- ### Valid Extended Formulation for Minimization Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/introduction/dcp.md This snippet demonstrates a valid extended formulation for a minimization problem using the absolute value function. It introduces an auxiliary variable 't' to represent abs(x) and ensures the problem remains DCP compliant. ```julia using Convex, SCS x = Variable(); t = Variable(); model_min_extended = minimize(t, [x >= 1, x <= 2, t >= x, t >= -x]); solve!(model_min_extended, SCS.Optimizer; silent = true) x.value ``` -------------------------------- ### Element-wise `/` Operator (`./`) Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Element-wise division of an abstract expression by a constant value, using Julia's broadcasting. ```APIDOC ## `./` ### Description Element-wise division of an abstract expression by a constant value. ### Method `Base.Broadcast.broadcasted(::typeof(/), ::Convex.AbstractExpr, ::Convex.Value)` ``` -------------------------------- ### Basic Minimization Problem Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/introduction/dcp.md A simple minimization problem using the absolute value function without an extended formulation. This serves as a baseline for comparison with extended formulations. ```julia using Convex, SCS x = Variable(); model_min = minimize(abs(x), [x >= 1, x <= 2]); solve!(model_min, SCS.Optimizer; silent = true) x.value ``` -------------------------------- ### Problem Evaluation and Solving Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Functions for evaluating problem objectives and solving optimization problems. ```APIDOC ## Function: Convex.evaluate(expression) ### Description Evaluates the given `expression` using the current values of its variables. This is useful for calculating objective function values or constraint satisfaction. ### Parameters - `expression`: The Convex.jl expression to evaluate. ``` ```APIDOC ## Function: Convex.solve!(problem, solver) ### Description Solves the given Convex.jl `problem` using the specified `solver`. This function attempts to find the optimal values for the decision variables. ### Parameters - `problem`: The Convex.jl problem to solve. - `solver`: The solver to use (e.g., SCS, ECOS). ``` -------------------------------- ### Post-Order Depth-First Traversal Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/advanced.md Iterate through the nodes of a tree using `AbstractTrees.PostOrderDFS`, ensuring children are visited before their parents. Useful for processing tree structures from leaves up to the root. ```julia for (i, node) in enumerate(AbstractTrees.PostOrderDFS(p)) println("Here's node $i via PostOrderDFS: $(summary(node))") end ``` -------------------------------- ### kron Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the Kronecker product of two expressions. ```APIDOC ## `kron` ### Description Computes the Kronecker product of two expressions. ### Method `Base.kron(::Convex.Value, ::Convex.AbstractExpr)` ``` -------------------------------- ### Define Optimization Problem Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/types.md Construct a Convex.jl problem for minimization, maximization, or feasibility. Use `minimize` or `maximize` with an objective and optional constraints, or `satisfy` for feasibility problems. ```julia problem = minimize(objective, constraints) # or problem = maximize(objective, constraints) # or problem = satisfy(constraints) ``` -------------------------------- ### Constraint Management Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Functions for retrieving and adding constraints to a Convex.jl problem. ```APIDOC ## Function: Convex.get_constraints(problem) ### Description Retrieves the list of constraints associated with a given Convex.jl `problem`. ### Parameters - `problem`: The Convex.jl problem object. ``` ```APIDOC ## Function: Convex.add_constraint!(problem, constraint) ### Description Adds a new `constraint` to the specified Convex.jl `problem`. Constraints define the feasible region of the optimization problem. ### Parameters - `problem`: The Convex.jl problem object to which the constraint will be added. - `constraint`: The constraint to add. ``` -------------------------------- ### Iterate Through Problems Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Applies a function to each problem defined in the ProblemDepot. Useful for batch processing or analysis. ```julia Convex.ProblemDepot.foreach_problem ``` -------------------------------- ### Variable Type and Properties Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Functions for inspecting and setting the type and properties of variables. ```APIDOC ## Type: Convex.VarType ### Description A type representing the possible types of variables in Convex.jl, such as real, integer, or binary. ``` ```APIDOC ## Function: Convex.vartype(variable) ### Description Returns the `VarType` of a given `variable`. ### Parameters - `variable`: The variable whose type is to be determined. ``` ```APIDOC ## Function: Convex.vartype!(variable, type) ### Description Sets the `VarType` of a `variable` to `type`. This function is primarily for internal use. ### Parameters - `variable`: The variable to modify. - `type`: The `VarType` to assign. ``` -------------------------------- ### Stateless Breadth-First Traversal Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/advanced.md Iterate through the nodes of a tree using `AbstractTrees.StatelessBFS`, visiting all nodes at a given level before moving to the next level. This provides a level-by-level exploration of the tree. ```julia for (i, node) in enumerate(AbstractTrees.StatelessBFS(p)) println("Here's node $i via StatelessBFS: $(summary(node))") end ``` -------------------------------- ### Element-wise `*` Operator (`.*`) Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Element-wise multiplication of two abstract expressions, leveraging Julia's broadcasting capabilities. ```APIDOC ## `.*` ### Description Element-wise multiplication of two abstract expressions. ### Method `Base.Broadcast.broadcasted(::typeof(*), ::Convex.AbstractExpr, ::Convex.AbstractExpr)` ``` -------------------------------- ### `-` Operator (Unary and Binary) Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Supports both unary negation of an abstract expression and binary subtraction between two abstract expressions. ```APIDOC ## `-` ### Description Supports unary negation and binary subtraction of abstract expressions. ### Method `Base.:-(::Convex.AbstractExpr)` `Base.:-(::Convex.AbstractExpr, ::Convex.AbstractExpr)` ``` -------------------------------- ### Element-wise `^` Operator (`.^`) Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Element-wise exponentiation of an abstract expression by an integer, utilizing broadcasting. ```APIDOC ## `.^` ### Description Element-wise exponentiation of an abstract expression by an integer. ### Method `Base.Broadcast.broadcasted(::typeof(^), ::Convex.AbstractExpr, ::Int)` ``` -------------------------------- ### trace_logm Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the trace of the matrix logarithm of an expression. ```APIDOC ## `trace_logm` ### Description Computes the trace of the matrix logarithm of an expression. ### Signature ```julia Convex.trace_logm( ::Convex.AbstractExpr, ::Union{AbstractMatrix,Convex.Constant}, ::Integer = 3, ::Integer = 3, ) ``` ``` -------------------------------- ### Invalid Formulation for Maximization Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/introduction/dcp.md This snippet illustrates an invalid extended formulation for a maximization problem. Attempting to use the same reformulation as for minimization leads to a DCPViolationError because the extended formulation is not valid for maximization. ```julia using Convex, SCS x = Variable(); t = Variable(); model_max_extended = maximize(t, [x >= 1, x <= 2, t >= x, t >= -x]); solve!(model_max_extended, SCS.Optimizer; silent = true) ``` -------------------------------- ### Dot Product Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the dot product of two abstract expressions. ```julia ```@docs Convex.dot(::Convex.AbstractExpr, ::Convex.AbstractExpr) ``` ``` -------------------------------- ### trace_mpower Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the trace of a matrix power of an expression. ```APIDOC ## `trace_mpower` ### Description Computes the trace of a matrix power of an expression. ### Signature ```julia Convex.trace_mpower( ::Convex.AbstractExpr, ::Rational, ::Union{AbstractMatrix,Convex.Constant}, ) ``` ``` -------------------------------- ### Dot Product with Sorting Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the dot product of two abstract expressions, with an option to sort the terms. ```julia ```@docs Convex.dotsort(::Convex.AbstractExpr, ::Convex.Value) ``` ``` -------------------------------- ### Basic Maximization Problem (Non-DCP) Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/introduction/dcp.md A maximization problem using the absolute value function that is not DCP compliant. Convex.jl will report 'false' for 'problem is DCP' and throw an error if solved. ```julia using Convex x = Variable(); model_max = maximize(abs(x), [x >= 1, x <= 2]) ``` -------------------------------- ### Diagonal Matrix Construction Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Constructs a diagonal matrix from an abstract expression representing the diagonal elements. ```julia ```@docs Convex.diagm(::Convex.AbstractExpr) ``` ``` -------------------------------- ### Iterate Over Tree Leaves Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/advanced.md Use `AbstractTrees.Leaves` to iterate over all the leaf nodes of a Convex.jl problem structure. Requires importing `Convex` and `AbstractTrees`. ```julia using Convex, AbstractTrees x = Variable() p = maximize( log(x), x >= 1, x <= 3 ) for leaf in AbstractTrees.Leaves(p) println("Here's a leaf: $(summary(leaf))") end ``` -------------------------------- ### `+` Operator Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Addition of two abstract expressions. Supports composition rules for convex and affine expressions. ```APIDOC ## `+` ### Description Addition of two abstract expressions. ### Method `Base.:+(::Convex.AbstractExpr, ::Convex.AbstractExpr)` ``` -------------------------------- ### log_perspective Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the log-perspective function of an expression. ```APIDOC ## `log_perspective` ### Description Computes the log-perspective function of an expression. This is useful for modeling functions that are convex in a perspective-like manner. ### Method `Convex.log_perspective(::Convex.AbstractExpr, ::Convex.AbstractExpr)` ``` -------------------------------- ### partialtrace Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the partial trace of a quantum state represented by an expression. Requires specifying the subsystem to trace over. ```APIDOC ## `partialtrace` ### Description Computes the partial trace of a quantum state. ### Signature ```julia Convex.partialtrace(x, ::Int, ::Vector) ``` ``` -------------------------------- ### Indexing and Slicing in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Supports indexing and slicing of matrices and vectors. ```julia x[1:4, 2:3] ``` -------------------------------- ### Addition of Expressions Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Supports element-wise addition of two abstract expressions. ```julia ```@docs Base.:+(::Convex.AbstractExpr, ::Convex.AbstractExpr) ``` ``` -------------------------------- ### File Operations Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Function for writing problem data to a file. ```APIDOC ## Function: Convex.write_to_file(problem, filename) ### Description Writes the representation of the `problem` to the specified `filename`. This can be useful for debugging or sharing problem formulations. ### Parameters - `problem`: The Convex.jl problem to write. - `filename`: The path to the file where the problem will be saved. ``` -------------------------------- ### `*` Operator Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Multiplication of two abstract expressions. This operation is fundamental for building more complex expressions in convex optimization. ```APIDOC ## `*` ### Description Multiplication of two abstract expressions. ### Method `Base.:*(::Convex.AbstractExpr, ::Convex.AbstractExpr)` ``` -------------------------------- ### log Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the elementwise natural logarithm of an expression. ```APIDOC ## `log` ### Description Computes the elementwise natural logarithm of an expression. ### Method `Base.log(::Convex.AbstractExpr)` ``` -------------------------------- ### Use Custom ProbabilityVector Type in Optimization Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/advanced.md Demonstrates constructing and using the custom `ProbabilityVector` type within a Convex.jl optimization problem, including solving and evaluating the result. ```julia using SCS p = ProbabilityVector(3) prob = minimize(p([1.0, 2.0, 3.0])) solve!(prob, SCS.Optimizer; silent = false); evaluate(p) ``` -------------------------------- ### Declare Scalar, Vector, and Matrix Variables Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/types.md Declare variables with specified dimensions. Use `Variable()` for a scalar, `Variable(n)` for an n-dimensional vector, and `Variable(m, n)` for an m x n matrix. ```julia x = Variable() ``` ```julia x = Variable(5) ``` ```julia x = Variable(4, 6) ``` -------------------------------- ### logsumexp Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the log-sum-exp of an expression. ```APIDOC ## `logsumexp` ### Description Computes the log-sum-exp of an expression. This is numerically stable for sums of exponentials. ### Method `Convex.logsumexp(::Convex.AbstractExpr)` ``` -------------------------------- ### tr Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the trace of an abstract expression. ```APIDOC ## `tr` ### Description Computes the trace of an abstract expression. ### Signature ```julia Convex.tr(::Convex.AbstractExpr) ``` ``` -------------------------------- ### real Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Extracts the real part of an abstract expression. ```APIDOC ## `real` ### Description Extracts the real part of an abstract expression. ### Signature ```julia Base.real(::Convex.AbstractExpr) ``` ``` -------------------------------- ### quantum_entropy Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the quantum entropy of a quantum state. Requires specifying dimensions. ```APIDOC ## `quantum_entropy` ### Description Computes the quantum entropy of a quantum state. ### Signature ```julia Convex.quantum_entropy(::Convex.AbstractExpr, ::Integer = 3, ::Integer = 3) ``` ``` -------------------------------- ### Constructing Diagonal Matrix in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Constructs a diagonal matrix from a vector. The input must be a vector. ```julia diagm(x) ``` -------------------------------- ### Solve Problem Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Solves the optimization problem. This function attempts to find the optimal values for the variables. ```julia Convex.solve! ``` -------------------------------- ### quadform Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Represents a quadratic form `x' * P * x` or `x' * P * y`. Used in quadratic programming. ```APIDOC ## `quadform` ### Description Represents a quadratic form. ### Signature ```julia Convex.quadform(::Convex.Value, ::Convex.AbstractExpr; kwargs...) ``` ``` -------------------------------- ### Define an Affine Negation Problem Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/developer/problem_depot.md Defines a simple convex optimization problem for testing the negation atom. It includes checks for vexity and optimal value, gated by a `test` flag. The problem is registered using `@add_problem`. ```julia @add_problem affine function affine_negate_atom(handle_problem!, ::Val{test}, atol, rtol, ::Type{T}) where {T, test} x = Variable() p = minimize(-x, [x <= 0]) if test @test vexity(p) == AffineVexity() end handle_problem!(p) if test @test p.optval ≈ 0 atol=atol rtol=rtol @test evaluate(-x) ≈ 0 atol=atol rtol=rtol end end ``` -------------------------------- ### invpos Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the elementwise positive inverse of an expression. ```APIDOC ## `invpos` ### Description Computes the elementwise positive inverse of an expression. This is equivalent to `1/x` for positive `x`. ### Method `Convex.invpos(::Convex.AbstractExpr)` ``` -------------------------------- ### sqrt Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Calculates the square root of an abstract expression. ```APIDOC ## `sqrt` ### Description Calculates the square root of an abstract expression. ### Signature ```julia Base.sqrt(::Convex.AbstractExpr) ``` ``` -------------------------------- ### Division of Expression by Value Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Supports element-wise division of an abstract expression by a concrete value. ```julia ```@docs Base.:/(::Convex.AbstractExpr, ::Convex.Value) ``` ``` -------------------------------- ### `diagm` Function Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Constructs a matrix with the elements of an abstract expression on the main diagonal and zeros elsewhere. ```APIDOC ## `diagm` ### Description Constructs a matrix with the elements of an abstract expression on the main diagonal. ### Method `Convex.diagm(::Convex.AbstractExpr)` ``` -------------------------------- ### logdet Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the logarithm of the determinant of a positive definite matrix expression. ```APIDOC ## `logdet` ### Description Computes the logarithm of the determinant of a positive definite matrix expression. ### Method `Convex.logdet(::Convex.AbstractExpr)` ``` -------------------------------- ### Generate a Single Markdown File Source: https://github.com/jump-dev/convex.jl/blob/master/docs/README.md Use Literate.markdown to generate a markdown file. This function does not execute the code; Documenter.jl handles code execution. ```julia fix_math_md(content) = replace(content, r"\$\$(.*?)\$\$"s => s"```math\1```") Literate.markdown(file_path, output_directory; preprocess = fix_math_md) ``` -------------------------------- ### Declare Variables with Special Properties Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/types.md Declare variables with constraints such as elementwise positivity, negativity, integrality, or binary nature. For matrices, `Semidefinite(n)` creates an n x n symmetric positive semidefinite matrix. ```julia x = Variable(4, Positive()) ``` ```julia x = Variable(4, Negative()) ``` ```julia x = Variable(4, IntVar) ``` ```julia x = Variable(4, BinVar) ``` ```julia z = Semidefinite(4) ``` -------------------------------- ### transpose Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the transpose of an abstract expression. ```APIDOC ## `transpose` ### Description Computes the transpose of an abstract expression. ### Signature ```julia Convex.transpose(::Convex.AbstractExpr) ``` ``` -------------------------------- ### min Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Element-wise minimum of two expressions. Useful for defining constraints or objectives involving minimum values. ```APIDOC ## `min` ### Description Element-wise minimum of two expressions. ### Signature ```julia Base.min(::Convex.AbstractExpr, ::Convex.AbstractExpr) ``` ``` -------------------------------- ### `dotsort` Function Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Sorts the elements of an abstract expression for use in dot products, often related to specific optimization formulations. ```APIDOC ## `dotsort` ### Description Sorts the elements of an abstract expression for use in dot products. ### Method `Convex.dotsort(::Convex.AbstractExpr, ::Convex.Value)` ``` -------------------------------- ### Multiplication of Expressions Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Supports element-wise multiplication of two abstract expressions. ```julia ```@docs Base.:*(::Convex.AbstractExpr, ::Convex.AbstractExpr) ``` ``` -------------------------------- ### eigmin Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the minimum eigenvalue of a matrix expression. ```APIDOC ## `eigmin` ### Description Computes the minimum eigenvalue of a matrix expression. ### Method `Convex.eigmin(::Convex.AbstractExpr)` ``` -------------------------------- ### lieb_ando Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the Lieb-Ando trace inequality term. ```APIDOC ## `lieb_ando` ### Description Computes the Lieb-Ando trace inequality term. ### Method `Convex.lieb_ando( ::Convex.AbstractExpr, ::Convex.AbstractExpr, ::Union{AbstractMatrix,Convex.Constant}, ::Rational, )` ``` -------------------------------- ### Solve a Convex.jl Problem Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/types.md Solve a defined Convex.jl problem using the `solve!` function, passing the problem object and a solver (e.g., `SCS.Optimizer()`). ```julia solve!(problem, solver) ``` -------------------------------- ### quadoverlin Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Represents a quadratic expression divided by a linear expression. Used in fractional programming. ```APIDOC ## `quadoverlin` ### Description Represents a quadratic expression divided by a linear expression. ### Signature ```julia Convex.quadoverlin(::Convex.AbstractExpr, ::Convex.AbstractExpr) ``` ``` -------------------------------- ### Define a Probability Vector Helper Function Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/advanced.md Create a helper function to define a probability vector variable, automatically enforcing non-negativity and sum-to-one constraints. ```julia using Convex function probability_vector(d::Int) x = Variable(d, Positive()) add_constraint!(x, sum(x) == 1) return x end ``` -------------------------------- ### rationalnorm Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Calculates the rational norm of an abstract expression. ```APIDOC ## `rationalnorm` ### Description Calculates the rational norm of an abstract expression. ### Signature ```julia Convex.rationalnorm(::Convex.AbstractExpr, ::Rational{Int}) ``` ``` -------------------------------- ### Sum of k Smallest Elements in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Calculates the sum of the k smallest elements in a vector or matrix. ```julia sumsmallest(x, k) ``` -------------------------------- ### Broadcasted Power Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Supports broadcasted element-wise exponentiation of an abstract expression to an integer power. ```julia ```@docs Base.Broadcast.broadcasted(::typeof(^), ::Convex.AbstractExpr, ::Int) ``` ``` -------------------------------- ### Kronecker Product in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Computes the Kronecker product of two matrices. Requires one argument to be constant. ```julia kron(x,y) ``` -------------------------------- ### Stacking Vectors Horizontally or Vertically in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Stacks two vectors or matrices horizontally ([x y]) or vertically ([x; y]). ```julia [x y] ``` ```julia [x; y] ``` ```julia hcat(x, y) ``` ```julia vcat(x, y) ``` -------------------------------- ### sumsmallest Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Sums the smallest elements of an abstract expression. ```APIDOC ## `sumsmallest` ### Description Sums the smallest elements of an abstract expression. ### Signature ```julia Convex.sumsmallest(::Convex.AbstractExpr, ::Int) ``` ``` -------------------------------- ### relative_entropy Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the relative entropy between two abstract expressions. ```APIDOC ## `relative_entropy` ### Description Computes the relative entropy between two abstract expressions. ### Signature ```julia Convex.relative_entropy(::Convex.AbstractExpr, ::Convex.AbstractExpr) ``` ``` -------------------------------- ### Convert to Conic Form Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Converts the current problem representation into its conic form. This is an in-place operation. ```julia Convex.conic_form! ``` -------------------------------- ### `/` Operator Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Division of an abstract expression by a constant value. This operation is defined for specific types to maintain convexity properties. ```APIDOC ## `/` ### Description Division of an abstract expression by a constant value. ### Method `Base.:/(::Convex.AbstractExpr, ::Convex.Value)` ``` -------------------------------- ### `abs` Function Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the absolute value of an abstract expression. This is a common function in optimization problems. ```APIDOC ## `abs` ### Description Computes the absolute value of an abstract expression. ### Method `Base.abs(::Convex.AbstractExpr)` ``` -------------------------------- ### exp Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the elementwise exponential of an expression. ```APIDOC ## `exp` ### Description Computes the elementwise exponential of an expression. ### Method `Base.exp(::Convex.AbstractExpr)` ``` -------------------------------- ### Subtraction of Expressions Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Supports element-wise subtraction of abstract expressions. Can be unary or binary. ```julia ```@docs Base.:-(::Convex.AbstractExpr) Base.:-(::Convex.AbstractExpr, ::Convex.AbstractExpr) ``` ``` -------------------------------- ### Summation of Matrix Elements in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Computes the sum of all elements in a matrix. ```julia sum(x) ``` -------------------------------- ### minimum Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the minimum value of an expression. Can be used for objectives or constraints related to the minimum element. ```APIDOC ## `minimum` ### Description Computes the minimum value of an expression. ### Signature ```julia Base.minimum(::Convex.AbstractExpr) ``` ``` -------------------------------- ### Conic Form Conversion Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Functions for converting problems into their conic form for specific solvers. ```APIDOC ## Function: Convex.conic_form!(problem, conic_problem_type) ### Description Converts the given `problem` into its conic form, suitable for solvers that operate on conic representations. This function modifies the problem in place. ### Parameters - `problem`: The Convex.jl problem to convert. - `conic_problem_type`: The desired type of conic form. ``` ```APIDOC ## Function: Convex.new_conic_form!(problem) ### Description Creates a new conic form representation of the `problem`. This is an alternative to in-place conversion. ### Parameters - `problem`: The Convex.jl problem for which to create a conic form. ``` -------------------------------- ### Trace of a Matrix in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Computes the trace of a square matrix. ```julia tr(x) ``` -------------------------------- ### entropy Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the Shannon entropy of a vector or matrix expression. ```APIDOC ## `entropy` ### Description Computes the Shannon entropy of a vector or matrix expression. ### Method `Convex.entropy(::Convex.AbstractExpr)` ``` -------------------------------- ### sigmamax Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the maximum singular value of an abstract expression. ```APIDOC ## `sigmamax` ### Description Computes the maximum singular value of an abstract expression. ### Signature ```julia Convex.sigmamax(::Convex.AbstractExpr) ``` ``` -------------------------------- ### Elementwise Division in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Represents elementwise division. Requires one argument to be a constant. ```julia x ./ y ``` -------------------------------- ### `dot` Function Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the dot product of two abstract expressions (vectors or matrices). A fundamental operation in linear algebra and optimization. ```APIDOC ## `dot` ### Description Computes the dot product of two abstract expressions. ### Method `Convex.dot(::Convex.AbstractExpr, ::Convex.AbstractExpr)` ``` -------------------------------- ### BibTeX Citation for Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/README.md Provides the BibTeX citation for the Convex.jl package, suitable for academic publications. ```bibtex @article{convexjl, title = {Convex Optimization in {J}ulia}, author = {Udell, Madeleine and Mohan, Karanveer and Zeng, David and Hong, Jenny and Diamond, Steven and Boyd, Stephen}, year = {2014}, journal = {SC14 Workshop on High Performance Technical Computing in Dynamic Languages}, archivePrefix = "arXiv", eprint = {1410.4821}, primaryClass = "math-oc", } ``` -------------------------------- ### Dot Product in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Computes the dot product of two vectors. Requires one argument to be constant. ```julia dot(x,y) ``` -------------------------------- ### Broadcasted Multiplication Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Supports broadcasted element-wise multiplication of two abstract expressions. ```julia ```@docs Base.Broadcast.broadcasted(::typeof(*), ::Convex.AbstractExpr, ::Convex.AbstractExpr) ``` ``` -------------------------------- ### Matrix Transpose in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Computes the transpose of a matrix. ```julia x' ``` -------------------------------- ### Dot Product of Sorted Vectors in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Computes the dot product of two vectors after sorting them. Requires one argument to be constant. ```julia dotsort(a, b) ``` -------------------------------- ### vec Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Converts an abstract expression into a column vector. ```APIDOC ## `vec` ### Description Converts an abstract expression into a column vector. ### Signature ```julia Base.vec(::Convex.AbstractExpr) ``` ``` -------------------------------- ### pos Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Positive part of an expression, defined as `max(x, 0)`. Useful for constraints involving non-negativity. ```APIDOC ## `pos` ### Description Positive part of an expression, defined as `max(x, 0)`. ### Signature ```julia Convex.pos(::Convex.AbstractExpr) ``` ``` -------------------------------- ### Create New Conic Form Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/api.md Creates a new conic form representation of the problem. This operation does not modify the original problem. ```julia Convex.new_conic_form! ``` -------------------------------- ### Broadcasted Division Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Supports broadcasted element-wise division of an abstract expression by a concrete value. ```julia ```@docs Base.Broadcast.broadcasted(::typeof(/), ::Convex.AbstractExpr, ::Convex.Value) ``` ``` -------------------------------- ### sum Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Calculates the sum of elements in an abstract expression, optionally along specified dimensions. ```APIDOC ## `sum` ### Description Calculates the sum of elements in an abstract expression, optionally along specified dimensions. ### Signature ```julia Base.sum(::Convex.AbstractExpr; dims = :) ``` ``` -------------------------------- ### Adjoint of Expression Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the adjoint (conjugate transpose) of an abstract expression. ```julia ```@docs Convex.adjoint(::Convex.AbstractExpr) ``` ``` -------------------------------- ### square Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Squares an abstract expression. ```APIDOC ## `square` ### Description Squares an abstract expression. ### Signature ```julia Convex.square(::Convex.AbstractExpr) ``` ``` -------------------------------- ### reshape Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Reshapes an abstract expression into a specified number of rows and columns. ```APIDOC ## `reshape` ### Description Reshapes an abstract expression into a specified number of rows and columns. ### Signature ```julia Base.reshape(::Convex.AbstractExpr, ::Int, ::Int) ``` ``` -------------------------------- ### Extracting Diagonal in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Extracts the k-th diagonal of a matrix. ```julia diag(x, k) ``` -------------------------------- ### matrixfrac Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Represents a matrix fractional linear expression. Used in optimization problems involving matrix variables. ```APIDOC ## `matrixfrac` ### Description Represents a matrix fractional linear expression. ### Signature ```julia Convex.matrixfrac(::Convex.AbstractExpr, ::Convex.AbstractExpr) ``` ``` -------------------------------- ### Addition in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Represents the addition of two expressions. ```julia x + y ``` ```julia x .+ y ``` -------------------------------- ### quantum_relative_entropy Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the quantum relative entropy between two quantum states. Requires specifying dimensions. ```APIDOC ## `quantum_relative_entropy` ### Description Computes the quantum relative entropy between two quantum states. ### Signature ```julia Convex.quantum_relative_entropy( ::Convex.AbstractExpr, ::Convex.AbstractExpr, ::Integer = 3, ::Integer = 3, ) ``` ``` -------------------------------- ### norm2 Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the 2-norm (Euclidean norm) of an expression. Equivalent to `norm(x, 2)`. ```APIDOC ## `norm2` ### Description Computes the 2-norm (Euclidean norm) of an expression. ### Signature ```julia Convex.norm2(::Convex.AbstractExpr) ``` ``` -------------------------------- ### Reshape Matrix in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Reshapes a matrix into dimensions m x n. ```julia reshape(x, m, n) ``` -------------------------------- ### Division in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Represents division. The denominator must be a scalar constant. ```julia x / y ``` -------------------------------- ### Vector Representation in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Converts a matrix into its vector representation. ```julia vec(x) ``` -------------------------------- ### entropy_elementwise Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the elementwise entropy of a vector or matrix expression. ```APIDOC ## `entropy_elementwise` ### Description Computes the elementwise entropy of a vector or matrix expression. ### Method `Convex.entropy_elementwise(::Convex.AbstractExpr)` ``` -------------------------------- ### logisticloss Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/reference/atoms.md Computes the logistic loss for a given expression. ```APIDOC ## `logisticloss` ### Description Computes the logistic loss for a given expression. This is often used in binary classification problems. ### Method `Convex.logisticloss(::Convex.AbstractExpr)` ``` -------------------------------- ### Multiplication in Convex.jl Source: https://github.com/jump-dev/convex.jl/blob/master/docs/src/manual/operations.md Represents multiplication. Requires one argument to be a constant. ```julia x * y ```