start ILP post
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Implementation of a Simple Integer Program Solver"
|
title = "Implementation of a Basic Integer Linear Programming Solver"
|
||||||
date = 2022-04-02T00:00:00
|
date = 2022-04-02T00:00:00
|
||||||
lastmod = 2022-04-02T00:00:00
|
lastmod = 2022-04-02T00:00:00
|
||||||
draft = true
|
draft = true
|
||||||
@@ -61,8 +61,6 @@ categories = []
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
## Problem Formulation
|
|
||||||
|
|
||||||
Inline math: \\(\varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887…\\)
|
Inline math: \\(\varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887…\\)
|
||||||
|
|
||||||
Block math:
|
Block math:
|
||||||
@@ -71,8 +69,45 @@ $$
|
|||||||
\varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } }
|
\varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } }
|
||||||
$$
|
$$
|
||||||
|
|
||||||
|
## Problem Formulation
|
||||||
|
|
||||||
|
A [linear programming problem](https://en.wikipedia.org/wiki/Linear_programming) is an optimization problem with the following form:
|
||||||
|
|
||||||
|
find \\(\mathbf{x}\\) to maximize
|
||||||
|
$$
|
||||||
|
\mathbf{c}^T\mathbf{x}
|
||||||
|
$$
|
||||||
|
|
||||||
|
subject to
|
||||||
|
|
||||||
|
$$\begin{aligned}
|
||||||
|
A\mathbf{x} &\leq \mathbf{b} \cr
|
||||||
|
0 &\leq \mathbf{x} \cr
|
||||||
|
\end{aligned}$$
|
||||||
|
|
||||||
|
For [integer linear programming (ILP)](https://en.wikipedia.org/wiki/Integer_programming), there is one additional constrait:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\mathbf{x} \in \mathbb{Z}
|
||||||
|
$$
|
||||||
|
|
||||||
|
In plain english, \\(\mathbf{x}\\) is a vector, where each entry represents a variable we want to find the optimal value for.
|
||||||
|
\\(\mathbf{c}\\) is a vector with one weight for each entry of \\(\mathbf{x}\\).
|
||||||
|
We're trying to maximize the dot product \\(\mathbf{c}^T\mathbf{x}\\); we're just summing up each each entry of entry of \\(\mathbf{x}\\) weighted by the corresponding entry of \\(\mathbf{c}\\).
|
||||||
|
For example, if we seek to maximize the sum of the first two entries of \\(\mathbf{x}\\), the first two entries of \\(\mathbf{c}\\) will be \\(1\\) and the rest \\(0\\).
|
||||||
|
|
||||||
|
**What about Minimizing instead of Maximizing?**
|
||||||
|
Just maximize \\(-\mathbf{c}^T\mathbf{x}\\) instead of maximizing \\(\mathbf{c}^T\mathbf{x}\\).
|
||||||
|
|
||||||
|
**What if one of my variables needs to be negative?**
|
||||||
|
At first glance, it appears \\(0 \leq \mathbf{x}\\) will be a problem.
|
||||||
|
However, we'll just construct \\(A\\) and \\(\mathbf{b}\\) so that all constraints are relative to \\(-\mathbf{x}_i\\) instead of \\(\mathbf{x}_i\\) for variable \\(i\\).
|
||||||
|
|
||||||
## Linear Program Relaxation
|
## Linear Program Relaxation
|
||||||
|
|
||||||
|
The way this is usually done is actually by initially ignoring the integer constraint ( \\(\mathbf{x} \in \mathbb{Z}\\) ), then going back and "fixing" your non-integer solution.
|
||||||
|
When you ignore the integer constraint, you're doing what's called ["linear programming relaxation" (LP relaxation)](https://en.wikipedia.org/wiki/Linear_programming_relaxation).
|
||||||
|
|
||||||
## Branch and Bound
|
## Branch and Bound
|
||||||
|
|
||||||
## User-friendly Interface
|
## User-friendly Interface
|
||||||
Reference in New Issue
Block a user