Python代写:CS457 GA and ACO

使用GA遗传算法,完成控制器设计。

GA

Question 1: Genetic Algorithms and PID Controller Design

GA can be used to design a PID (Proportional-Integral-Differential) controller for closed loop plant control systems. A common configuration is shown in the following figure 1. setpoint

Notice that the output of this system has an explicit impact on the input of the controller, which explains the “closed-loop” term. In this loop, the output of the system is what we would like to control to the set-point. So, the controller is being fed by the error.

The PID controller is specified by a transfer function of the form.

The objective of the design is to obtain the values of these parameters that optimize the performance of the system. For a given plant transfer function, the performance of the system is typically evaluated by the step response of the system which is of the form shown in figure 2.

The performance is measured in terms of integral squared error (ISE), which is the integral of the square of the difference between the output and the steady state value (1 in this case), along with the values of the step response parameters, the rise-time, the settling time, the maximum overshoot magnitude, which can be addressed as the percentage of the steady-state output. and are important, as they demonstrate how fast a system can work. M is of importance as well, as we may abide by the plant restrictions. So it is important to minimize all these performance measures.

In this problem you are provided by a function that gives you the performance measures if you provide it with values for the parameters. It is a Matlab code that uses other functions of the Matlab control tool box.

Assume that the values of the controller parameters are in the ranges:

  • a) Develop a suitable representation for the solutions with precision of 2 decimal points.
  • b) Formulate a fitness function that you can use to evaluate a solution.
  • c) Implement GA algorithm to solve this problem, use a population of 50 individuals, number of generations of 150, crossover probability of 0.6 and mutation probability of 0.25. Use FPS parent selection strategy and an elitism survival selection strategy keeping the best two individuals across generations. Select a crossover and mutation operators and solve the problem.
  • d) In this part we would like to study the effect of the choice of the GA control parameters:
    • i) Experiment with 3 different values for the number of generations and report the progression of the solutions as a function of the different number of generations.
    • ii) Repeat i) for 3 different population sizes.
    • iii) Experiment with different crossover and mutation probabilities (within the guidelines given in class) and report the results.

Deliverables

A report that contains:

  • a) For part (a) provide a summary on the representation for the solutions. Justify your choice.
  • b) For part (b) provide a summary on the fitness function that you used to evaluate a solution. Justify your choice.
  • c) For part (c) provide a Plot(s) of the fitness of the best solution in each generation throughout the generations. That is the x-axis is generation no., the y-axis is the fitness value of the best solution in that generation.
  • d) For part (d):
    • i) Plot the progress of the solution fitness as a function of the 3 different values for the number of generations. Provide your insight to the behavior of the search as the number of generations is increased.
    • ii) Same as in (i) but for the population experiment.
    • iii) Same as in (ii) but for the crossover/mutation experiment.

The supplementary files and an article on PID controller design are posted in this assignment module.

Question 2: Ant Foraging Behavior and TSP

a) NetLogo is a high-level multi-agent modelling environment, very suitable for fast creation of agent-based models. NetLogo has a large library of sample models. The model “ANTS” demonstrates a colony of ants forages for food. Though each ant follows a set of simple rules, the colony as a whole acts in a sophisticated way. The first part of this question is to experiments on the NetLogo’s ANTS model. The model provides control sliders to change the model parameters.

Run experiments with population (30, 50, 100), diffusion rate (40, 80), evaporation rate (10, 20) and different placements of the food sources. Examining the ant colony’s food foraging and transporting behavior (finish time).

  • b) The target problem in this question is the 29-city TSP (known as Bays29 in literature). The distance between cities is symmetrical, and Euclidean distance measure is used. Each city must be visited once and only once. The objective is to minimize the sum of the Euclidean distances of a complete TSP tour. Ignore curvature of the earth. The 29 city coordinate matrix is listed below.

For this problem do the following:

  1. Code a simple ACO algorithm to solve the problem. To do this you need to select a transition rule, select online and offline pheromone update rules, set a population size and select a stopping criterion.
  2. Run your ACO algorithm.
  3. Perform the following changes on your ACO code (one by one) and compare the results.
    • a) Change the values of pheromone persistence constant 3 times
    • b) Change the values of state transition control parameter 3 times
    • c) Change the population size twice
    • d) Turn off online pheromone update

Deliverables

A report that contains

  • For part (a) report your observations on the behavior of the colonies for the different parameters.
  • For part (b)
    • Report the details of your ACO algorithm specifications
      • (a) Plot the solution progression for each pheromone persistence constant
      • (b) Same as in (3)(a) but for the state transition control parameter
      • (c) Same as in (3)(a) but for the population size parameter
      • (d) Same as in (3)(a) but for the case where the pheromone update is turned-off for each case of the above three scenarios.
  • Summarize your observations and conclusions on the behavior of your ACO algorithm as you change its control parameters.