fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / nlpsolver / ThirdParty / EvolutionarySolver / src / net / adaptivebox / deps / behavior / DEGTBehavior.java
blob50666ff4f8f565c17f61346601ab3c105f8ce118
1 /**
2 * Description: The description of differential evolution Generate-and-Test Behavior.
4 #Supported parameters:
5 NAME VALUE_type Range DefaultV Description
6 FACTOR real (0, 1.2] 0.5 DEAgent: scale constant
7 CR real [0, 1] 0.9 DEAgent: crossover constant
8 //Other choices for FACTOR and CR: (0.5, 0.1)
11 * @ Author Create/Modi Note
12 * Xiaofeng Xie May 11, 2004
13 * Xiaofeng Xie Jul 01, 2008
15 * @version 1.0
16 * @Since MAOS1.0
18 * @References:
19 * [1] Storn R, Price K. Differential evolution - a simple and efficient
20 * heuristic for global optimization over continuous spaces. Journal of
21 * Global Optimization, 1997, 11: 341-359
22 * @ The original differential evolution idea
23 * [2] X F Xie, W J Zhang. SWAF: swarm algorithm framework for numerical
24 * optimization. Genetic and Evolutionary Computation Conference (GECCO),
25 * Seattle, WA, USA, 2004: 238-250
26 * -> a generate-and-test behavior
29 package net.adaptivebox.deps.behavior;
31 import net.adaptivebox.goodness.*;
32 import net.adaptivebox.global.*;
33 import net.adaptivebox.knowledge.*;
34 import net.adaptivebox.problem.*;
35 import net.adaptivebox.space.*;
37 public class DEGTBehavior extends AbsGTBehavior implements ILibEngine {
38 public int DVNum = 2; //Number of differential vectors, normally be 1 or 2
39 public double FACTOR = 0.5; //scale constant: (0, 1.2], normally be 0.5
40 public double CR = 0.9; //crossover constant: [0, 1], normally be 0.1 or 0.9
42 //the own memory: store the point that generated in last learning cycle
43 protected SearchPoint pbest_t;
45 public void setPbest(SearchPoint pbest) {
46 pbest_t = pbest;
49 public void generateBehavior(SearchPoint trailPoint, ProblemEncoder problemEncoder) {
50 SearchPoint gbest_t = socialLib.getGbest();
52 BasicPoint[] referPoints = getReferPoints();
53 int DIMENSION = problemEncoder.getDesignSpace().getDimension();
54 int rj = RandomGenerator.intRangeRandom(0, DIMENSION-1);
55 for (int k=0; k<DIMENSION; k++) {
56 if (Math.random()<CR || k == DIMENSION-1) {
57 double Dabcd = 0;
58 for(int i=0; i<referPoints.length; i++) {
59 Dabcd += Math.pow(-1, i%2)*referPoints[i].getLocation()[rj];
61 trailPoint.getLocation()[rj] = gbest_t.getLocation()[rj]+FACTOR*Dabcd;
62 } else {
63 trailPoint.getLocation()[rj] = pbest_t.getLocation()[rj];
65 rj = (rj+1)%DIMENSION;
69 public void testBehavior(SearchPoint trailPoint, IGoodnessCompareEngine qualityComparator) {
70 Library.replace(qualityComparator, trailPoint, pbest_t);
73 protected SearchPoint[] getReferPoints() {
74 SearchPoint[] referPoints = new SearchPoint[DVNum*2];
75 for(int i=0; i<referPoints.length; i++) {
76 referPoints[i] = socialLib.getSelectedPoint(RandomGenerator.intRangeRandom(0, socialLib.getPopSize()-1));
78 return referPoints;