SCC361 Artificial Intelligence Coursework 2 – Genetic AlgorithmsR

Java Python SCC361

Artificial  Intelligence

Coursework 2 - Genetic Algorithms

Date Released: Friday,  15th   November 2024

Date Due: Friday  13th   December 2024 at 4pm

This coursework is worth 20 % of your overall mark

1. Introduction

In this coursework, your task  is to  implement  a  Genetic Algorithm  (GA)  to address a designated problem, and subsequently present the results. The foundational concepts of GA were introduced and discussed during the week 6 lectures and the lab sessions in week 7 were dedicated to familiarizing you with GA. However, it's essential to note that this coursework involves applying GA to a distinct problem, different from those addressed in the lab sessions.

2. Problem Definition

The task at  hand  involves  implementing  and  enhancing a  robot  motion  planning  algorithm  using Genetic Algorithms (GAs). Assume that you have a robot with an overhead camera. The first step in motion planning is to create a representation of the robot's operating environment. This involves constructing a map that includes information about obstacles, terrain, and other relevant features. For the purposes of this CW, we simplify the process by assuming the existence of such amap, already provided as input, with dimensions of 500 pixels by 500 pixels. An illustrative example of such a map is shown in the figure below.

The next step is localisation, which refers to the process of determining the robot's precise position and orientation within its operating environment. It is a crucial aspect of robotics that enables a robot to understand and update its location relative to a given coordinate system or map.  Effective localization is essential for accurate navigation, as the robot needs to know where it is in order to plan and execute its movements successfully. For the purposes of this CW, it is presumed that both the starting point and the destination of the robot are provided as follows:

start = [1, 1]

finisℎ = [500,500]

The primary objective of the CW is thus limited to path planning for the robot.

Let a path be characterized by a fixed number of pointsnp  in the robotic map. As shown in the figure below for np  = 10, the pathis constructed by commencing from the start point [1, 1] and connecting it to the first point through a straight line. Subsequently, each point is connected to the next in sequence by straight lines until the final point is linked to the finish point [500,500].

To keep things simple, we're treating the robot asatiny point (or a pixel) instead of its actual size.

3. Problem Solving using Genetic Algorithms

In formulating the problem as an optimization challenge for resolution by a Genetic Algorithm (GA), two key elements are essential: defining an objective function and specifying the variables of that function along with their bounds. The objective function, in this context, is the length of the path, where a shorter pathis considered more favourable. A penalty should be imposed if any part of the path intersects with an obstacle, with the penalty proportional to the pathlength within the obstacle.

The optimization variables are the coordinates (x, y) of each of the fixed number of points along the path. The variable bounds are determined such that each point resides within the map. Specifically, the lower bound is set to 1, and the upper bound corresponds to the length or width of the map for the x andy axes (i.e., 500). Each of these points, arranged one after another, constitutes the genetic individual utilized in the optimization process.

Each point in the path marks a point of turn. The total number of points “noOfPointsInSolution” should be considered as a parameter and should be equal to the maximum number of turns a robot is expected to make in the robot map.

How to Read and Generate Random Maps

In order to implement your code, you need to first read a map as a binary image as follows:

map=im2bw(imread('random_map.bmp'));

where 'random_map.bmp' is the name of an example map. A MATLAB script named

“Generate_Random_Map.m” is provided to generate different (simple to complex) binary maps.

Implement Genetic Algorithm

Your main task involves the implementation, using MATLAB, of a genetic algorithm designed to discover an optimal path th SCC361 Artificial Intelligence Coursework 2 – Genetic AlgorithmsR rough an evolutionary process. It is important to note that the built-in ga function in MATLAB is not permissible for use in this task. Instead, you are required to develop an approach akin to what was covered in the lab sessions during week 7.

Your algorithm should make use of appropriate crossover and mutation operators. Numerous design decisions, including the implementation details of the algorithm and the selection of parameter values, will be required.

Your code should output animage displaying the final best path using the provided code below:

path = [start; [solution(1:2:end)'*size(map,1) solution(2:2:end)'*size(map,2)]; finish];

clf;

imshow(map);

rectangle('position',[1 1 size(map)-1],'edgecolor','k');

line(path(:,2),path(:,1));

The solution is a row vector of size 2 × np. One possible output is shown below.

