Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
/playground
/scripts/evaluation/data
/plots
**/__pycache__/

/CvxLean/Command/Solve/Mosek/Path.lean
22 changes: 22 additions & 0 deletions CvxLean/Examples/CVXPY/Portfolio.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import CvxLean

noncomputable section

open CvxLean Minimization Real BigOperators

def portfolio_optimization :=
optimization (weights : Fin 3 → ℝ)
minimize (Vec.sum (weights ^ 2) : ℝ)
subject to
c1 : Vec.sum weights = 1
c2 : ∀ i, 0 ≤ weights i

-- Solve the problem directly (applies pre_dcp automatically)
solve portfolio_optimization

-- Check the results
#eval portfolio_optimization.status
#eval portfolio_optimization.solution
#eval portfolio_optimization.value

end
22 changes: 22 additions & 0 deletions CvxLean/Examples/CVXPY/Quadratic.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import CvxLean

noncomputable section

open CvxLean Minimization Real BigOperators

def quadratic_problem :=
optimization (x : ℝ)
minimize (((x + (-1))) ^ 2 : ℝ)
subject to
c1 : 0 ≤ x
c2 : x ≤ 2

-- Solve the problem directly (applies pre_dcp automatically)
solve quadratic_problem

-- Check the results
#eval quadratic_problem.status
#eval quadratic_problem.solution
#eval quadratic_problem.value

end
Loading