Class: Problem::FSP

Inherits:
Object
  • Object
show all
Defined in:
lib/opt_alg_framework/problem/fsp.rb

Overview

require ‘opt_alg_framework/problem/problem_interface’ FSP class have a inner class Schedule

Defined Under Namespace

Classes: Production

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFSP

Initialize the FSP problem with a empty schedule



35
36
37
# File 'lib/opt_alg_framework/problem/fsp.rb', line 35

def initialize
  @production = Production.new
end

Instance Attribute Details

#default_solutionObject (readonly)

Returns the value of attribute default_solution.



6
7
8
# File 'lib/opt_alg_framework/problem/fsp.rb', line 6

def default_solution
  @default_solution
end

Instance Method Details

#fitness(solution) ⇒ Object



46
47
48
49
50
# File 'lib/opt_alg_framework/problem/fsp.rb', line 46

def fitness(solution)
  schedule = @production.reorder_schedule(solution)
  makespan(schedule: schedule, task: schedule.row_size - 1,
            machine: schedule.column_size - 1, memory: {})
end

#load_instance(path) ⇒ Object

Load the production schedule from a file



40
41
42
43
44
# File 'lib/opt_alg_framework/problem/fsp.rb', line 40

def load_instance(path)
  transpose = block_given? ? yield : false
  @production.build_from_file(path, transpose)
  @default_solution = (0...@production.schedule.row_size).to_a
end