Update background section
This commit is contained in:
parent
8c6f4572e8
commit
29b31b2a09
@ -1,15 +1,15 @@
|
||||
% Problem parameters
|
||||
enum TOYS;@\Vlabel{line:back-knap-toys}@
|
||||
array[TOYS] of int: toy_joy;@\Vlabel{line:back-knap-joy}@
|
||||
array[TOYS] of int: toy_space;@\Vlabel{line:back-knap-space}@
|
||||
int: space_left;@\Vlabel{line:back-knap-left}@
|
||||
enum TOYS;@\Vlabel{line:back:knap:toys}@
|
||||
array[TOYS] of int: toy_joy;@\Vlabel{line:back:knap:joy}@
|
||||
array[TOYS] of int: toy_space;@\Vlabel{line:back:knap:space}@
|
||||
int: space_left;@\Vlabel{line:back:knap:left}@
|
||||
|
||||
% Decision variables
|
||||
var set of TOYS: selection;@\Vlabel{line:back-knap-sel}@
|
||||
var int: total_joy = sum(toy in selection)(toy_joy[toy]);@\Vlabel{line:back-knap-tj}@
|
||||
var set of TOYS: selection;@\Vlabel{line:back:knap:sel}@
|
||||
var int: total_joy = sum(toy in selection)(toy_joy[toy]);@\Vlabel{line:back:knap:tj}@
|
||||
|
||||
% Constraints
|
||||
constraint sum(toy in selection)(toy_space[toy]) < space_left;@\Vlabel{line:back-knap-con}@
|
||||
constraint sum(toy in selection)(toy_space[toy]) < space_left;@\Vlabel{line:back:knap:con}@
|
||||
|
||||
% Goal
|
||||
solve maximize total_joy;@\Vlabel{line:back-knap-obj}@
|
||||
solve maximize total_joy;@\Vlabel{line:back:knap:obj}@
|
||||
|
@ -82,6 +82,7 @@ style=apa,
|
||||
|
||||
\newcommand{\Vlabel}[1]{\label[line]{#1}\hypertarget{#1}{}}
|
||||
\newcommand{\lref}[1]{\hyperlink{#1}{\FancyVerbLineautorefname~\ref*{#1}}}
|
||||
\newcommand{\Lref}[1]{\hyperlink{#1}{\FancyVerbLineautorefname~\ref*{#1}}}
|
||||
\newcommand{\lrefrange}[2]{\FancyVerbLineautorefname{}s~\hyperlink{#1}{\ref*{#1}}--\hyperlink{#2}{\ref*{#2}}}
|
||||
\newcommand{\Lrefrange}[2]{Lines~\hyperlink{#1}{\ref*{#1}}--\hyperlink{#2}{\ref*{#2}}}
|
||||
|
||||
|
@ -130,20 +130,20 @@ Let us introduce the language by modelling the problem from
|
||||
\end{listing}
|
||||
|
||||
The model starts with the declaration of the \glspl{parameter}.
|
||||
\Lref{line:back-knap-toys} declares an enumerated type that represents all
|
||||
\Lref{line:back:knap:toys} declares an enumerated type that represents all
|
||||
possible toys, \(T\) in the mathematical model in the example.
|
||||
\Lref{line:back-knap-joy,line:back-knap-space} declare arrays mapping from toys
|
||||
\Lref{line:back:knap:joy,line:back:knap:space} declare arrays mapping from toys
|
||||
to integer values, these represent the functional mappings \(joy\) and
|
||||
\(space\). Finally, \lref{line:back-knap-left} declares an integer
|
||||
\(space\). Finally, \lref{line:back:knap:left} declares an integer
|
||||
\gls{parameter} to represent the car capacity as an equivalent to \(C\).
|
||||
|
||||
The model then declares its \glspl{variable}. \Lref{line:back-knap-sel} declares
|
||||
The model then declares its \glspl{variable}. \Lref{line:back:knap:sel} declares
|
||||
the main \gls{variable} \mzninline{selection}, which represents the selection of
|
||||
toys to be packed. \(S\) in our earlier model. We also declare the variable
|
||||
\mzninline{total_joy}, on \lref{line:back-knap-tj}, which is functionally
|
||||
\mzninline{total_joy}, on \lref{line:back:knap:tj}, which is functionally
|
||||
defined to be the summation of all the joy for the toy picked in our selection.
|
||||
|
||||
Finally, the model contains a constraint, on \lref{line:back-knap-con}, to
|
||||
Finally, the model contains a constraint, on \lref{line:back:knap:con}, to
|
||||
ensure we do not exceed the given capacity and states the goal for the solver:
|
||||
to maximise the value of the variable \mzninline{total_joy}.
|
||||
|
||||
@ -157,30 +157,30 @@ primitive constraints.
|
||||
Given the assignments
|
||||
|
||||
\begin{mzn}
|
||||
TOYS = {football, tennisball, stuffed_lama, stuffed_elephant};
|
||||
toy_joy = [63, 12, 50, 100];
|
||||
toy_space = [32, 8, 16, 40];
|
||||
space_left = 64;
|
||||
TOYS = {football, tennisball, stuffed_elephant};
|
||||
toy_joy = [63, 12, 100];
|
||||
toy_space = [32, 8, 40];
|
||||
space_left = 44;
|
||||
\end{mzn}
|
||||
|
||||
is the result of flattening for \mzninline{n=2}:
|
||||
the following model is the result of flattening:
|
||||
|
||||
\begin{mzn}
|
||||
var 1..2: x_1_1;
|
||||
var 1..2: x_1_2;
|
||||
var 1..2: x_2_1;
|
||||
var 1..2: x_2_2;
|
||||
constraint all_different([x_1_1, x_1_2]);
|
||||
constraint all_different([x_2_1, x_2_2]);
|
||||
constraint all_different([x_1_1, x_2_1]);
|
||||
constraint all_different([x_1_2, x_2_2]);
|
||||
var 0..1: selection_0;
|
||||
var 0..1: selection_1;
|
||||
var 0..1: selection_2;
|
||||
var 0..175: total_joy:: is_defined_var;
|
||||
constraint int_lin_le([32,8,40],[selection_0,selection_1,selection_2],44);
|
||||
constraint int_lin_eq([63,12,100,-1],[selection_0,selection_1,selection_2,total_joy],0):: defines_var(total_joy);
|
||||
solve maximize total_joy;
|
||||
\end{mzn}
|
||||
|
||||
This \emph{flat} problem will be passed to some \gls{solver}, which will attempt
|
||||
to determine an assignment to each decision variable \verb|x_i_j| that satisfies
|
||||
all constraints, or report that there is no such assignment.
|
||||
to determine an assignment to each decision variable \mzninline{solection_i} and
|
||||
\mzninline{total_joy} that satisfies all constraints and maximises
|
||||
\mzninline{total_joy}, or report that there is no such assignment.
|
||||
|
||||
\section{The current \glsentrytext{minizinc} interpreter}%
|
||||
\section{The Current \glsentrytext{minizinc} Interpreter}%
|
||||
\label{sec:back-mzn-interpreter}
|
||||
|
||||
\section{Other Constraint Modelling Languages}%
|
||||
@ -191,5 +191,3 @@ all constraints, or report that there is no such assignment.
|
||||
|
||||
\section{Constraint Logic Programming}%
|
||||
\label{sec:back-clp}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user