COIT20277 Introduction to Computational Intelligence Assignment 1 – Evolutionary Computation Due date: Week 5 Tuesday (13 August XXXXXXXXXX:59 pm AEST ASSESSMENT Weighting: 20% 1 Objectives  Model...

1 answer below »
i don't exactly please go through the requirements and important point is already i have code only i need knapsack problem


COIT20277 Introduction to Computational Intelligence Assignment 1 – Evolutionary Computation Due date: Week 5 Tuesday (13 August 2019) 11:59 pm AEST ASSESSMENT Weighting: 20% 1 Objectives  Model and design solution to the given problem applying principles of Genetic Algorithms  Develop source code and implement designed solution.  Follow correct procedure for implementing a Genetic Algorithm.  Test software implementations to ensure correctness and maintainability. The Knapsack Problem (KP) The Knapsack Problem is an example of a combinatorial optimization problem, which seeks for a best solution from among many other solutions. It is concerned with a knapsack that has a specific volume (or capacity) V. There are a number of distinct items I that may potentially be placed in the knapsack. Each item has a positive number volume v and positive integer benefit b. The goal is to place as the items into the Knapsack to maximize the total benefit, while the total volume of the items is not exceeding the volume V of the knapsack. Note that we cannot have more than one copy of an item in the knapsack. Example: Suppose we have a knapsack that has a capacity of 13 cubic inches and three potential items (labeled ‘A,’ ‘B,’ ‘C’), whose volume and benefit are as follows: Item # A B C Benefit 4 3 5 Volume 6 7 8 We want to include in the knapsack only these items that will have the greatest total benefit within the constraint of the knapsack’s capacity. Each item is only selected once. There are 23 = 8 possible ways (subsets) to place these items into the knapsack as in the table (next page). An index 0 or 1 is used to indicate if the corresponding item is selected nor not. We can see that the optimal solution is to select only item A and B not C (1 1 0) to place into the knapsack, which result in highest benefit of 7, and total volume of 13 satisfying the capacity constraint of the knapsack. A B C Total Volume Total Benefit 0 0 0 0 0 0 0 1 8 5 0 1 0 7 3 0 1 1 15 -- 1 0 0 6 4 1 0 1 14 -- 1 1 0 13 7 1 1 1 21 -- Assessment Task A. Programming You are required to write a Java Application that implements a genetic algorithm to solve the Knapsack Problem for any number of items with different volumes and benefits. You can use the following class descriptions as a guideline for your design. 1. Item class This class is to store the item value and benefit in integers. Write the necessary accessor and mutator methods to and get the value and benefit values. You should also write the parameterised constructor that takes the values and creates the Item object, a default constructor. 2. Individual class The purpose of this class is to create an individual and store required values. In this problem, the chromosome is an array of binary integers, each integer being the index of an item (0 or 1) to indicate if an item is selected or not. The chromosome length or the array size is the number of available item to be considered. This class should have:  Two parameterised constructors, one taking the chromosome as a parameter, and the other taking the chromosome length as a parameter.  Accessor and mutator methods to set and get chromosome, set and get a particular gene within a chromosome, set and get fitness of the individual. Fitness is the total benefit of selected items.  toString() method to display the genes (item indices) contained in the chromosome. 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 item index and therefore, different fitness. This class stores the array of individuals and the population fitness which is the total 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. Genetic Algorithm class This class stores the GA parameters of population size, mutation rate, crossover rate, elitism count, knapsack volume. This class should have:  A parameterised constructor that takes the above parameters and creates the object.  An initPopulation method to create the first generation of the population.  A method to test whether termination condition has reached.  A method to calculate and return the individual’s fitness.  A method to evaluate population by calculating and setting the individual fitness and then calculating the population fitness.  A method to select parent for the crossover using roulette wheel selection.  A method to crossover using two-points cross-over and create new population.  A method to mutate population leading to evolution. 5. Packaging Main class This class will create items with random values and benefits using objects of the above classes and execute the application creating the required number of generations and displaying the optimal solution for items in knapsack. You use the algorithmic steps given below to implement this class public class Packaging{ public static int maxGenerations = //initialize to given generations public static void main(String[] args) { int numItems = //initialize number of items int populationSize = double mutationRate = double crossoverRate = double knapsack_capacity = //initialize capacity for knapsack int elitism_count = 1; //Number of best individuals to retain. Item items[] = new Item[numItems]; // Loop to create Items with random Volumne and Benefit. for (int itemIndex = 0; itemIndex < numitems; itemindex++) { int volumne = (int) (10 * math.random()+1); int benefit = (int) (10 * math.random()+1); items[itemindex] = new item(volumne, benefit); } // initial ga geneticalgorithm ga = new geneticalgorithm(//use appropriate parameters); // initialize population population population = ga.initpopulation(items.length); // todo: evaluate population // keep track of current generation int generation = 1; // start evolution loop while (ga.isterminationconditionmet(generation, maxgenerations) == false) { // todo: apply select paren population // todo: apply crossover // todo: apply mutation // todo: evaluate population // todo: increment the current generation // todo: display appropriate output for each iteration. } // todo: display results } } you will write and submit source code in java for the implementation of the application. as you can see many of the classes and methods can be coded following the generic pattern given in weekly examples. sample outputs of an implemented program is provided in “assignment 1 - example output.pdf” for your reference. you can build your application using the netbeans, textpad editor or any other suitable ide for software development. run and test your program with the following parameter settings:  maximum generations: 50  number of items : 10  population size : 10  mutation rate : 0.1  crossover rate : 0.7  knapsack volume constraint = 40  elitism = 1 b. report as part of the assessment you should submit a report that contains the uml class diagrams for the classes. 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. take screenshots and explain the outputs of your implemented program. assessment submission you should submit one zip file containing the following files using the moodle online submission system, by the due date:  item.java – source code for the item class as given above  individual.java – source code for the individual class  population.java – source code for the population class  geneticalgorithm.java – source code for the genetic algorithm class  packagingmain.java– source code for the packaging main class  report.docx – a document file containing details as outline above. assessment criteria - assignment 1 marking guide note: 1. if your program doesn’t 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 numitems;="" itemindex++)="" {="" int="" volumne="(int)" (10="" *="" math.random()+1);="" int="" benefit="(int)" (10="" *="" math.random()+1);="" items[itemindex]="new" item(volumne,="" benefit);="" }="" initial="" ga="" geneticalgorithm="" ga="new" geneticalgorithm(//use="" appropriate="" parameters);="" initialize="" population="" population="" population="ga.initPopulation(items.length);" todo:="" evaluate="" population="" keep="" track="" of="" current="" generation="" int="" generation="1;" start="" evolution="" loop="" while="" (ga.isterminationconditionmet(generation,="" maxgenerations)="=" false)="" {="" todo:="" apply="" select="" paren="" population="" todo:="" apply="" crossover="" todo:="" apply="" mutation="" todo:="" evaluate="" population="" todo:="" increment="" the="" current="" generation="" todo:="" display="" appropriate="" output="" for="" each="" iteration.="" }="" todo:="" display="" results="" }="" }="" you="" will="" write="" and="" submit="" source="" code="" in="" java="" for="" the="" implementation="" of="" the="" application.="" as="" you="" can="" see="" many="" of="" the="" classes="" and="" methods="" can="" be="" coded="" following="" the="" generic="" pattern="" given="" in="" weekly="" examples.="" sample="" outputs="" of="" an="" implemented="" program="" is="" provided="" in="" “assignment="" 1="" -="" example="" output.pdf”="" for="" your="" reference.="" you="" can="" build="" your="" application="" using="" the="" netbeans,="" textpad="" editor="" or="" any="" other="" suitable="" ide="" for="" software="" development.="" run="" and="" test="" your="" program="" with="" the="" following="" parameter="" settings:="" ="" maximum="" generations:="" 50="" ="" number="" of="" items="" :="" 10="" ="" population="" size="" :="" 10="" ="" mutation="" rate="" :="" 0.1="" ="" crossover="" rate="" :="" 0.7="" ="" knapsack="" volume="" constraint="40" ="" elitism="1" b.="" report="" as="" part="" of="" the="" assessment="" you="" should="" submit="" a="" report="" that="" contains="" the="" uml="" class="" diagrams="" for="" the="" classes.="" 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.="" take="" screenshots="" and="" explain="" the="" outputs="" of="" your="" implemented="" program.="" assessment="" submission="" you="" should="" submit="" one="" zip="" file="" containing="" the="" following="" files="" using="" the="" moodle="" online="" submission="" system,="" by="" the="" due="" date:="" ="" item.java="" –="" source="" code="" for="" the="" item="" class="" as="" given="" above="" ="" individual.java="" –="" source="" code="" for="" the="" individual="" class="" ="" population.java="" –="" source="" code="" for="" the="" population="" class="" ="" geneticalgorithm.java="" –="" source="" code="" for="" the="" genetic="" algorithm="" class="" ="" packagingmain.java–="" source="" code="" for="" the="" packaging="" main="" class="" ="" report.docx="" –="" a="" document="" file="" containing="" details="" as="" outline="" above.="" assessment="" criteria="" -="" assignment="" 1="" marking="" guide="" note:="" 1.="" if="" your="" program="" doesn’t="" 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="">
Answered Same DayAug 25, 2021COIT20277Central Queensland University

Answer To: COIT20277 Introduction to Computational Intelligence Assignment 1 – Evolutionary Computation Due...

Sonu answered on Aug 26 2021
142 Votes
KnapsackProblem/KnapsackProblem/.classpath

    
    
    
KnapsackProblem/KnapsackProblem/.project

     KnapsackProblem
    
    
    
    
        
             org.eclipse.jdt.core.javabuilder
            
            
        
    
    
         org.eclipse.jdt.core.javanature
    
KnapsackProblem/KnapsackProblem/.settings/org.eclipse.jdt.core.prefs
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.
eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
KnapsackProblem/KnapsackProblem/bin/com/knapsack/problem/java/GeneticAlgorithm.class
package com.knapsack.problem.java;
public synchronized class GeneticAlgorithm {
private int populationSize;
private Population[] Generations;
double[] rouletteWheelWedgeSizes;
private final int GENERATION_COUNT;
private double mutationRate;
private final double crossoverRate;
public void GeneticAlgorithm(int, double, double, int);
public Population initPopulation(int);
public int getGenerationCount();
public void evalPopulation(Population);
public void setRouletteWheelwedgeSizes();
public boolean isTerminationConditionMet();
public Population selectParentPopulation(Population);
public void addPopulationToGeneration(int, Population);
public void twoPointCrossOver(Individual, Individual);
public Population crossoverPopulation(Population);
public Population mutatePopulation(Population);
public Population GetAGeneration(int);
}
KnapsackProblem/KnapsackProblem/bin/com/knapsack/problem/java/Individual.class
package com.knapsack.problem.java;
public synchronized class Individual {
final int CHROMOSOME_LENGTH;
final double pi;
private final int[] chromosome;
private double fitness;
private double volume;
int deciamalValueX;
double normalizedFitness;
double cumNormFitness;
int maximumGeneration;
public void Individual(int[]);
public void Individual(int);
public void Individual(Individual);
private void setChromosome();
public int[] getChromosome();
public int getChromosomeLength();
public void setGene(int, int);
public int getGene(int);
public int covertToDecimal();
public void calculateAndSetFitness();
public void setFitness(double);
public double getFitness();
public double getNormalizedFitness();
public double getCumNormFitness();
public void setNormalizedFitness(double);
public void setCumNormFitness(double);
public void calculateAndSetVolume();
public void setVolume(double);
public double getVolume();
public String toString();
}
KnapsackProblem/KnapsackProblem/bin/com/knapsack/problem/java/Item.class
package com.knapsack.problem.java;
public synchronized class Item {
private int value;
private int benefit;
public void Item();
public void setValue();
public void setBenefit();
public int getValue();
public int getBenefit();
}
KnapsackProblem/KnapsackProblem/bin/com/knapsack/problem/java/Packaging.class
package com.knapsack.problem.java;
public synchronized class Packaging {
public void Packaging();
public static void main(String[]);
}
KnapsackProblem/KnapsackProblem/bin/com/knapsack/problem/java/Population$1.class
package com.knapsack.problem.java;
synchronized class Population$1 implements java.util.Comparator {
void Population$1(Population);
public int compare(Individual, Individual);
}
KnapsackProblem/KnapsackProblem/bin/com/knapsack/problem/java/Population.class
package com.knapsack.problem.java;
public synchronized class Population {
private Individual[] population;
final int populationSize;
private double populationFitness;
private double populationVolume;
public void Population(int);
public void Population(int, int);
public Individual[] getIndividuals();
public Individual getFittest(int);
public void setPopulationFitness(double);
public double getPopulationFitness();
public int size();
public void setIndividual(int, Individual);
public Individual getIndividual(int);
public void calculateAndSetPopulationFitness();
public void shuffle();
public String...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here