首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
辅导Algorithm程序设计、讲解Java程序、Python,c++编程调试 讲解R语言编程|解析Haskell程序
项目预算:
开发周期:
发布时间:
要求地区:
Genetic Algorithm - Immutable
Time Estimate: 20 hours
Video
Introduction
You will design and implement a genetic algorithm without using any mutable variables or
state.
The following are banned in your submissions:
● Variables (var)
○ The value at any memory address on the stack or heap cannot
change throughout the execution of your program
○ You can use values (val) to store values
● Any way of directly simulating mutability that is against the spirit of this
assignment. (Ex. Importing a class that has a mutable state variable)
If your submission, including testing, violates this immutability restriction it will not be graded.
Description
Genetic algorithms provide probabilistic solutions to optimization problems. These algorithms
can be thought of as an advanced “guess and check” technique that eventually arrives at an
output that is close to the actual solution without having to know how to compute the solution
directly.
Resources:
● https://en.wikipedia.org/wiki/Genetic_algorithm
● https://www.tutorialspoint.com/genetic_algorithms/index.htm
You will write a generic genetic algorithm of your own design that can find approximate
solutions to optimization problems. This algorithm will be written in such a way that it can be
reused for any application suitable for a genetic algorithm. For each problem, you will need
to provide your genetic algorithm with a cost function to determine how well a potential
solution performs and an incubator function that creates a potential solution from a list of
doubles (Referred to as genes).
Project Structure
1. Download the starter code from UBLearns as a new IntelliJ project
2. Run maven and mark src as the root sources directory
This repository includes a server as its GUI. To run the GUI, run towers.TowerServer then
open towers/static/index.html in your browser.
Objectives
Primary Objective: Genetic Algorithm
Implement a generic genetic algorithm.
In the GeneticAlgorithm object, write a method named geneticAlgorithm with the following
features:
● Takes a type parameter T
○ This is the type of the solution space that you are trying to find. For example,
when computing polynomial regression this type will be Polynomial
● As the first parameter, takes an “incubator” function that takes a List[Double] and
returns an object of type T
○ This function will provide a way to convert a list of genes into an object in the
solution space. Your algorithm will only work with lists of doubles to guess
new solutions and call this incubator to convert the genes into possible
solutions
● As the second parameter, takes a cost function of type T to Double
○ This function takes a potential solution and computes its cost. The goal of
your algorithm is to find a solution with minimal cost. A solution with a cost of
0.0 is considered perfect, though a perfect will not always exist.
● The third, and final, parameter is an Int named size representing the number of
genes in the List[Double] for the incubator function
○ When creating/mutating/crossing lists for the incubator, make sure the lists
have this length
● Returns an object of type T which is the most optimal solution found by the algorithm
Your algorithm will be tested with an unknown application to ensure you implemented the
algorithm generically. Your algorithm will be called 10 times during primary objective testing
to test the efficiency and consistency of your implementation. Be sure your algorithm is
efficient enough to run this many times. Grading will timeout after 5 minutes.
Algorithm Outline: You have a significant amount of freedom in designing your genetic
algorithm. Your only goal is to return a solution that is close to optimal. If you achieve this,
you can complete this assignment. For a little guidance on designing an algorithm, if you
don’t want to design your own from scratch, here are a few steps you can follow.
1. Start by generating a fixed number of random “animals”
a. Each animal is defined by its genes (List of doubles) so this involves
generating random lists of doubles
b. Depending on the rest of your algorithm and applications, the range of these
random values may be important. Ensure that the range is wide enough to
allow any potential solution. (If your genes cover the range -100 to 100 you
will be able to pass the primary objective)
2. Find the best animals
a. Use the incubator function to create a potential solution for each set of genes
b. Use the cost function to compute the cost of each potential solution
c. Sort the animals based on their cost to find the best animals
3. Survival of the fittest
a. Only keep animals with the least costs and say goodbye to the rest
4. Mutations
a. Simulate genetic mutations of the best animals by creating new sets of genes
that are similar to the best ones, but with some random variation
b. Randomness is your friend in this step. You are starting with a pretty good
solution and creating random solutions that are similar to the good one to find
an even better one. Creating several variations of the best solutions with
random changes will help your algorithm to find the best solution
5. Crossover
a. Pair up the top animals and create offspring by combining their genes
b. There are several methods of this, for example averaging their genes or
randomly choosing one parent for each gene
6. More random animals
a. Add more random animals to get back to the original number of animals
7. The next generation
a. Go back to step 2 [with recursion]
b. You can recurse for a fixed number of generations, or until the improvement
from the previous generation is very small. Do not run until the cost is close to
0 since the most optimal solution may have a high cost.
If you follow this outline there are many parameters that are up to you to choose. You should
use the three objectives for testing and adjust your parameters until you have a robust
genetic algorithm. These parameters include:
● How many animals in each generation
● How many generations
● How to mutate genes
● How many mutations to generate and which animals get mutated
● How to crossover two (or more) animals
Testing Note
● Your tests will not be checked by AutoLab for this assignment. Three applications
are setup to assist your testing which you should use to write test suites and test
your genetic algorithm
● If you ask a question in office hours or on Piazza without taking advantage of these
testing opportunities, don’t expect a satisfying answer (Unless your question is
about testing)
Testing Opportunity 1: Single Value
Given a single double to compute, the genetic algorithm should return an instance of
SingleValue containing a double close to this value. This is a simple application that should
be used as a first milestone for your genetic algorithm to reach. The SingleValue object has:
1. A costFunction method
a. This method takes the number to be “guessed” as a parameter and returns a
cost function that takes a SingleValue and return its distance from the number
to be guessed
2. An incubator method
a. This method takes a list of doubles (genes) and returns an instance of
SingleValue from those genes
b. The input List should contain a single Double and this Double will be used
directly as the SingleValues Double
Sample Test Case 1
1. A single value equal to 50.0. This test case is provided with the started code to show
you how the genetic algorithm is used.
Sample Test Case 2
1. A single value equal to 0.0
Sample Test Case 3
1. A single value equal to -50.0
Testing Opportunity 2: Line
Use your genetic algorithm to compute linear regression.
Using SingleValue as an example, complete the Line class and object to be used by your
genetic algorithm to estimate a line fitting a list of points.
The Line class has the same structure as the SingleValue class with:
1. A costFunction method
a. The cost function takes a List of Points and returns a cost function that
computes the cost of a Line object. The cost is the sum of the squared
distances of the points from the polynomial in the y direction.
2. An incubator method
a. The incubator takes a List of Doubles of length 2 and directly uses them as
the coefficients of the Line to be created. The first element of the list is the
slope and the second is the y-intercept.
Sample Test Case 1
1. Points: (-2.0, 1.0), (-1.0, 3.0), (0.0, 5.0), (1.0, 7.0), (2.0, 9.0)
Sample Test Case 2
1. Points: (-4.2, 24.957), (-1.2, 13.453), (-0.3, 11.508), (1.3, 6.088), (2.5, 1.0), (4.0, -3.047), (5.0, -7.839)
2. To ensure that you have the cost function set up properly, check that your algorithm
finds the best fit line of -3.483x + 10.122
Sample Test Case 3
1. Points: (-10.0, -36.4), (-5.1, -17.3), (0.5, -2.2), (1.7, 2.6), (10.0, 26.6)
2. The best fit line is not given for this test case
Testing Opportunity 3: AimBot
Use your genetic algorithm to hit a moving target in a 2d space.
This bot will have a fixed position and must hit a moving target given by its velocity and initial
location. To do this, the genetic algorithm will be used to determine the velocity (direction)
that a projectile should be fired to hit the target.
The cost function will be provided these values as 3 PhysicsVectors and will return a function
that determines the cost of a particular velocity vector.
The returned velocity will have a magnitude of 7.0.
Note: It is not required that you understand all the code in the AimBot class.
This can be tested by running the server, opening the html file, and verifying that the tower
can hit the plate as you move around the screen. The code is already set up to call your
genetic algorithm.
Grading Note
● Because the grader only checks the primary objective it is broken into 4
components
a. Your GA can accurately figure out 2 random hidden numbers 1 time in a
row (2.5 points)
b. Your GA can accurately figure out 2 random hidden numbers 5 times in a
row (2.5 points)
c. Your GA can accurately figure out 2 random hidden numbers 10 times in a
row (2.5 points)
d. Your GA can accurately figure out 2 random hidden numbers 15 times in a
row (2.5 points)
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!