Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Multiple fixes

  • Loading branch information...
commit 878ce5959069f3e564e4a7eb59cb1efe76beb49e 1 parent 8708ba5
Guillermo Iguaran authored
22 functions.rb
@@ -51,8 +51,8 @@ def objective_z
51 51 (0...e).each do |ec|
52 52 s3 = 0
53 53 (0...m).each do |mc|
54   - sv1 = sfcv[0] * ge(ci, cj, cm, 0, ce)
55   - sv2 = sfcv[1] * ge(ci, cj, cm, 1, ce)
  54 + sv1 = sfcv[0] * ge(ic, jc, mc, 0, ec)
  55 + sv2 = sfcv[1] * ge(ic, jc, mc, 1, ec)
56 56 s4 = sv1 + sv2
57 57 end
58 58 s2 = s2 + scge[ec]*s3
@@ -69,14 +69,12 @@ def d(ic, jc, mc, v)
69 69 end
70 70
71 71 def d1(ic, jc, mc)
72   - puts "c #{c[ic][jc]}"
73 72 ((0.5 * c[ic][jc] * (1 - g[ic][jc][mc] / c[ic][jc]) * (1 - g[ic][jc][mc] / c[ic][jc])) /
74 73 ( 1 - ([1, x(ic, jc, mc)].min * g[ic][jc][mc] / c[ic][jc])))
75 74 end
76 75
77 76 def x(ic, jc, mc)
78   - puts "q #{q[ic][jc][mc][0]}\n q #{q[ic][jc][mc][1]} \n c #{c[ic][jc]} \n g #{g[ic][jc][mc]} \n s #{s[ic][jc][mc]}"
79   - (q[ic][jc][mc][0] + q[ic][jc][mc][1]) * c[ic][jc] / (g[ic][jc][mc] * s[ic][jc][mc]);
  77 + (q[ic][jc][mc][0] + q[ic][jc][mc][1]) * c[ic][jc] / (g[ic][jc][mc] * s[ic][mc])
80 78 end
81 79
82 80 def d2(ic, jc, mc)
@@ -85,7 +83,7 @@ def d2(ic, jc, mc)
85 83
86 84 # "big Q"
87 85 def bQ(ic, jc, mc)
88   - s[ic][jc][mc] * g[ic][jc][mc] / c[ic][jc]
  86 + s[ic][jc][mc] * g[ic][jc][mc] / c[ic][jc].to_f
89 87 end
90 88
91 89 def fc(ic, jc, mc, v)
@@ -93,15 +91,15 @@ def fc(ic, jc, mc, v)
93 91 end
94 92
95 93 def h(ic, jc, mc, v)
96   - 0.9 * ((1 - u(ic, jc, mc)) / (1 - y(ic, jc, mc)) + (no(ic, jc, mc)) / (q[ic][jc][mc][v] * c[ic][jc]))
  94 + 0.9 * ((1 - u(ic, jc, mc)) / (1 - y(ic, jc, mc)).to_f + (no(ic, jc, mc)) / (q[ic][jc][mc][v] * c[ic][jc]).to_f)
97 95 end
98 96
99 97 def u(ic, jc, mc)
100   - g[ic][jc][mc] / c[ic][jc];
  98 + g[ic][jc][mc] / c[ic][jc]
101 99 end
102 100
103 101 def y(ic, jc, mc)
104   - (q[ic][jc][mc][0] + q[ic][jc][mc][1]) / s[ic][jc][mc]
  102 + (q[ic][jc][mc][0] + q[ic][jc][mc][1]) / s[ic][mc]
105 103 end
106 104
107 105 def no(ic, jc, mc)
@@ -115,7 +113,7 @@ def no(ic, jc, mc)
115 113 end
116 114
117 115 def xo(ic, jc, mc)
118   - 0.67 + s[i][j][m] * g[i][j][m] / 600.0
  116 + 0.67 + s[ic][mc] * g[ic][jc][mc] / 600.0
119 117 end
120 118
121 119 def z(ic, jc, mc)
@@ -123,11 +121,11 @@ def z(ic, jc, mc)
123 121 end
124 122
125 123 def ge(ic, jc, mc, v, ec)
126   - q[ic][jc][mc][v] * (ge1[v][ec] * x[mc] + ge2[v][ec] * ds[m] + ge3[v][ec] * h(ic, jc, mc, v))
  124 + q[ic][jc][mc][v] * (ge1[v][ec] * xm + ge2[v][ec] * ds[mc] + ge3[v][ec] * h(ic, jc, mc, v))