Your code should include functionality to display both the execution time of the Genetic Algorithm (GA) and the total Euclidean distance of the optimal path.

Important Notes

1.   You need to implement THREE selection methods including Roulette wheelselection (RWS), Tournament selection and Rank-based Selection. The code for RWS is available in Week 6’s lab material on Moodle. Conduct some research to gain an understanding of how Rank-based selection operates, and subsequently, incorporate this knowledge into the implementation. Note that for the Tournament selection method, you need to consider its variants/parameters as variables.

2.   You need to implement TWO appropriate cross-over operators. Note that t-point cross-

over is counted as one method, and thus, changing k to 1, 2, 3 doesn’t count as three cross- over operators.

3.   You need to implement TWO appropriate mutation operators.

4.   Your algorithm should provide optimal or near optimal solutions for any combination of selection/cross-over/mutation.

5.    Upon initiation, the code should prompt the user to specify the types of selection,

crossover, and mutation to be employed. For both crossover and mutation operators, the user should input a binary digit (0 or 1) to signify a specific type for each operator. For example, when selecting the crossover method, entering 0 signifies opting for crossover method 1, while entering 1 indicates the adoption of crossover method 2. Regarding selection, the user should input 0, 1, or 2 to indicate the chosen method.

6.   The code should output animage displaying the final best path similar to the one shown in the figure above.

7.   The code should be efficient and produces the required outputs. Try to use minimum number of loops in your code.

8.   The maximum number of iterations/generations and the size of population should be as small as possible.

6. Submission

Please save your code in a zip file called “CW2_ID.zip”, substituting ID with your student ID. submit the code on Moodleonor before the deadline of 4pm on Friday, 13th December, 2024. The code could be submitted as a single .m file or with multiple separate function files and a “main.m” file. If for some reason, you cannot upload your submission, please zip it up and e-mail it to b.williams6@lancaster.ac.ukandscc-teaching-office@lancaster.ac.ukas soon as possible. Your submission should be anonymous and not include your name in the code.

7. Marking

There area total of 20 marks for this coursework and the coursework mark constitutes 20% of your overall mark for this module.

•    2 marks are allocated to the structure of the code. It should be well-structured and easy to understand. The code should be run by pressing the Matlab RUN button without requiring  any changes.

•    10 marks are allocated to the correctness of the results. The code is expected to produce a solution that is close to optimal. Your code will be executed 10 times to assess how frequently it generates an optimal or near-optimal solution. The expectation is to achieve optimal results in 80% of the runs.

•    2 marks are allocated to the commenting. There should be enough comments to understand the code. A report is not required for this coursework; the code should be well-commented with enough detail on methods used/ implemented.

•    6 marks are allocated to time complexity of the algorithm (in all settings). The code should prioritise time efficiency and use matrix operations for computational advantage. The maximum number of iterations/ generations and population size should be minimised for optimal performance         

【电动汽车充电站有序充电调度的分散式优化】基于蒙特卡诺和拉格朗日的电动汽车优化调度(分时电价调度)(Matlab代码实现)内容概要:本文介绍了基于蒙特卡洛和拉格朗日方法的电动汽车充电站有序充电调度优化方案,重点在于采用分散式优化策略应对分时电价机制下的充电需求管理。通过构建数学模型,结合不确定性因素如用户充电行为和电网负荷波动,利用蒙特卡洛模拟生成大量场景,并运用拉格朗日松弛法对复杂问题进行分解求解,从而实现全局最优或近似最优的充电调度计划。该方法有效降低了电网峰值负荷压力,提升了充电站运营效率与经济效益,同时兼顾用户充电便利性。 适合人群:具备一定电力系统、优化算法和Matlab编程基础的高校研究生、科研人员及从事智能电网、电动汽车相关领域的工程技术人员。 使用场景及目标:①应用于电动汽车充电站的日常运营管理,优化充电负荷分布;②服务于城市智能交通系统规划,提升电网与交通系统的协同水平;③作为学术研究案例,用于验证分散式优化算法在复杂能源系统中的有效性。 阅读建议:建议读者结合Matlab代码实现部分,深入理解蒙特卡洛模拟与拉格朗日松弛法的具体实施步骤,重点关注场景生成、约束处理与迭代收敛过程,以便在实际项目中灵活应用与改进。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值