-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linear programming according to Antoine Chambert-Loir's book — affine version #10159
Open
madvorak
wants to merge
5
commits into
master
Choose a base branch
from
lpantoineaffine
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+83
−0
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/- | ||
Copyright (c) 2023 Martin Dvorak. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Martin Dvorak, Antoine Chambert-Loir | ||
-/ | ||
import Mathlib.Analysis.Convex.Cone.Pointed | ||
import Mathlib.Algebra.Order.Group.Defs | ||
|
||
/-! | ||
|
||
# Linear programming | ||
|
||
TODO | ||
|
||
-/ | ||
|
||
/-- Typically `M` is `ℝ^m` and `N` is `ℝ^n` -/ | ||
structure ConeProgram (R V W M N : Type*) [OrderedRing R] | ||
[AddCommGroup V] [Module R V] [AddTorsor V M] | ||
[AddCommGroup W] [Module R W] [AddTorsor W N] | ||
where | ||
/-- Linear map -/ | ||
linmap : M →ᵃ[R] N | ||
/-- Right-hand side -/ | ||
upper : N | ||
/-- Objective function -/ | ||
objective : M →ᵃ[R] R | ||
/-- Cone defines nonnegative elements -/ | ||
cone : PointedCone R W | ||
|
||
abbrev LinearProgram {R V W M N : Type*} [OrderedRing R] | ||
[AddCommGroup V] [Module R V] [AddTorsor V M] | ||
[OrderedAddCommGroup W] [Module R W] [OrderedSMul R W] [AddTorsor W N] | ||
(l : M →ᵃ[R] N) (u : N) (o : M →ᵃ[R] R) := | ||
ConeProgram.mk l u o (PointedCone.positive R W) | ||
|
||
variable {R V W M N : Type*} [OrderedRing R] | ||
[AddCommGroup V] [Module R V] [AddTorsor V M] | ||
[AddCommGroup W] [Module R W] [AddTorsor W N] | ||
|
||
/-- `LP.primal = { x : M | LP.linmap x ≤ LP.upper }` -/ | ||
def ConeProgram.primal (LP : ConeProgram R V W M N) := | ||
{ x : M | LP.upper -ᵥ LP.linmap x ∈ LP.cone } | ||
|
||
/-- `LP.dual = { g : N →ᵃ[R] R | LP.objective = g ∘ LP.linmap ∧ ∀ a, ∀ b, a ≤ b → g a ≤ g b }` -/ | ||
def ConeProgram.dual (LP : ConeProgram R V W M N) := | ||
{ g : N →ᵃ[R] R | LP.objective = g ∘ LP.linmap ∧ | ||
∀ a : N, ∀ b : N, (b -ᵥ a) ∈ LP.cone → g a ≤ g b } | ||
|
||
-- From here on, we will need more assumptions than currently written | ||
|
||
theorem ConeProgram.weakDuality (LP : ConeProgram R V W M N) | ||
{c : M} (hc : c ∈ LP.primal) {d : N →ᵃ[R] R} (hd : d ∈ LP.dual) : | ||
LP.objective c ≤ d LP.upper := by | ||
simp_all [ConeProgram.primal, ConeProgram.dual] | ||
|
||
/-- Theorem 1.4.1.a, TODO we probably need more assumptions (finite-dimensional `M` and `N` ?) -/ | ||
theorem ConeProgram.strongDuality (LP : ConeProgram R V W M N) | ||
(hC : LP.primal.Nonempty) (hD : LP.dual.Nonempty) : | ||
∃ c ∈ LP.primal, ∃ d ∈ LP.dual, LP.objective c = d LP.upper := | ||
sorry | ||
|
||
/-- Theorem 1.4.1.b (TODO maybe add item (iii), which is easy, | ||
and item (iv), which holds when `N` is `ℝ^n` and `LP.cone` is the positive ortant) -/ | ||
theorem ConeProgram.min_max (LP : ConeProgram R V W M N) | ||
{c : M} (hc : c ∈ LP.primal) {d : N →ᵃ[R] R} (hd : d ∈ LP.dual) (hs : LP.cone.FG) : | ||
-- TODO maybe `hs` is not needed | ||
(∀ x ∈ LP.primal, LP.objective x ≤ LP.objective c) ∧ (∀ g ∈ LP.dual, d LP.upper ≤ g LP.upper) ↔ | ||
LP.objective c = d LP.upper := | ||
sorry | ||
|
||
/-- Theorem 1.4.1.c(1) -/ | ||
theorem ConeProgram.empty_dual (LP : ConeProgram R V W M N) | ||
(hC : LP.primal.Nonempty) (hD : LP.dual = ∅) : | ||
∀ r : R, ∃ d ∈ LP.dual, d LP.upper < r := | ||
sorry | ||
|
||
/-- Theorem 1.4.1.c(2) -/ | ||
theorem ConeProgram.empty_primal (LP : ConeProgram R V W M N) | ||
(hC : LP.primal = ∅) (hD : LP.dual.Nonempty) : | ||
∀ r : R, ∃ c ∈ LP.primal, r < LP.objective c := | ||
sorry |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need for
upper
here, the point of the affine refactor is that it becomes part oflinmap
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I refactored it to not use
upper
, it ended up looking very strange:Since we are maximizing in the primal, the feasibility condition ends up being
{ x : M | -LP.themap x ∈ LP.cone }
, which is ugly af.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you really want me to do it, I can flip the sign and proceed with this setting, but I am not happy about it, since we seemed to finally reached the consensus that Antoine Chambert-Loir's definition is the one we want to have in Mathlib.