<p>I'm adding an answer to show what sort of things I'm looking for. </p>

<p>An example of such a problem could be fitting coefficients for a polynomial​ function. We have a dataset of <code>(X,Y)</code>, and the highest power of the polynomial. Then a solution is a set of numbers (number of parameters is the highest power). </p>

<p>The <code>fitness</code> of a solution could be </p>

<pre><code>fitness := 1.0/(sum(dataset's Y - polynomial's Y, for each X in dataset))
</code></pre>

<p>This is an introductory genetic algorithm to give the idea, before going into more complex exercises.</p>

CC BY-SA 3.0
2017-06-09T08:48:22.993Z
2017-06-09T08:48:22.993Z
ItamarG3
<p>Classification problems are reasonable candidates.  For instance, I wrote a GA that looked at the <a href="https://archive.ics.uci.edu/ml/datasets/mushroom" rel="nofollow noreferrer">mushroom dataset</a> taken from the <a href="https://archive.ics.uci.edu/ml/about.html" rel="nofollow noreferrer">UCI Machine Learning Repository</a> with the goal of classifying an unknown mushroom as safe or poisonous based on its traits.  Each candidate solution encoded a series of rules (Red cap means poisonous, blue spores are safe). During the learning phase I used a portion of the dataset, but to perform the final evaluation I used the full set.</p>

<p>That particular dataset might not be well suited to the high-school level, as it has missing values on some entries, but there are a lot of other datasets. Also, numerical data is generally easier to encode than categorical data. That being said, it was a fun dataset to use - <em>"Hey look, after fixing that bug my GA poisons us 15% less often!"</em></p>

<p>Beyond that, it might be worth deliberately looking at a variety of problems including some that are poor candidates for GAs in order to demonstrate their relative strengths &amp; limitations.</p>

CC BY-SA 3.0
2017-06-09T04:17:10.050Z
Using poor candidates as learning examples is a good point.
Gypsy Spellweaver
CC BY-SA 3.0
2017-06-09T04:53:52.133Z
Wow. This is a very useful answer. It can also be used with neural networks.
ItamarG3
CC BY-SA 3.0
2017-06-09T03:53:45.633Z
2017-06-09T03:53:45.633Z
Pikalek
<p>As a special lesson, I would like to show students the very basic idea of genetic\evolutionary algorithms. I let them play a bit in <a href="http://rednuht.org/genetic_cars_2/" rel="nofollow noreferrer">a genetic algorithm online</a> game, to get the idea.</p>

<p>Then I teach them the main concepts (Population, individual with genes, mutation, crossover, fitness etc.) and I introduce the <a href="https://en.wikipedia.org/wiki/Travelling_salesman_problem" rel="nofollow noreferrer">Traveling Salesman Problem</a>. Then I go through solving TSP with genetic algorithm with them, so they see it in action and in practice. However I'm out of practice exercises.</p>

<p>So, I am looking for problems that have a solution which can vary in its "goodness", and its goodness can be judged by some requirements. To explain this, take the example of a timetable for tests over a month. a solution is a random time table. a good solution is one where tests are suffeciently spaced so that students have time to revise. in the <a href="http://rednuht.org/genetic_cars_2/" rel="nofollow noreferrer">game</a>, <strong>a</strong> solution is just any vehicle, but a <strong>good</strong> solution, is one that gets far. </p>

<p>Note: I am not necessarily looking for an answer that shows any previous knowledge about genetic algorithms (though it is appreciated <code>;)</code>), just any problem as described above.</p>

<p>What kinds of exercises\problems such as those are used? </p>

<p>The students
 are high-school students learning in java, and they are familiar with OOP. </p>

<java><secondary-education><exercises><genetic-algorithm>
Genetic Algorithm enrichment lesson
# Genetic Algorithm enrichment lesson

(Asked by: username_0 on 2017-06-08)

As a special lesson, I would like to show students the very basic idea of genetic\evolutionary algorithms. I let them play a bit in [a genetic algorithm online](http://rednuht.org/genetic_cars_2/) game, to get the idea.

Then I teach them the main concepts (Population, individual with genes, mutation, crossover, fitness etc.) and I introduce the [Traveling Salesman Problem](https://en.wikipedia.org/wiki/Travelling_salesman_problem). Then I go through solving TSP with genetic algorithm with them, so they see it in action and in practice. However I'm out of practice exercises.

So, I am looking for problems that have a solution which can vary in its "goodness", and its goodness can be judged by some requirements. To explain this, take the example of a timetable for tests over a month. a solution is a random time table. a good solution is one where tests are suffeciently spaced so that students have time to revise. in the [game](http://rednuht.org/genetic_cars_2/), **a** solution is just any vehicle, but a **good** solution, is one that gets far.

Note: I am not necessarily looking for an answer that shows any previous knowledge about genetic algorithms (though it is appreciated `;)`), just any problem as described above.

What kinds of exercises\problems such as those are used?

The students
are high-school students learning in java, and they are familiar with OOP.

**Tags:** java, secondary-education, exercises, genetic-algorithm


---

## 2 answers

### Answer by username_1 on 2017-06-09. Score: 3 | Accepted answer

Classification problems are reasonable candidates. For instance, I wrote a GA that looked at the [mushroom dataset](https://archive.ics.uci.edu/ml/datasets/mushroom) taken from the [UCI Machine Learning Repository](https://archive.ics.uci.edu/ml/about.html) with the goal of classifying an unknown mushroom as safe or poisonous based on its traits. Each candidate solution encoded a series of rules (Red cap means poisonous, blue spores are safe). During the learning phase I used a portion of the dataset, but to perform the final evaluation I used the full set.

That particular dataset might not be well suited to the high-school level, as it has missing values on some entries, but there are a lot of other datasets. Also, numerical data is generally easier to encode than categorical data. That being said, it was a fun dataset to use - *"Hey look, after fixing that bug my GA poisons us 15% less often!"*

Beyond that, it might be worth deliberately looking at a variety of problems including some that are poor candidates for GAs in order to demonstrate their relative strengths & limitations.

> **Comments:**
> **username_2**: Using poor candidates as learning examples is a good point.  
> **username_0**: Wow. This is a very useful answer. It can also be used with neural networks.  

---

### Answer by username_0 on 2017-06-09. Score: 0

I'm adding an answer to show what sort of things I'm looking for. 
An example of such a problem could be fitting coefficients for a polynomial​ function. We have a dataset of (X,Y), and the highest power of the polynomial. Then a solution is a set of numbers (number of parameters is the highest power). 
The fitness of a solution could be 
fitness := 1.0/(sum(dataset's Y - polynomial's Y, for each X in dataset))

This is an introductory genetic algorithm to give the idea, before going into more complex exercises.


---

