-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: improved
README.md
and new demo
- Loading branch information
Showing
4 changed files
with
175 additions
and
36 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import CvxLean | ||
|
||
/-! | ||
Demo used to make a GIF for README.md. | ||
-/ | ||
|
||
noncomputable section README | ||
|
||
open CvxLean Minimization Real | ||
|
||
-- Define. | ||
|
||
def p := | ||
optimization (x y : ℝ) | ||
minimize -2 * x | ||
subject to | ||
c₁ : 0 ≤ x | ||
c₂ : 1 < y | ||
c₃ : log (y - 1) ≤ 2 * sqrt x + 1 | ||
c₄ : 3 * x + 5 * y ≤ 10 | ||
|
||
-- Transform (proving `p ≡ q`). | ||
|
||
equivalence* eqv/q : p := by | ||
change_of_variables! (v) (y ↦ v + 1) | ||
change_of_variables! (w) (v ↦ exp w) | ||
remove_constr c₂ => | ||
field_simp; arith | ||
-- Make DCP-compliant automatically: | ||
-- pre_dcp | ||
-- Or, manually: | ||
rw_constr c₃ into (w ≤ 2 * sqrt x + 1) => | ||
field_simp | ||
|
||
#print q | ||
|
||
#check eqv | ||
|
||
-- Solve (proving `q ≡ q.conicForm`). | ||
|
||
solve q | ||
|
||
#print q.conicForm | ||
|
||
#eval q.status | ||
#eval q.value | ||
#eval q.solution | ||
|
||
#eval eqv.backward_map q.solution | ||
|
||
end README |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters