Description
COIT20277 – Introduction to Artificial Intelligence Assessment item 1,
COIT20277 – Introduction to Artificial Intelligence
Assessment item 1, Term 1, 2023
Due Date
Weighting
Assessment Task
30%
Solve retail problem using genetic algorithm
Objectives
1. Analysis of the solution design for the given problem applying principles of
Genetic Algorithms
2. The strategy of implementation presented using diagram
3. Use the appropriate parameters given in the assessment specification and fitness
function specified
4. Put appropriate comments in the code and follow good programming
techniques/practices
5. Use of crossover and mutation in the code to ensure the correctness of the model
and algorithm
Assessment Task
Nowadays genetic algorithm (GA) is greatly used in solving complex problem and issues.
GA utilizes selection, crossover, and mutation strategy to solve the problem effectively
from the problem space.
In this assessment, you need to build a model solution to help a store manager to solve
their retail problem using genetic algorithm. Details about the problem will be describe
in section A. The program needs to be implemented using Java following the data
structures provided in the section D.
Section A: Problem Statement
Bob works as a retail manager in Woolworth group in Forest Lake, Brisbane branch. After
so many years of experience he founds an important pattern to maximise the profit. But
he is not good with programming, so it’s difficult for him to program it, so that it will be
easier for him. He recently heard about the advantage of ChatGPT and can solve problem
immediately, so he tried to give input to ChatGPT and expecting his problem will be
solved. But at this moment ChatGPT isn’t that much smart to solve his problem
automatically, so he is asking help from a machine learning engineer to solve his problem.
Initially he breaks down his problem into small space and would like to develop an MVP
(minimum viable product) as a proof of concept. Upon getting success using the MVP, he
will plan for the next phase and how to move into production. As a machine learning
engineer, you need to develop a model solution to help Bob.
Here is a partial detail of the retail problem that Bob wants to solve. In a giant super shop
like Woolworth there are lots of product. He chooses 10 products among the list, and he
found an interesting pattern. Among the 10 products if the sum of the five products is 360
and product of the other five products is 360 * 100K, he can maximise the profit. Price of
the 10 products is [10, 20, 30, 40, 50, 60, 70, 80, 90, and 100]. So, the expected solution is
for the one set is [20, 70, 80, 90, 100] where the sum is 360 and the second set is [10, 30,
40, 50, 60] where the product is 360 * 100k. As it’s a subset of the problem it seems very
simple and can be solved by hand, but if the set size increasing the permutation of the
solution space will be huge. So, if we summarise the input and goal, it will be like this
shown in the diagram.
Expected Outcome
A sample solution
After 900 iterations solution for the set 1 are: 20 70 80 90 100
and solution for the set 2 are: 10 30 40 50 60
A schematic diagram for the process shown in the below diagram
Section B: Modelling
Use the following guidelines for your solution
1. The length of the chromosome is 10
2. Kind of cross over that can be use
I. One-point crossover / Two-point crossover
3. Fitness function
sum!””#” = sum − sum_target
sum_target
product!””#” = product − product_target
product_target
total!””#” = ABS (sum!””#”)
ABS(product!””#”)
If total!””#” = 0, we got the solution
4. Use tournament selection algorithm for the parent selection during crossover
5. You can set a maximum iteration to terminate the process
6. You can choose 0 for set 1 and 1 for set 2 from the gene
Section C: Parameters to be used
1. Number of Generations: 1000
2. Population size: 50
3. Chromosome length: 10
4. Mutation rate: 0.1
5. Crossover rate: 0.5
6. Tournament size: 2
7. Sum Target: 360
8. Product Target: 360 * 100k
Section D: Code Structures
You can use the following code structures to implement the solution
1. Product Class: This is to store the product information in integers. Write necessary
accessor and mutator methods to set the values.
2. Genetic Algorithm Class: This class stores the GA parameters of population size,
mutation rate, crossover rate, elitism count, and tournament size. This class
should have:
I. A parameterised constructor that takes the above parameters and creates
the object.
II. An initPopulation method to create the first generation of the population.
III. A method to test whether termination condition has reached.
IV. A method to calculate and return the individual’s fitness.
V. A method to evaluate population by calculating and setting the individual
fitness and then calculating the population fitness.
VI. A method to select parent for the crossover using tournament selection.
3. Population Class: As in any GA, this class is used to create as many individuals as
per the given population size where each individual will have a different route and
therefore, different fitness. This class stores the array of individuals and the
population fitness which is the average of the individual fitness. This class should
have:
Two parameterised constructors, one taking the population size as a parameter,
and the other taking the population size and chromosome length as parameters.
Accessor and mutator methods to set and get the parameters of population size,
population fitness, individuals, a specific individual at a given index, the fittest
individual of the population.
This class also should have a shuffle method to organise the individuals of the
population at a random order.
4. Individual Class: The purpose of this class is to create an individual and store
required values.
5. Fitness Calculation method: This will calculate the fitness for the selected
chromosome.
6. Display method: to show the output after each iteration
Section E: Source Code
You must write and submit source code in java for the implementation of the application.
You need to make essential changes to integrate the given code into your application. As
you can see many of the classes and methods can be coded following the generic pattern
given in examples in various weeks.
Pseudocode: Solving the Retail Problem
1: Generate a random population P
2: while Termination condition is not met do select 2 individual
3: for each individual i of P do
4: Generate a product combination using individual i
5: Evaluate the generated product combination using the fitness function
6: end for
7: Apply mutation
8: Apply crossover
8: Generate a new population P
9: end while
Section F: Report
As part of the assessment, you should submit a report that contains step by step how to
run the code. Your report should also contain an explanation of the implementation of
the given methods of crossover and mutation to show the strategical approach used to
improve the population fitness, generation after generation. Include a brief note on how
such strategy can be used in solving optimization problems.
Section G: Software Tools and Building the Application
You can build your application using the TextPad Editor, NetBeans, or any other suitable
IDE for software development.
Note: Commence with one class at a time, test it and then incrementally add the next.
Submission Instructions
You should submit one zip file containing the following files using the Moodle online
submission system. (Note: the file names/class names could be changed to meaningful
names.)
Assessment Item 1 Marking criteria
Serial No. Specification Marks Marks
Scored
1 Step by step for genetic algorithm and show how to
run the code and screenshot of the expected
outcome
4
2 Correct implementation of the display method 3
3 Correct implementation of the Genetic Algorithm 4
4 Correct implementation of the Individual 4
5 Correct implementation of the Population 4
6 Correct implementation of the fitness method 4
7 Good coding practices (Indentation, Java doc
Comments clearly describing the code segments,
naming Conventions, Readability)
3
8 Well-presented report with student details,
providing correct explanation of the crossover
and mutation methods and description of the
strategic approach leading to improved
population
4
Penalties
9 Late Penalty (5% of total marks per day – 1 mark)
10 Plagiarism (as per policy)
Total 30
Note:
1. If your program does not compile or run, partial marks will be allocated by
inspection of the source code.
2. Your understanding of the algorithm and problem-solving approach used will be
examined using the detailed java doc comments inserted in your source code file.
3. Please clarify any doubts you have by one of the means of discussing with your
tutor, posting a query in the Q & A forum, or discussing with your colleagues or
contacting the unit coordinator.
4. Please do not share your source code files or report with your colleagues which
may lead to plagiarism. Please do not search and use source code available
elsewhere which may also lead to plagiarism
Commence your assignment work early and show your progress to your tutor from Week
3 onwards
Reviews
There are no reviews yet.