Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Multiple fixes

  • Loading branch information...
commit 878ce5959069f3e564e4a7eb59cb1efe76beb49e 1 parent 8708ba5
@guilleiguaran authored
View
22 functions.rb
@@ -51,8 +51,8 @@ def objective_z
(0...e).each do |ec|
s3 = 0
(0...m).each do |mc|
- sv1 = sfcv[0] * ge(ci, cj, cm, 0, ce)
- sv2 = sfcv[1] * ge(ci, cj, cm, 1, ce)
+ sv1 = sfcv[0] * ge(ic, jc, mc, 0, ec)
+ sv2 = sfcv[1] * ge(ic, jc, mc, 1, ec)
s4 = sv1 + sv2
end
s2 = s2 + scge[ec]*s3
@@ -69,14 +69,12 @@ def d(ic, jc, mc, v)
end
def d1(ic, jc, mc)
- puts "c #{c[ic][jc]}"
((0.5 * c[ic][jc] * (1 - g[ic][jc][mc] / c[ic][jc]) * (1 - g[ic][jc][mc] / c[ic][jc])) /
( 1 - ([1, x(ic, jc, mc)].min * g[ic][jc][mc] / c[ic][jc])))
end
def x(ic, jc, mc)
- 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]}"
- (q[ic][jc][mc][0] + q[ic][jc][mc][1]) * c[ic][jc] / (g[ic][jc][mc] * s[ic][jc][mc]);
+ (q[ic][jc][mc][0] + q[ic][jc][mc][1]) * c[ic][jc] / (g[ic][jc][mc] * s[ic][mc])
end
def d2(ic, jc, mc)
@@ -85,7 +83,7 @@ def d2(ic, jc, mc)
# "big Q"
def bQ(ic, jc, mc)
- s[ic][jc][mc] * g[ic][jc][mc] / c[ic][jc]
+ s[ic][jc][mc] * g[ic][jc][mc] / c[ic][jc].to_f
end
def fc(ic, jc, mc, v)
@@ -93,15 +91,15 @@ def fc(ic, jc, mc, v)
end
def h(ic, jc, mc, v)
- 0.9 * ((1 - u(ic, jc, mc)) / (1 - y(ic, jc, mc)) + (no(ic, jc, mc)) / (q[ic][jc][mc][v] * c[ic][jc]))
+ 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)
end
def u(ic, jc, mc)
- g[ic][jc][mc] / c[ic][jc];
+ g[ic][jc][mc] / c[ic][jc]
end
def y(ic, jc, mc)
- (q[ic][jc][mc][0] + q[ic][jc][mc][1]) / s[ic][jc][mc]
+ (q[ic][jc][mc][0] + q[ic][jc][mc][1]) / s[ic][mc]
end
def no(ic, jc, mc)
@@ -115,7 +113,7 @@ def no(ic, jc, mc)
end
def xo(ic, jc, mc)
- 0.67 + s[i][j][m] * g[i][j][m] / 600.0
+ 0.67 + s[ic][mc] * g[ic][jc][mc] / 600.0
end
def z(ic, jc, mc)
@@ -123,11 +121,11 @@ def z(ic, jc, mc)
end
def ge(ic, jc, mc, v, ec)
- q[ic][jc][mc][v] * (ge1[v][ec] * x[mc] + ge2[v][ec] * ds[m] + ge3[v][ec] * h(ic, jc, mc, v))
+ q[ic][jc][mc][v] * (ge1[v][ec] * xm + ge2[v][ec] * ds[mc] + ge3[v][ec] * h(ic, jc, mc, v))
end
def fpf(ic, jc, mc)
- index = "0.#{((10 * g[ic][jc][mc] / c[ic][jc]).to_i)}0clea"
+ index = "0.#{((10 * g[ic][jc][mc] / c[ic][jc]).to_i)}0"
pf[index] || 0
end
View
2  info.json
@@ -30,7 +30,7 @@
"0.90": 0.314,
"1.00": 0.090
},
- "f1v": [-1, -1],
+ "f1v": [0, 0],
"f2v": [0.345, 0.345],
"fp3v": [17.98, 17.98],
"ge1": [[7, 3, 12], [14, 9, 11]],
View
4 problem_setup_spea2.rb
@@ -15,8 +15,8 @@
:p_cross => 0.90
}
-(10..13).each do |n|
+(10..10).each do |n|
context.n = n
spea2_instance = Spea2.new(context, options)
- #spea2_instance.search
+ spea2_instance.search
end
View
11 solutions.rb
@@ -3,10 +3,9 @@ module Solutions
# gpow: [1, 5]
def generate_solution(vector)
cpow, gpow = vector
- @g = Array.new(i){ Array.new(n){ Array.new(m) } }
+ @g = Array.new(i){ Array.new(n) { Array.new(m) } }
@c = Array.new(i){ Array.new(n) }
@q = Array.new(i){ Array.new(n) { Array.new(m) { Array.new(2) } } }
- @g = Array.new(i){ Array.new(n) { Array.new(m) } }
(0...i).each do |ic|
c[ic][0] = ci[ic]
@@ -23,7 +22,7 @@ def generate_solution(vector)
(0...i).each do |ic|
(0...m).each do |mc|
- (1...n - 2).each do |j|
+ (1...n - 1).each do |j|
q[ic][j][mc][0] = q[ic][j - 1][mc][0] + (q[ic][n - 1][mc][0] - q[ic][0][mc][0]) / n
q[ic][j][mc][1] = q[ic][j - 1][mc][1] + (q[ic][n - 1][mc][1] - q[ic][0][mc][1]) / n
end
@@ -32,15 +31,15 @@ def generate_solution(vector)
(0...i).each do |ic|
(0...m).each do |mc|
- (1...n - 2).each do |j|
+ (1...n - 1).each do |j|
g[ic][j][mc] = g[ic][0][mc] + (g[ic][n - 1][mc] - g[ic][0][mc]) * ((j/n) ** gpow)
end
end
end
(0...i).each do |ic|
- (1...n - 2).each do |j|
- c[ic][j] = c[ic][0] + (c[ic][n - 1] - c[ic][0]) * ((j/n) ** cpow)
+ (1...n - 1).each do |j|
+ c[ic][j] = c[ic][0] + (c[ic][n - 1] - c[ic][0]) * ((j/n.to_f) ** cpow)
end
end
end
View
4 spea2.rb
@@ -65,7 +65,11 @@ def calculate_objectives(pop, search_space)
p[:vector] = decode(p[:bitstring], search_space)
p[:objectives] = []
context.generate_solution(p[:vector])
+ puts "c: #{context.c}\n\n"
+ puts "q: #{context.q}\n\n"
+ puts "g: #{context.g}\n\n"
context.objectives.each do |objective|
+ puts "#{objective}: #{context.public_send(objective)}"
p[:objectives] << context.public_send(objective) if context.restrictions_meet?
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.