Skip to content
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
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

madvorak
Copy link
Collaborator

@madvorak madvorak commented Feb 1, 2024


Zulip discussion:
https://leanprover.zulipchat.com/#narrow/stream/144837-PR-reviews/topic/.237386.20Linear.20Programming

Four PRs incompatible with each other:
#7386 (list of constraints)
#9693 (matrix form)
#10026 (Antoine Chambert-Loir's def; semirings, linear)
#10159 (Antoine Chambert-Loir's def; rings, affine)

Open in Gitpod

@madvorak madvorak added the WIP Work in progress label Feb 1, 2024
@madvorak madvorak added RFC Request for comment and removed WIP Work in progress labels Feb 1, 2024
Comment on lines +22 to +25
/-- Linear map -/
linmap : M →ᵃ[R] N
/-- Right-hand side -/
upper : N
Copy link
Member

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 of linmap.

Copy link
Collaborator Author

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:

/-- Typically `M` is `ℝ^m` and `N` is `ℝ^n` -/
structure LinearProgram (R V M N : Type*) [OrderedRing R]
    [AddCommGroup V] [Module R V] [AddTorsor V M]
    [AddCommGroup N] [Module R N]
    where
  /-- Affine map -/
  themap : M →ᵃ[R] N
  /-- Objective function -/
  objective : M →ᵃ[R] R
  /-- Cone defines nonnegative elements -/
  cone : PointedCone R N

variable {R V W M N : Type*} [OrderedRing R]
    [AddCommGroup V] [Module R V] [AddTorsor V M]
    [AddCommGroup N] [Module R N]

/-- `LP.primal = { x : M | LP.themap x ≤ LP.upper }` -/
def LinearProgram.primal (LP : LinearProgram R V M N) :=
  { x : M | -LP.themap x ∈ LP.cone }

/-- `LP.dual = { g : N →ᵃ[R] R | LP.objective = g ∘ LP.themap ∧ ∀ a, ∀ b, a ≤ b → g a ≤ g b }` -/
def LinearProgram.dual (LP : LinearProgram R V M N) :=
  { g : N →ᵃ[R] R | LP.objective = g ∘ LP.themap ∧
      ∀ a : N, ∀ b : N, (b -ᵥ a) ∈ LP.cone → g a ≤ g b }

-- From here on, we will need more assumptions than currently written

theorem LinearProgram.weakDuality (LP : LinearProgram R V M N)
    {c : M} (hc : c ∈ LP.primal) {d : N →ᵃ[R] R} (hd : d ∈ LP.dual) :
    LP.objective c ≤ d 0 := by
  simp_all [LinearProgram.primal, LinearProgram.dual]

Since we are maximizing in the primal, the feasibility condition ends up being { x : M | -LP.themap x ∈ LP.cone }, which is ugly af.

Copy link
Collaborator Author

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.

Comment on lines 17 to 21
/-- Typically `M` is `ℝ^m` and `N` is `ℝ^n` -/
structure LinearProgram (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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original suggestion was only that M should be affine, not N. I don't really understand what N is (you didn't write any documentation!), but M is natural space in which the problem is set up, which may as well be affine

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am familiar with finite-dimensional setting. In finite-dimensional setting, where LP is typically represented by a matrix, my M represents variables and my N represents conditions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me personally, modelling LP in my head is easier in terms of "searching for a vector" than "searching for a point". I understand that "searching for a point" has certain appeal and I am therefore willing to rephrase the definitions to the affine setting; however, if M should be be affine, I will make N affine as well, so that the dual of LP is still kinda LP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Request for comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants