<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass{article}
\usepackage{fullpage,algorithmic,verbatim,graphicx,comment,hyperref,wasysym,tikz,enumitem}

\title{Introduction to Evolutionary Computing\\
        COMP 5970-002/6970-003/6976-V04 -- Auburn University\\
        Fall 2019 -- Assignment Series 1\\
        Evolutionary Algorithms for the Offline Cutting Stock Problem}
\author{Daniel R. Tauritz, Ph.D.}
\date{\today}

\begin{document}
\maketitle

\section*{Synopsis} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The goal of this assignment series is for you to become familiarized with (I) representing problems in mathematically precise terms, (II) implementing an Evolutionary Algorithm (EA) to solve a problem, (III) conducting scientific experiments involving EAs, (IV) statistically analyzing experimental results from stochastic algorithms, and (V) writing proper technical reports. 

The Cutting Stock Problem [\url{https://en.wikipedia.org/wiki/Cutting_stock_problem}], also known as the Offline 2D Bin Packing Problem, is an extremely important real-world industrial problem belonging to the NP-hard complexity class. Real-world applications include aerospace (for instance, at Boeing's Sheet Metal Fabrication Center), shipbuilding, VLSI design, and manufacturing of shoes, clothing and furniture. 

While highly efficient heuristics have been developed for several variations of the Cutting Stock Problem, particularly hard variations such as those involving irregular shapes have no known heuristics with low approximation ratios (the ratio between the generated solution quality and the optimum). Also, atypical variations sometimes require custom heuristics. One approach to address this is the use of a meta-heuristic such as an Evolutionary Algorithm to directly solve a given variation. Another approach is the use of a hyper-heuristic to automate the design of a custom heuristic. This assignment series takes the former approach.

These are individual assignments and plagiarism will not be tolerated. You must write your code from scratch in one of the approved programming languages. You are free to use libraries/toolboxes/etc, except search/optimization/EA specific ones.

\section*{General implementation requirements} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The specific variation of the Cutting Stock Problem tackled in this assignment is as follows: 
\begin{enumerate}
\item Assume a machine which can produce an arbitrary long sheet of material of a fixed width. 
\item A problem instance is specified by a positive integer indicating the fixed width, a positive integer indicating the number of shapes to be cut, and an indexed sequence of shapes which need to be cut from the material stock.
\item Each shape is specified as a finite sequence of grid moves.
\item Each move is specified as a direction (U - up, D - down, L - left, R - right) and a positive integer indicating the number of grid cells in a straight line to be added to the shape, starting from the end of the last move.
\item The objective is to minimize the length of the material needed in order to accommodate all the shapes provided.
\item The solution consists of an indexed sequence of ordered triplets $(x,y,r)$ containing coordinate pairs $(x,y)$ and clockwise 90 degree rotation multipliers ($r$) valued 0, 1, 2, or 3, where $(x,y)$ indicates the starting grid cell to cut the corresponding indexed shape, under the following constraints:
  \begin{enumerate}
  \item shapes cannot go off grid
  \item shapes cannot overlap
  \item the length of the material cut cannot exceed the sum of the greatest shape lengths, where greatest shape length is defined as the max of a shape's horizontal and vertical lengths
  \end{enumerate}
\end{enumerate}

\noindent The problem instance file format consists of a line containing the value of the fixed $width$ and the number of shapes, followed by one line per $shape$ containing space delimited $moves$. Here is an example:
\begin{verbatim}
5 2
R1 D1
D1 L4 R1 U3 R3
\end{verbatim}

\noindent The solution file format consists of lines where each line corresponds to a shape and contains a coordinate pair of the form $(x,y)$ where $x$ is the length offset and $y$ is the width offset, with the origin being bottom left, followed by a 0, 1, 2, or 3, indicating clockwise 90 degree rotation multipliers. Here are two solution file examples with accompanying grid visualization and fitness calculation for the previously given example problem instance:\\
\\
\textbf{Solution Example 1}\\
\\
Solution File
\begin{verbatim}
3,2,1
4,1,0
\end{verbatim}

\noindent Grid Visualization\\
\begin{tikzpicture}
\draw[step=1cm,gray,very thin] (0,0) grid (7,5);
\draw[thick,-&gt;] (0,0) -- (7,0) node[anchor=north west] {x axis};
\draw[thick,-&gt;] (0,0) -- (0,5) node[anchor=south east] {y axis};
\draw (0.5 cm, 1pt) -- (0.5 cm, -1pt) node[anchor=north] {0};
\draw (1.5 cm, 1pt) -- (1.5 cm, -1pt) node[anchor=north] {1};
\draw (2.5 cm, 1pt) -- (2.5 cm, -1pt) node[anchor=north] {2};
\draw (3.5 cm, 1pt) -- (3.5 cm, -1pt) node[anchor=north] {3};
\draw (4.5 cm, 1pt) -- (4.5 cm, -1pt) node[anchor=north] {4};
\draw (5.5 cm, 1pt) -- (5.5 cm, -1pt) node[anchor=north] {5};
\draw (6.5 cm, 1pt) -- (6.5 cm, -1pt) node[anchor=north] {6};
\draw (1pt, 0.5 cm) -- (-1pt,0.5 cm) node[anchor=east] {0};
\draw (1pt, 1.5 cm) -- (-1pt,1.5 cm) node[anchor=east] {1};
\draw (1pt, 2.5 cm) -- (-1pt,2.5 cm) node[anchor=east] {2};
\draw (1pt, 3.5 cm) -- (-1pt,3.5 cm) node[anchor=east] {3};
\draw (1pt, 4.5 cm) -- (-1pt,4.5 cm) node[anchor=east] {4};
\fill[blue!40!white] (4,3) rectangle (3,1);
\fill[blue!40!white] (3,1) rectangle (2,2);
\fill[green!40!white] (5,2) rectangle (4,0);
\fill[green!40!white] (4,0) rectangle (0,1);
\fill[green!40!white] (1,1) rectangle (2,4);
\fill[green!40!white] (2,4) rectangle (5,3);
\end{tikzpicture}\\
\\
Objective Value Calculation: length used = 5\\
Example Fitness Calculation: max length - length used = (max (5,4) + max(2,2)) - 5 = (5 + 2) - 5 = 7 - 5 = 2\\
\\
\textbf{Solution Example 2}\\
\\
Solution File
\begin{verbatim}
1,0,2
6,2,0
\end{verbatim}

\noindent Grid Visualization\\
\begin{tikzpicture}
\draw[step=1cm,gray,very thin] (0,0) grid (7,5);
\draw[thick,-&gt;] (0,0) -- (7,0) node[anchor=north west] {x axis};
\draw[thick,-&gt;] (0,0) -- (0,5) node[anchor=south east] {y axis};
\draw (0.5 cm, 1pt) -- (0.5 cm, -1pt) node[anchor=north] {0};
\draw (1.5 cm, 1pt) -- (1.5 cm, -1pt) node[anchor=north] {1};
\draw (2.5 cm, 1pt) -- (2.5 cm, -1pt) node[anchor=north] {2};
\draw (3.5 cm, 1pt) -- (3.5 cm, -1pt) node[anchor=north] {3};
\draw (4.5 cm, 1pt) -- (4.5 cm, -1pt) node[anchor=north] {4};
\draw (5.5 cm, 1pt) -- (5.5 cm, -1pt) node[anchor=north] {5};
\draw (6.5 cm, 1pt) -- (6.5 cm, -1pt) node[anchor=north] {6};
\draw (1pt, 0.5 cm) -- (-1pt,0.5 cm) node[anchor=east] {0};
\draw (1pt, 1.5 cm) -- (-1pt,1.5 cm) node[anchor=east] {1};
\draw (1pt, 2.5 cm) -- (-1pt,2.5 cm) node[anchor=east] {2};
\draw (1pt, 3.5 cm) -- (-1pt,3.5 cm) node[anchor=east] {3};
\draw (1pt, 4.5 cm) -- (-1pt,4.5 cm) node[anchor=east] {4};
\fill[blue!40!white] (2,1) rectangle (0,0);
\fill[blue!40!white] (0,1) rectangle (1,2);
\fill[green!40!white] (7,3) rectangle (6,1);
\fill[green!40!white] (6,1) rectangle (2,2);
\fill[green!40!white] (3,2) rectangle (4,5);
\fill[green!40!white] (4,5) rectangle (7,4);
\end{tikzpicture}\\
\\
Objective Value Calculation: length used = 7\\
Different Example Fitness Calculation: - length used = -7\\
\\
At minimum, you will be expected to have the following parameters configurable:
\begin{enumerate}
\item An indicator specifying whether the random number generator should be initialized based on time in microseconds or on a specified seed; in case of the latter, the config file should also define the seed for the random number generator (to allow your results to be reproduced)
\item  Search algorithm and all black-box search algorithm parameters (e.g., Random Search, EA)
\item The number of runs a single experiment consists of
\item The maximum number of fitness evaluations each run is allotted
\item The relative file path+name of the log file
\item The relative file path+name of the solution file
\end{enumerate}
Your config file should be human-readable with documentation on acceptable configuration values. This documentation may be placed in the README or in comments within the config file itself.\\

\noindent The log file should at minimum include:
\begin{enumerate}
\item The path of the problem instance files
\item The random number generator seed
\item The algorithm parameters (enough detail to recreate the config file from the log)
\item An algorithm specific result log (specified in the assignment specific section)
\end{enumerate}

The fitness of a solution must be proportional to the quality of the solution it encodes. Note that fitness per definition correlates higher values with better solutions. In case of a formulation as a minimization problem, you would need to transform the objective value to obtain the fitness value of the corresponding maximization problem.\\
\\
Solution files should consist of the best solution found in any run.\\


\section*{Version control requirements}
For each assignment you will be given a new repository on [\url{https://classroom.github.com}] \textbf{Please view your repository and the README.md} It may clear things up after reading this.

Included in your repository is a script named ``finalize.sh'', which you will use to indicate which version of your code is the one to be graded. When you are ready to submit your final version, run the command \texttt{./finalize.sh} from your local Git directory, then commit and push your code. This will create a text file, ``readyToSubmit.txt'', that is pre-populated with a known text message for grading purposes. You may commit and push as much as you want, but your submission will be confirmed as ``final'' if  ``readyToSubmit.txt'' exists and is populated with the text generated by ``finalize.sh'' at 10:00pm on the due date. If you do not plan to submit before the deadline, then you should NOT run the ``finalize.sh'' script until your final submission is ready. If you accidentally run ``finalize.sh'' before you are ready to submit, do not commit or push your repo and delete ``readyToSubmit.txt''. Once your final submission is ready, run ``finalize.sh'', commit and push your code, and do not make any further changes to it.

By each assignment deadline, the code currently pushed to Master will be pulled for grading. You are required to include a  \verb|run.sh| 
that needs to be configured to compile and run with the command \verb|./run.sh| using a problem file provided by the TAs and a configuration provided by you, passed in that order through the command line. Specifically, in order to run your submission and grade your output, all the TAs should have to do is execute \verb|./run.sh problem1 config|. The TAs should not have to worry about external dependencies. Any files created by your assignment must be created in the present working directory or subfolders in the present working directory.

\section*{Submissions, penalties, documents, and bonuses}
You may commit and push to your repository at anytime. At submission time, your latest, pushed, commit to the master branch will be graded (if there is one). In order to ensure that the correct version of your code will be used for grading, after pushing your code, visit [\url{https://github.com}] and verify that your files are present. If for any reason you submit late, then \textbf{please notify the TAs when you have submitted.} If you do submit late, then your first late submission will be graded.

The penalty for late submission is a 5\% deduction for the first 24 hour period and a 10\% deduction for every additional 24 hour period. So 1 hour late and 23 hours late both result in a 5\% deduction. 25 hours late results in a 15\% deduction, etc. Not following submission guidelines can be penalized for up to 5\%, which may be in addition to regular deduction due to not following the assignment guidelines.

Your code needs to compile/execute as submitted without syntax errors and without runtime errors. Grading will be based on what can be verified to work correctly as well as on the quality of your source code. You must follow the coding requirements as stated in the syllabus.

Documents are required to be in PDF format; you are encouraged to employ \LaTeX~for typesetting.

All four assignments in this series are weighted equally.

\section*{Deliverable Categories}
There are three deliverable categories, namely:
\begin{enumerate}[label=\alph*]
\item Required for all students in all sections.
\item Required for students in the 6000-level sections, bonus for the students in the 5000-level section.
\item Bonus for all students in all sections.
\end{enumerate}
Note that the max grade for the average of all assignments in Assignment Series 1, including bonus points, is capped at 100\%.

\newpage

%-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
\section*{Assignment 1a: Random Search}
Implement a random search algorithm to optimize the cut pattern for each of the problem instances provided.\\
\\
The result log should be headed by the label ``Result Log'' and consist of empty-line separated blocks of rows where each block is headed by a run label of the format ``Run $i$'' where $i$ indicates the run of the experiment and where each row is tab delimited in the form $&lt;$evals$&gt;&lt;$tab$&gt;&lt;$fitness$&gt;$ (not including the $&lt;$ and $&gt;$ symbols) where $&lt;$evals$&gt;$ indicates the number of evals executed so far and $&lt;$fitness$&gt;$ is the value of the fitness function at that number of evals. The first row has 1 as value for $&lt;$evals$&gt;$. Rows are only added if they improve on the best fitness value found so far that run. The solution file should consist of the best solution found during any run and be in the specified format. Log files and solution files should be placed in their respective directories, \emph{logs} and \emph{solutions}.

The deliverables of this assignment are:
\begin{description}
\item[a1] your source code, configured to compile and run with '\emph{./run.sh $&lt;$problem1-filepath$&gt;$ $&lt;$configuration-filepath$&gt;$}'  (including any necessary support files such as makefiles, project files, etc.).
\item[a2] for each problem instance, a configuration file configured for 1000 fitness evaluations, timer initialized random seed, and 30 runs, along with the corresponding log file and the corresponding solution file (these should go in the repo's \emph{logs} and \emph{solutions} directories).
\item[a3] a document headed by your name, AU E-mail address, and the string ``COMP x97y Fall 2019 Assignment 1a'', where $x$ and $y$ need to reflect the section you are enrolled in, containing for each provided problem instance, the evals versus fitness plot corresponding to your log file which produced the best solution.
\end{description}
Edit your README.md file to explain anything you feel necessary. Submit all files via GitHub, by \emph{pushing} your latest commit to the \emph{master} branch. The due date for this assignment is 10:00 PM on Sunday September 1, 2019.\\
\\
\textbf{Grading}\\
The point distribution is as follows: \\
\\
\begin{tabular}{l|l}
  Algorithmic                                             &amp; 30\% \\
  \hline Configuration files and parsing    &amp; 10\% \\
  \hline Logging and output/solution files &amp; 10\% \\
  \hline Good programming practices        &amp; 10\% \\
  \hline Document containing evals versus fitness plots &amp; 10\%\\
\end{tabular}

\newpage

%-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
\section*{Assignment 1b: Evolutionary Algorithm Search}
Implement a $(\mu+\lambda)$-EA with your choice of representation and associated variation operators, including at minimum one unary (i.e., mutation) and one multi-ary variation operator (i.e., recombination), to find the valid solution which optimizes the cut pattern for each of the problem instances provided. To avoid invalid solutions from entering the population, implement the following base approach:
\begin{itemize}
\item Initialize the start population with random valid solutions (randomly generated each run).
\item When recombining, check each gene selected for inheritance and if it causes invalidity, replace with a randomly generated allele which does not.
\item When mutating a gene, check the new mutated allele and if it causes invalidity, generate a new mutated allele; repeat until the new mutated allele does not cause invalidity.
\end{itemize}

\noindent You need to implement support for all of the following EA configurations, where operators with multiple options are comma separated:
\begin{description}
\item[Initialization] Uniform Random
\item[Parent Selection] Fitness Proportional Selection, $k$-Tournament Selection with replacement
\item[Survival Selection] Truncation, $k$-Tournament Selection without replacement
\item[Termination] Number of evals, no change in average population fitness for $n$ generations, no change in best fitness in population for $n$ generations
\end{description}
Your configuration file should allow you to select which of these configurations to use. Your configurable EA strategy parameters should include all those necessary to support your operators, such as:
\begin{itemize}
\item $\mu$
\item $\lambda$
\item tournament size for parent selection
\item tournament size for survival selection
\item mutation rate
\item number of evals till termination
\item $n$ for termination convergence criterion
\end{itemize}

The result log should be headed by the label ``Result Log'' and consist of empty-line separated blocks of rows where each block is headed by a run label of the format ``Run $i$'' where $i$ indicates the run of the experiment and where each row is tab delimited in the form $&lt;$evals$&gt;&lt;$tab$&gt;&lt;$average fitness$&gt;&lt;$tab$&gt;&lt;$best fitness$&gt;$ (not including the $&lt;$ and $&gt;$ symbols) where $&lt;$evals$&gt;$ indicates the number of evals executed so far, $&lt;$average fitness$&gt;$ is the average population fitness at that number of evals, and $&lt;$best fitness$&gt;$ is the fitness of the best individual in the population at that number of evals (so local best, not global best!). The first row has $&lt;\mu&gt;$ as value for $&lt;$evals$&gt;$. Rows are added after each generation, so after each $\lambda$ evaluations. The solution file should consist of the best solution found in any run.\\
\\
The deliverables of this assignment are:
\begin{description}
\item[a1] your source code (including any necessary support files such as makefiles, project files, etc.)
\item[a2] for each of the three provided problem instances, a configuration file configured for 10,000 fitness evaluations, a timer initialized random seed, 30 experimental runs, and the best EA configuration you can find, along with the corresponding log and solution files,
\item[a3] a document in PDF format headed by your name, AU E-mail address, and the string ``COMP x97y Fall 2019 Assignment 1b'', where $x$ and $y$ need to reflect the section you are enrolled in, containing:
    \begin{itemize}
    \item for each problem instance, a plot which simultaneously shows evals versus average local fitness and evals versus local best fitness, averaged over all runs; box plots are preferred,
    \item your statistical analysis for both experiments comparing the average final best random search result (note that in Assignment 1a you plotted the best run results as opposed to the average results) versus the average final best result you obtained in Assignment 1b (report said averages along with standard deviation, describe the test statistic you employed, and the appropriate analysis results for said test statistic).
    \end{itemize}
\item[b1] This deliverable is concerned with creating significantly different multi-ary and/or unary variation operators, and comparing the different combinations of variation operators, showing the results in tables and figures, as well as providing accompanying statistical analysis. Of particular interest is under which circumstances a particular combination of variation operators outperforms another combination, while underperforming on another. Statistical analysis followed by a brief discussion is needed. You also need to explain the design of your variation operators. Note that the provided three datasets may be insufficient to show the differences; therefore, we will also provide you with a problem instance generator to test many different kinds of problem instances.\\
This investigation needs to be documented in a separate section of the required document marked as ``Investigation of Variation Operators''. You also need to indicate in your source files any code which pertains to this investigation and additionally describe it in your README.md file. Basically, you need to make it as easy as possible for the TAs to see with a glance what part of your submission pertains to this investigation, and which doesn't. Students enrolled in COMP 5970 will earn up to 15\% bonus for the multi-ary part of this investigation, up to 15\% for the unary part of this investigation, or up to 25\% for both. Students enrolled in COMP 6970/6976 must do both and this will count for 25\% regular points (not bonus) beyond the A deliverables. 
\item[c1] Up to 15\% bonus points can be earned by implementing a true repair function in addition to the specified approach for generating valid solutions. You need to compare your repair function with the base approach, showing the results in tables and figures, as well as providing accompanying statistical analysis. Of particular interest is under which circumstances your repair function outperforms the base approach, while underperforming on another. Statistical analysis followed by a brief discussion is needed. Either way, you need to explain the design of your repair function. Note that the provided three datasets may be insufficient to show the differences; therefore, we will also provide you with a problem instance generator to test many different kinds of problem instances.\\
This bonus investigation needs to be documented in a separate section of the required document marked as ``True Repair Function''. You also need to indicate in your source files any code which pertains to this bonus and additionally describe it in your README.md file. Basically, you need to make it as easy as possible for the TAs to see with a glance what part of your submission pertains to this bonus, and which does not. 
\end{description}
Edit your README.md file to explain anything you feel necessary. Submit all files via GitHub, by \emph{pushing} your latest commit to the \emph{master} branch. The due date for this assignment is 10:00 PM on Sunday September 15, 2019.\\
\\
\textbf{Grading}\\
The point distribution per deliverable category is as follows: \\
\\
\begin{tabular}{l|l|l|l|}
  Assessment Rubric \ Deliverable Category &amp; A        &amp; B        &amp; C\\ \hline \hline  
  Algorithmic                                                  &amp; 50\% &amp; 35\% &amp; 35\%\\
  \hline Configuration files and parsing         &amp; 10\% &amp; 5\%   &amp; 5\%\\
  \hline Logging and output/solution files     &amp; 10\% &amp; 0\%   &amp; 0\%\\
  \hline Good programming practices            &amp; 10\% &amp; 10\% &amp; 10\%\\
  \hline Writing                                              &amp; 10\% &amp; 25\% &amp; 25\%\\
  \hline Statistical analysis                            &amp; 10\% &amp; 25\% &amp;25\%\\
\end{tabular}\\
\newpage

\end{document}</pre></body></html>