Commit 9ec15822 authored by Michael Keller's avatar Michael Keller
Browse files

Mom Notes

parent 586d52a2
...@@ -116,7 +116,7 @@ results in an upper bound of $1624$. ...@@ -116,7 +116,7 @@ results in an upper bound of $1624$.
\section{LP bound} \section{LP bound}
We can also use the solution to the We can also use the solution to the
following Linear Program as a bound. following linear program as a bound.
The variables are all of the possible The variables are all of the possible
crop pairings: crop pairings:
\begin{align*} \begin{align*}
...@@ -151,7 +151,7 @@ total relationships between pixels: ...@@ -151,7 +151,7 @@ total relationships between pixels:
\begin{align*} \begin{align*}
\sum_{x_i \in x} 2 \cdot x_i = \text{Basic Bound} \sum_{x_i \in x} 2 \cdot x_i = \text{Basic Bound}
\end{align*} \end{align*}
as well as that we don't plant too much of a as well as that we do not plant too much of a
specific crop. Here we simply enforce an upper bound specific crop. Here we simply enforce an upper bound
on the number of possible connections a crop could have: on the number of possible connections a crop could have:
\begin{align*} \begin{align*}
...@@ -161,9 +161,9 @@ on the number of possible connections a crop could have: ...@@ -161,9 +161,9 @@ on the number of possible connections a crop could have:
As an optimal solution for a pixel farming problem As an optimal solution for a pixel farming problem
meets these constraints, this is a valid bound. It should meets these constraints, this is a valid bound. It should
be noted that this bound does not enforce any constraints be noted that this bound does not enforce any constraints
on the shape of the field, or indeed that this score on the shape of the field or that this score
is achievable with only one field (and not multiple disjoint is achievable with only one field (and not multiple disjoint
fields). fields).
The bound for the first benchmark problem is $950$, for The bound for the first benchmark problem is $950$ and for
the second benchmark problem $1624$. the second benchmark problem $1624$.
\ No newline at end of file
\chapter{Computational Difficulty} \chapter{Computational Difficulty}
We show that the problem of finding a We prove that the problem of finding a
solution of a certain quality to a pixel solution of a certain quality to a pixel
farming problem is NP complete. farming problem is NP complete.
To do this we will first formulate the problem as To do this we will first formulate the problem as
a decision problem. In a second step we will a decision problem. In a second step we will
show that the problem is in NP. Lastly we will show that the problem is in NP. Lastly we will
prove that pixel farming can be used to find prove that pixel farming can be used to find
hamiltonian paths, which will imply that finding Hamiltonian Paths, which will imply that finding
solutions for pixel farming is NP complete. solutions for pixel farming is NP complete.
\section{The decision version of pixel farming} \section{The decision version of pixel farming}
The decision version of the pixel farming We define the decision version of the pixel farming
problem we define very similarly to the problem very similarly to the
regular version. However, instead of asking regular version. However, instead of asking
for a field with the maximum score, we ask for a field with the maximum score, we ask
for a field with a score at least $s$. Formally: for a field with a score of at least $s$. Formally:
Does a field $F$ for relation function $R$ exist Does a field $F$ for relation function $R$ exist
such that the score $S(F, R)$ is at least $s$: such that the score $S(F, R)$ is at least $s$:
\begin{displaymath} \begin{displaymath}
s \leq S(F, R) s \leq S(F, R)
\end{displaymath} \end{displaymath}
\section{Pixel Farming is NP complete} \section{Pixel Farming is NP Complete}
Now that we have defined the decision version of Now that we have defined the decision version of
the problem, we formulate and prove the following the problem, we formulate and prove the following
...@@ -35,11 +35,11 @@ theorem: ...@@ -35,11 +35,11 @@ theorem:
\begin{proof} \begin{proof}
First we non-deterministically select First, we non-deterministically select
a field $F$ for a given relation a field $F$ for a given relation
function $R$. By computing the score $S(F, R)$, which function $R$. By computing the score $S(F, R)$, which
can be done in Polynomial time in relation to the field can be done in polynomial time in relation to the field
size $X \cdot Y$, we can easily test is the score size $X \cdot Y$, we can easily test wether the score
is at least a certain value. Further, testing whether is at least a certain value. Further, testing whether
our field $F$ meets the requirements specified by $D$, our field $F$ meets the requirements specified by $D$,
our probability distribution specifying how much of our probability distribution specifying how much of
...@@ -51,15 +51,15 @@ size $X \cdot Y$ and number of crops $C$. ...@@ -51,15 +51,15 @@ size $X \cdot Y$ and number of crops $C$.
It is known that finding Hamiltonian Paths is NP It is known that finding Hamiltonian Paths is NP
complete \cite[Page 199, GT39]{alma990005774300205503}. complete \cite[Page 199, GT39]{alma990005774300205503}.
Thus, reducing the decision version Thus, reducing the decision version
of hamiltonian paths (explained below) to the decision of Hamiltonian Paths (explained below) to the decision
version of pixel farming demonstrates that pixel version of pixel farming demonstrates that pixel
farming is NP complete. farming is NP complete.
\paragraph{Hamiltonian Paths} \paragraph{Hamiltonian Paths}
Let $G = (V, E)$ be an undirected graph. We formulate the Let $G = (V, E)$ be an undirected graph. We formulate the
decision version of the hamiltonian path problem as follows: decision version of the Hamiltonian Path problem as follows:
Does there exist a path that visits every vertex Does a path that visits every vertex
in the graph exactly once? in the graph exactly once exist?
\paragraph{Reduction} We assume we are given an undirected \paragraph{Reduction} We assume we are given an undirected
graph $G$ and a polynomial time algorithm in $X \cdot Y$ graph $G$ and a polynomial time algorithm in $X \cdot Y$
...@@ -119,12 +119,12 @@ of crops $C$. Now we pass the pixel farming problem formulated ...@@ -119,12 +119,12 @@ of crops $C$. Now we pass the pixel farming problem formulated
above to our algorithm above to our algorithm
that solves the decision version of the pixel farming problem. that solves the decision version of the pixel farming problem.
If we get the answer that no solution If we get the answer that no solution
with value at least $s$ exists, we return that no longest path of with value at least $s$ exists, we conclude that no longest path of
length $\abs{V} - 1$ exists. If on the other hand a solution length $\abs{V} - 1$ exists. If, on the other hand, a solution
of at least $s$ exists, we return that a hamiltonian path of at least $s$ exists, we know that a hamiltonian path
must exist in $G$. must exist in $G$.
The rationale for this is as follows. Let us assume The rationale for this is as follows: Let us assume
a solution of value at least $s$ exists. This would a solution of value at least $s$ exists. This would
imply that every pixel likes all of their neighbors. imply that every pixel likes all of their neighbors.
As "crop $a$ likes crop $b$" is the same function as As "crop $a$ likes crop $b$" is the same function as
...@@ -134,7 +134,7 @@ know that every crop can only appear once in our field and all crops ...@@ -134,7 +134,7 @@ know that every crop can only appear once in our field and all crops
have two neighbors (except the ends) we must have found a have two neighbors (except the ends) we must have found a
path of length $\abs{V} - 1$. path of length $\abs{V} - 1$.
If on the other hand no arrangement of value at least $s$ If, on the other hand, no arrangement of value at least $s$
exists, there must be at least one index $i$ for all fields $F$ exists, there must be at least one index $i$ for all fields $F$
where $R(F_{1, i}, F_{1, i+1}) = 0$. What this translates where $R(F_{1, i}, F_{1, i+1}) = 0$. What this translates
to for our longest path problem is that every order to for our longest path problem is that every order
...@@ -143,103 +143,103 @@ hence no path of length $\abs{V} - 1$ can exist. ...@@ -143,103 +143,103 @@ hence no path of length $\abs{V} - 1$ can exist.
As we now know that pixel farming is in NP and NP-hard, As we now know that pixel farming is in NP and NP-hard,
we can conclude that pixel farming must be NP-complete. we can conclude that pixel farming must be NP-complete.
\section{Fractional Pixel Farming is NP Complete}
We consider the slightly modified version of the
standard pixel farming decision problem. Instead of allowing
a pixel to only contain a single crop,
a pixel may now contain multiple crops, as explained
in the problem definition section. One might suspect that
such a relaxation might enable us to formulate a
convex optimization problem. We show however that
this relaxation is also NP complete.
We define the decision version of fractional pixel farming
analogously to the standard version: Does a field $F'$
for a relation function $R$ exist such that the score
$S(F', R)$ is at least $s$:
\begin{align*}
s \leq S(F', R)
\end{align*}
\begin{theorem}
The fractional pixel farming problem (decision version) is NP complete.
\end{theorem}
\begin{proof}
The problem is obviously in NP, as we can non-deterministically
choose a field $F'$ for a given score function
$R$ and calculate the
score in polynomial time in relation to the size of the
field and number of crops. In a next step we verify
that the solution meets the requirement for crop
distribution given to us. This can also be done in
polynomial time relational to field size and number
of crop types. Finally we test if the score $S(F', R)$
is at least $s$.
For the proof of NP Hardness we again reduce to the
hamiltonian paths problem as in the proof that
regular pixel farming is NP complete. For this
purpose we define the constructed pixel farming
problem for a given graph $G = (V, E)$ as follows:
\begin{align*}
X &= \abs{V} && Y = 1\\
\Cps &= V && R(a, b) = \begin{cases}
1 & \{a, b\} \in E\\
0 & otherwise.
\end{cases}\\
s &= 2 \cdot (\abs{V} - 1) && D(c) = \frac{1}{\abs{V}} \quad \forall c \in \Cps\\
F' &\in R_+^{C \times X \times Y}
\end{align*}
We show that
the following implications hold:
\begin{enumerate}
\item There exists no optimal fractional solution to
the constructed pixel farming problem $\implies$
There exists no Hamiltonian path in $G$
\item There exists an optimal fractional
solution to the constructed pixel farming problem
$\implies$ There exists a Hamiltonian path in $G$
\end{enumerate}
\end{proof} \end{proof}
The first implication is obviously true. We prove this indirectly, % \section{Fractional Pixel Farming is NP Complete}
that is we show that: ``There exists a hamiltonian path in $G$'' % We consider the slightly modified version of the
$\implies$ ``There exists an optimal fractional solution to the % standard pixel farming decision problem. Instead of allowing
constructed pixel farming problem''. This statement is a % a pixel to only contain a single crop,
direct consequence of the NP completeness proof for the standard % a pixel may now contain multiple crops, as explained
pixel farming problem. If a Hamiltonian path exists, then % in the problem definition section. One might suspect that
an optimal solution for the standard pixel farming problem % such a relaxation might enable us to formulate a
instance exists. As this standard solution can also be % convex optimization problem. We show however that
viewed as an optimal fractional solution ($1$'s and $0$'s % this relaxation is also NP complete.
are fractions too) we are done.
% We define the decision version of fractional pixel farming
The second implication we prove by directly. % analogously to the standard version: Does a field $F'$
We assume that there exists an optimal solution to the % for a relation function $R$ exist such that the score
constructed pixel farming problem for a % $S(F', R)$ is at least $s$:
Graph $G$. An optimal % \begin{align*}
solution in our case means that every crop likes % s \leq S(F', R)
all of the crops in its neighborhood, otherwise % \end{align*}
the solution would not obtain the maximal
possible score $s$. Further there must also % \begin{theorem}
exist a sequence of crops such that: % The fractional pixel farming problem (decision version) is NP complete.
\FloatBarrier % \end{theorem}
\begin{enumerate}
\item The sequence only contains each crop exactly once % \begin{proof}
\item Every pixel along the proposed sequence of crops contains some of the proposed crop % The problem is obviously in NP, as we can non-deterministically
\end{enumerate} % choose a field $F'$ for a given score function
\FloatBarrier % $R$ and calculate the
If these two facts did not hold, then there must % score in polynomial time in relation to the size of the
exist a crop within our valid solution that is contained % field and number of crops. In a next step we verify
less than once, which would mean our solution is invalid. % that the solution meets the requirement for crop
% distribution given to us. This can also be done in
TODO: MAKE MORE FORMAL % polynomial time relative to field size and number
% of crop types. Finally, we test if the score $S(F', R)$
As a sequence of all crops where every crop % is at least $s$.
likes its neighbors corresponds to $G$
containing a hamiltonian path, we know % For the proof of NP Hardness we again reduce to the
our statement must be true. % Hamiltonian Paths problem as in the proof that
\end{proof} % regular pixel farming is NP complete. For this
\ No newline at end of file % purpose we define the constructed pixel farming
% problem for a given graph $G = (V, E)$ as follows:
% \begin{align*}
% X &= \abs{V} && Y = 1\\
% \Cps &= V && R(a, b) = \begin{cases}
% 1 & \{a, b\} \in E\\
% 0 & otherwise.
% \end{cases}\\
% s &= 2 \cdot (\abs{V} - 1) && D(c) = \frac{1}{\abs{V}} \quad \forall c \in \Cps\\
% F' &\in R_+^{C \times X \times Y}
% \end{align*}
% We show that
% the following implications hold:
% \begin{enumerate}
% \item There exists no optimal fractional solution to
% the constructed pixel farming problem $\implies$
% There exists no Hamiltonian path in $G$
% \item There exists an optimal fractional
% solution to the constructed pixel farming problem
% $\implies$ There exists a Hamiltonian path in $G$
% \end{enumerate}
%
% The first implication is obviously true. We prove this indirectly,
% that is we show that: ``There exists a hamiltonian path in $G$''
% $\implies$ ``There exists an optimal fractional solution to the
% constructed pixel farming problem''. This statement is a
% direct consequence of the NP completeness proof for the standard
% pixel farming problem. If a Hamiltonian path exists, then
% an optimal solution for the standard pixel farming problem
% instance exists. As this standard solution can also be
% viewed as an optimal fractional solution ($1$'s and $0$'s
% are fractions too) we are done.
% The second implication we prove by directly.
% We assume that there exists an optimal solution to the
% constructed pixel farming problem for a
% Graph $G$. An optimal
% solution in our case means that every crop likes
% all of the crops in its neighborhood, otherwise
% the solution would not obtain the maximal
% possible score $s$. Further there must also
% exist a sequence of crops such that:
% \FloatBarrier
% \begin{enumerate}
% \item The sequence only contains each crop exactly once
% \item Every pixel along the proposed sequence of crops contains some of the proposed crop
% \end{enumerate}
% \FloatBarrier
% If these two facts did not hold, then there must
% exist a crop within our valid solution that is contained
% less than once, which would mean our solution is invalid.
% TODO: MAKE MORE FORMAL
% As a sequence of all crops where every crop
% likes its neighbors corresponds to $G$
% containing a hamiltonian path, we know
% our statement must be true.
% \end{proof}
\ No newline at end of file
...@@ -179,7 +179,7 @@ on large fields and requires no conditions of $R$. ...@@ -179,7 +179,7 @@ on large fields and requires no conditions of $R$.
\begin{proof} \begin{proof}
The key insight for this statement is that the The key insight for this statement is that the
score function changes linearly when swapping score function changes linearly when swapping
crops between non-neighboring pixels. Picture crops between non-neighboring pixels. Imagine
two non-neighboring pixels that both contain two non-neighboring pixels that both contain
the crops $c_1$ and $c_2$: the crops $c_1$ and $c_2$:
\FloatBarrier \FloatBarrier
...@@ -191,7 +191,7 @@ on large fields and requires no conditions of $R$. ...@@ -191,7 +191,7 @@ on large fields and requires no conditions of $R$.
\node[main node] (2) [right of=1] {V}; \node[main node] (2) [right of=1] {V};
\path[every node/.style={font=\sffamily\small}] \path[every node/.style={font=\sffamily\small}]
(1) edge[bend left] node [above] {$\lambda \cdot c_1$} (2); (1) edge[bend left] node [above] {$\lambda \cdot c_1$} (2)
(2) edge[bend left] node [below] {$\lambda \cdot c_2$} (1); (2) edge[bend left] node [below] {$\lambda \cdot c_2$} (1);
\end{tikzpicture} \end{tikzpicture}
\end{figure} \end{figure}
...@@ -207,8 +207,9 @@ on large fields and requires no conditions of $R$. ...@@ -207,8 +207,9 @@ on large fields and requires no conditions of $R$.
swap like this, we eliminate at least one crop swap like this, we eliminate at least one crop
from at least one fractional pixel. from at least one fractional pixel.
Next we argue that for this result it is not necessary Next we argue that it is not necessary
to swap between neighboring pixels. Consider the field to swap between neighboring pixels for this result.
Consider the field
below. If we only swap between pixels that have below. If we only swap between pixels that have
the same color, then we never have to swap between the same color, then we never have to swap between
neighboring pixels. It is always possible to color neighboring pixels. It is always possible to color
...@@ -228,10 +229,9 @@ on large fields and requires no conditions of $R$. ...@@ -228,10 +229,9 @@ on large fields and requires no conditions of $R$.
\end{figure} \end{figure}
\FloatBarrier \FloatBarrier
Further we argue that iterating this method terminates. Further, we argue that iterating this method terminates.
While there exist While pixels of the same color that both contain the same two
pixels of the same color that both contain the same two crops exist, we perform the swap as outlined above. Eventually,
crops, we perform the swap as outlined above. Eventually,
because we get rid of at least one fractional crop every time because we get rid of at least one fractional crop every time
we swap, we must reach a state for a pixel color where we swap, we must reach a state for a pixel color where
no two pixels contain two of the same crop. Because no two pixels contain two of the same crop. Because
...@@ -242,7 +242,7 @@ on large fields and requires no conditions of $R$. ...@@ -242,7 +242,7 @@ on large fields and requires no conditions of $R$.
means in the worst case there are up to $\binom{C}{2}$ means in the worst case there are up to $\binom{C}{2}$
pixels that each contain two crops. All other pixels pixels that each contain two crops. All other pixels
must now contain exactly one unit of one crop. Because must now contain exactly one unit of one crop. Because
there are four colors among which we swap, this means there are four colors among which we swap,
in the worst case we end up with $4 \cdot \binom{C}{2}$ in the worst case we end up with $4 \cdot \binom{C}{2}$
pixels that are still fractional. pixels that are still fractional.
\end{proof} \end{proof}
...@@ -253,7 +253,7 @@ on large fields and requires no conditions of $R$. ...@@ -253,7 +253,7 @@ on large fields and requires no conditions of $R$.
There might be situations where up to $4 \cdot \binom{C}{2}$ There might be situations where up to $4 \cdot \binom{C}{2}$
still fractional pixels are unacceptable. This might be the still fractional pixels are unacceptable. This might be the
case in relatively small fields with relatively large amounts case in relatively small fields with relatively large amounts
of different crops. Here the following slightly stronger of different crops. Here the following, slightly stronger,
statement with a condition on $R$ might be helpful: statement with a condition on $R$ might be helpful:
\begin{theorem} \begin{theorem}
...@@ -272,7 +272,7 @@ statement with a condition on $R$ might be helpful: ...@@ -272,7 +272,7 @@ statement with a condition on $R$ might be helpful:
that we allow swapping of crops between neighboring that we allow swapping of crops between neighboring
pixels. pixels.
We now need to know what condition needs to be We now need to know what condition must be
met to ensure that swapping in either direction met to ensure that swapping in either direction
even among neighboring pixels is never detrimental. even among neighboring pixels is never detrimental.
...@@ -327,12 +327,12 @@ statement with a condition on $R$ might be helpful: ...@@ -327,12 +327,12 @@ statement with a condition on $R$ might be helpful:
\sum_{c_j \in \Cps \setminus \{c_\alpha, c_\beta \}} \sum_{c_j \in \Cps \setminus \{c_\alpha, c_\beta \}}
R(c_i, c_j) \cdot (u'_i \cdot v'_{j} - u_i \cdot v_{j})\\ R(c_i, c_j) \cdot (u'_i \cdot v'_{j} - u_i \cdot v_{j})\\
\end{align*} \end{align*}
We can now use that: We can now utilize that:
\begin{align*} \begin{align*}
u'_\alpha &= u_\alpha - \lambda & v'_\alpha &= v_\alpha + \lambda\\ u'_\alpha &= u_\alpha - \lambda & v'_\alpha &= v_\alpha + \lambda\\
u'_\beta &= u_\beta + \lambda & v'_\beta &= v_\beta - \lambda\\ u'_\beta &= u_\beta + \lambda & v'_\beta &= v_\beta - \lambda\\
\end{align*} \end{align*}
Which gives us: which gives us:
\begin{align*} \begin{align*}
&\sum_{c_i \in \Cps} \sum_{c_j \in \Cps} R(c_i, c_j) \cdot (u'_i \cdot v'_{j} - u_i \cdot v_{j})\\ &\sum_{c_i \in \Cps} \sum_{c_j \in \Cps} R(c_i, c_j) \cdot (u'_i \cdot v'_{j} - u_i \cdot v_{j})\\
&= \sum_{c_i \in \{c_\alpha, c_\beta \}} &= \sum_{c_i \in \{c_\alpha, c_\beta \}}
...@@ -348,7 +348,7 @@ statement with a condition on $R$ might be helpful: ...@@ -348,7 +348,7 @@ statement with a condition on $R$ might be helpful:
\sum_{c_j \in \Cps \setminus \{c_\alpha, c_\beta \}} \sum_{c_j \in \Cps \setminus \{c_\alpha, c_\beta \}}
R(c_i, c_j) \cdot (u_i \cdot v_{j} - u_i \cdot v_{j}) R(c_i, c_j) \cdot (u_i \cdot v_{j} - u_i \cdot v_{j})
\end{align*} \end{align*}
Where the last term is simply $0$ and the second where the last term is simply $0$ and the second
and third terms are linear functions in $\lambda$. and third terms are linear functions in $\lambda$.
We again focus only on the quadratic term: We again focus only on the quadratic term:
\begin{align*} \begin{align*}
...@@ -374,7 +374,7 @@ statement with a condition on $R$ might be helpful: ...@@ -374,7 +374,7 @@ statement with a condition on $R$ might be helpful:
&+ \lambda \cdot (R(c_\beta, c_\beta) - R(c_\alpha, c_\beta)) \cdot v_\beta &+ \lambda \cdot (R(c_\beta, c_\beta) - R(c_\alpha, c_\beta)) \cdot v_\beta
\end{align*} \end{align*}
Of special note here is the quadratic term. Of special note here is the quadratic term.
If every crop likes all other crops If every crop likes all the other crops
at least as much as it likes itself, at least as much as it likes itself,
then the quadratic term is positive. The quadratic then the quadratic term is positive. The quadratic
term being positive means we can always swap term being positive means we can always swap
...@@ -382,7 +382,7 @@ statement with a condition on $R$ might be helpful: ...@@ -382,7 +382,7 @@ statement with a condition on $R$ might be helpful:
the score getting worse. The optimal swap the score getting worse. The optimal swap
direction is determined by all of the linear direction is determined by all of the linear
functions in $\lambda$ we put to the side functions in $\lambda$ we put to the side
throughout this proof. Therefore throughout this proof. Therefore,
a relationship function $R$ fulfilling a relationship function $R$ fulfilling
$R(c_i, c_j) \geq R(c_i, c_i)$ ensures there is $R(c_i, c_j) \geq R(c_i, c_i)$ ensures there is
always a good way to swap crops among always a good way to swap crops among
...@@ -391,7 +391,8 @@ statement with a condition on $R$ might be helpful: ...@@ -391,7 +391,8 @@ statement with a condition on $R$ might be helpful:
Being allowed to swap even amongst neighboring Being allowed to swap even amongst neighboring
pixels allows us to disregard the pattern pixels allows us to disregard the pattern
structure we had for the standard swapping method structure we had for the standard swapping method
and we can by the same reasoning conclude and we can, by the same reasoning, conclude
that this new method has after termination that this new method has
at most $\binom{C}{2}$ still fractional pixels. at most $\binom{C}{2}$ still fractional pixels
after terminating.
\end{proof} \end{proof}
\ No newline at end of file
...@@ -20,8 +20,8 @@ the following scenario of three non-neighboring pixels: ...@@ -20,8 +20,8 @@ the following scenario of three non-neighboring pixels:
\FloatBarrier \FloatBarrier
Using only swaps involving two pixels will always Using only swaps involving two pixels will always
lead to a pixel containing a crop it strongly dislikes lead to a pixel containing a crop it strongly dislikes
based on it's neighborhood. Instead, swapping between based on its neighborhood. Instead, swapping between
three pixels as seen below leads to every pixel containing three pixels, as seen below, leads to every pixel containing
their preferred crop: their preferred crop:
\FloatBarrier \FloatBarrier
\begin{figure}[h] \begin{figure}[h]
...@@ -33,17 +33,17 @@ their preferred crop: ...@@ -33,17 +33,17 @@ their preferred crop:
\node[main node] (2) [right of=hidden] {V}; \node[main node] (2) [right of=hidden] {V};
\node[main node] (3) [above of=hidden] {W}; \node[main node] (3) [above of=hidden] {W};
\path[every node/.style={font=\sffamily\small}]; \path[every node/.style={font=\sffamily\small}]
(1) edge[left] node [above] {$b$} (2); (1) edge[left] node [above] {$b$} (2)
(2) edge[left] node [above] {$c$} (3); (2) edge[left] node [above] {$c$} (3)
(3) edge[right] node [above] {$a$} (1); (3) edge[right] node [above] {$a$} (1);
\end{tikzpicture} \end{tikzpicture}
\end{figure} \end{figure}
\FloatBarrier \FloatBarrier
The question is how we find such a multi-way swap. The question is how we find such a multi-way swap.
If we allowed swapping between neighboring pixels this would If we allowed swapping between neighboring pixels, this would
indeed be tricky. If instead we restrict ourselves to only indeed be tricky. If instead we restrict ourselves to only
swapping between non-neighboring pixels however, then the score swapping between non-neighboring pixels, then the score
function changes only linearly and we can use linear programming function changes only linearly and we can use linear programming
to find the optimal swap. Let the following linear program to find the optimal swap. Let the following linear program
be defined as the swap LP. be defined as the swap LP.
...@@ -65,7 +65,7 @@ is planted within the pixel: ...@@ -65,7 +65,7 @@ is planted within the pixel:
\end{align*} \end{align*}
And the function we are trying to maximize shows And the function we are trying to maximize shows
for every variable in $x$ how good it would be for every variable in $x$ how good it would be
based on the pixels neighborhood to plant that crop based on the pixel's neighborhood to plant that crop
there: there:
\begin{align*} \begin{align*}
c &= \begin{bmatrix} c &= \begin{bmatrix}
...@@ -81,10 +81,10 @@ there: ...@@ -81,10 +81,10 @@ there:
Then we are trying to maximize the function $c^T x$ Then we are trying to maximize the function $c^T x$
subject to the constraints that: subject to the constraints that:
\begin{enumerate} \begin{enumerate}
\item We don't allow less than $0$ or more than $1$ of each crop to \item we don't allow less than $0$ or more than $1$ of each crop to
be planted in a pixel be planted in a pixel
\item Every Pixel must contain a total amount of crops equaling $1$ \item every Pixel must contain a total amount of crops equaling $1$
\item The amount of each crop in $x$ before the swap and \item the amount of each crop in $x$ before the swap and
in $x^*$ after the swap must be the same in $x^*$ after the swap must be the same
\end{enumerate} \end{enumerate}
or formally, a solution $x^*$ must satisfy: or formally, a solution $x^*$ must satisfy:
...@@ -97,7 +97,7 @@ or formally, a solution $x^*$ must satisfy: ...@@ -97,7 +97,7 @@ or formally, a solution $x^*$ must satisfy:
In theory an optimal solution to this linear program In theory an optimal solution to this linear program
could result in fractional amounts of crop being could result in fractional amounts of crop being
planted in a pixel. However, the following theorems planted in a pixel. However, the following theorems
demonstrates that there is always an optimal integer solution. demonstrate that there is always an optimal integer solution.