127 125 end
128 126
129 127 def fpf(ic, jc, mc)
130   - index = "0.#{((10 * g[ic][jc][mc] / c[ic][jc]).to_i)}0clea"
  128 + index = "0.#{((10 * g[ic][jc][mc] / c[ic][jc]).to_i)}0"
131 129 pf[index] || 0
132 130 end
133 131
2  info.json
@@ -30,7 +30,7 @@
30 30 "0.90": 0.314,
31 31 "1.00": 0.090
32 32 },
33   - "f1v": [-1, -1],
  33 + "f1v": [0, 0],
34 34 "f2v": [0.345, 0.345],
35 35 "fp3v": [17.98, 17.98],
36 36 "ge1": [[7, 3, 12], [14, 9, 11]],
4 problem_setup_spea2.rb
@@ -15,8 +15,8 @@
15 15 :p_cross => 0.90
16 16 }
17 17
18   -(10..13).each do |n|
  18 +(10..10).each do |n|
19 19 context.n = n
20 20 spea2_instance = Spea2.new(context, options)
21   - #spea2_instance.search
  21 + spea2_instance.search
22 22 end
11 solutions.rb
@@ -3,10 +3,9 @@ module Solutions
3 3 # gpow: [1, 5]
4 4 def generate_solution(vector)
5 5 cpow, gpow = vector
6   - @g = Array.new(i){ Array.new(n){ Array.new(m) } }
  6 + @g = Array.new(i){ Array.new(n) { Array.new(m) } }
7 7 @c = Array.new(i){ Array.new(n) }
8 8 @q = Array.new(i){ Array.new(n) { Array.new(m) { Array.new(2) } } }
9   - @g = Array.new(i){ Array.new(n) { Array.new(m) } }
10 9
11 10 (0...i).each do |ic|
12 11 c[ic][0] = ci[ic]
@@ -23,7 +22,7 @@ def generate_solution(vector)
23 22
24 23 (0...i).each do |ic|
25 24 (0...m).each do |mc|
26   - (1...n - 2).each do |j|
  25 + (1...n - 1).each do |j|
27 26 q[ic][j][mc][0] = q[ic][j - 1][mc][0] + (q[ic][n - 1][mc][0] - q[ic][0][mc][0]) / n
28 27 q[ic][j][mc][1] = q[ic][j - 1][mc][1] + (q[ic][n - 1][mc][1] - q[ic][0][mc][1]) / n
29 28 end
@@ -32,15 +31,15 @@ def generate_solution(vector)
32 31
33 32 (0...i).each do |ic|
34 33 (0...m).each do |mc|
35   - (1...n - 2).each do |j|
  34 + (1...n - 1).each do |j|
36 35 g[ic][j][mc] = g[ic][0][mc] + (g[ic][n - 1][mc] - g[ic][0][mc]) * ((j/n) ** gpow)
37 36 end
38 37 end
39 38 end
40 39
41 40 (0...i).each do |ic|
42   - (1...n - 2).each do |j|
43   - c[ic][j] = c[ic][0] + (c[ic][n - 1] - c[ic][0]) * ((j/n) ** cpow)
  41 + (1...n - 1).each do |j|
  42 + c[ic][j] = c[ic][0] + (c[ic][n - 1] - c[ic][0]) * ((j/n.to_f) ** cpow)
44 43 end
45 44 end
46 45 end
4 spea2.rb
@@ -65,7 +65,11 @@ def calculate_objectives(pop, search_space)
65 65 p[:vector] = decode(p[:bitstring], search_space)
66 66 p[:objectives] = []
67 67 context.generate_solution(p[:vector])
  68 + puts "c: #{context.c}\n\n"
  69 + puts "q: #{context.q}\n\n"
  70 + puts "g: #{context.g}\n\n"
68 71 context.objectives.each do |objective|
  72 + puts "#{objective}: #{context.public_send(objective)}"
69 73 p[:objectives] << context.public_send(objective) if context.restrictions_meet?
70 74 end
71 75 end

0 comments on commit 878ce59

Please sign in to comment.
Something went wrong with that request. Please try again.