% -*- latex -*-
\documentclass[letter,12pt]{article}
%---------------------------------------------------------------
%\usepackage{listings}
\usepackage[framed]{matlab-prettifier}
\usepackage{color}
\usepackage{fullpage}
\usepackage{enumitem} % control over itemize, list environment
%---------------------------------------------------------------


\begin{document}
\newcommand{\hwtitle}[1]{%
	\begin{center}
		\Large  \bf Homework #1%
	\end{center}%
}

\newcommand{\mat}[1]{% matlab code
%{\color{blue}\texttt{#1}}%
	% this one does not work inside of captions
	{\lstinline[style = Matlab-editor, basicstyle = \mlttfamily, columns=fixed]!#1!}%
	% this one work but style is different
	%{\lstinline[columns=fixed]!#1!}%
}
%---------------------------------------------------------------
\newcommand{\problem}[1]{% homework problem
	%{\item  \bf #1%}
\item {\bf #1{}:}% the next blank line is important

}

\newenvironment{homework}[2]%
{%
	\hwtitle{#1}
	#2% Prerequisites

	\begin{enumerate}[
		label={\bf Problem\ \arabic*}, 
		leftmargin=0pt,
		start,
		labelindent=0pt,
		widest=20, align=left, itemindent=!
		]
}%
{%
	\end{enumerate}
}%

%---------------------------------------------------------------
\begin{homework}{08}{
%Prerequisites:

General comments: 
\begin{itemize}
	\item Do not forget to run some test cases. 
\end{itemize}
}

\problem{(5 points)}
%---------------------------------------------------------------
Modify the provided traveler salesman combinatorial algorithm to solve 
the slightly different problem. You are looking for the shortest route which
goes through all cities, while it starts and ends in the same city (the first
one), i.e. we need a close loop route. 

Coordinates of the cities are provided in the
\mat{'cities_for_combinatorial_search.dat'} file:
the first column  of
the data file corresponds to 'x' coordinates and the second one to 'y' coordinates.
The coordinates of the city where the route begins and ends  are in the first row.  

Provide your answers to the following questions:
\begin{itemize}
	\item 
		What is the sequence of all cities in the shortest route?
	\item
		What is the total length of the best route?
	\item
		Provide the plot with the visible cities location and the shortest route.
\end{itemize}


\problem{(10 points)}
%---------------------------------------------------------------
Implement the Metropolis algorithm to solve the above problem. A good way to obtain
a new test route is to randomly swap two cities  along the route.
You need to choose the number of cycles and initial and final  temperature
($kT$). Provide the reasons for your choices.

As a test, compare this algorithm solution  with the above combinatorial.

Now load the cities coordinates from the 
\mat{'cities_for_metropolis_search.dat'} file.  Find the shortest route for
this set of cities.

\begin{itemize}
	\item 
		What is the sequence of all cities in the shortest route?
	\item
		What is the total length of the best route?
	\item
		Provide the plot with the visible cities location and the shortest route.
\end{itemize}


\end{homework}
%---------------------------------------------------------------
\end{document}
%---------------------------------------------------------------
