download: Population.java

File Population.java, 1.8 kB (added by dumoulin, 3 years ago)
Line 
1package Model;
2
3import viabController.Point;
4
5/**
6 * <B>Population model</B>
7 * Represents the growth of a population in a limited space.
8 * The size of the population x can evolve thanks to a growing rate y.
9 *
10 * @author Florent LOPEZ
11 */
12public class Population extends Dynamic_System {
13
14    Population() {
15
16        this.nbDim_ = 2;
17        this.nbDimControl_ = 1;
18        this.initSystem();
19
20        this.lowerBoundState_[0] = 0.2f;
21        this.upperBoundState_[0] = 3;
22        this.lowerBoundState_[1] = -2;
23        this.upperBoundState_[1] = 2;
24        this.lowerBoundControl_[0] = -0.5f;
25        this.upperBoundControl_[0] = 0.5f;
26        this.dt_ = 0.2;
27
28        this.theoricCurves_ = true;
29        this.nbLineTheoric = 2;
30    }
31
32    /**
33     * Dynamics: x' = xy
34     * y'=u
35     */
36    @Override
37    public Point computePhi(Point inP, Point inU) {
38        Point res = new Point(inP.nbDim_);
39        res.vect_[ 0] = (float) (inP.vect_[ 0] * inP.vect_[1]);
40        res.vect_[ 1] = inU.vect_[ 0];
41        return res;
42    }
43
44    @Override
45    public double fTheoric(double inX, int i) {
46        if (i == 1) {
47            return Math.sqrt(2 * this.upperBoundControl_[0] * Math.log(this.upperBoundState_[0] / inX));
48        } else {
49            return -Math.sqrt(2 * this.upperBoundControl_[0] * Math.log(inX / this.lowerBoundState_[0]));
50        }
51    }
52
53    /**
54     * computes the real derivative
55     * @param inP normalized point
56     * @param inU control
57     * @param indice indice
58     * @return derivative at the point inP
59     */
60    @Override
61    public Point derivative(Point inP, Point inU, int indice, float betaHNorme) {
62        Point res = new Point(inP.nbDim_);
63        //inP = this.deNorme(inP);
64        res.vect_[0] = (float) 0;
65        res.vect_[1] = (float) 1;
66        return this.norme(res);
67    }
68}