vcs 0.1 → 0.2.148
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +17 -3
- data/bin/vcs +57 -34
- data/doc/jamis.rb +564 -0
- data/ruby_ex/abstract.rb +254 -0
- data/ruby_ex/abstract_node.rb +85 -0
- data/ruby_ex/algorithms/simulated_annealing.rb +140 -0
- data/ruby_ex/array_each_pair.rb +18 -0
- data/ruby_ex/ask.rb +101 -0
- data/ruby_ex/attributed_class.rb +302 -0
- data/ruby_ex/cache.rb +373 -0
- data/ruby_ex/checkout.rb +12 -0
- data/ruby_ex/choose.rb +271 -0
- data/ruby_ex/commands.rb +18 -0
- data/ruby_ex/commands/command.rb +401 -0
- data/ruby_ex/commands/datas.rb +16 -0
- data/ruby_ex/commands/datas/data.rb +33 -0
- data/ruby_ex/commands/datas/factory.rb +66 -0
- data/ruby_ex/commands/factory.rb +66 -0
- data/ruby_ex/commands/helpers.rb +67 -0
- data/ruby_ex/commands/pipe.rb +64 -0
- data/ruby_ex/commands/runners.rb +17 -0
- data/ruby_ex/commands/runners/exec.rb +49 -0
- data/ruby_ex/commands/runners/fork.rb +97 -0
- data/ruby_ex/commands/runners/runner.rb +107 -0
- data/ruby_ex/commands/seq.rb +27 -0
- data/ruby_ex/config_file.rb +96 -0
- data/ruby_ex/const_regexp.rb +59 -0
- data/ruby_ex/daemon.rb +134 -0
- data/ruby_ex/diff.rb +667 -0
- data/ruby_ex/dlogger.rb +62 -0
- data/ruby_ex/drb/dispatcher.rb +252 -0
- data/ruby_ex/drb/dispatcher_server_test.rb +29 -0
- data/ruby_ex/drb/drb_observable.rb +97 -0
- data/ruby_ex/drb/drb_observable_pool.rb +27 -0
- data/ruby_ex/drb/drb_service.rb +43 -0
- data/ruby_ex/drb/drb_undumped_attributes.rb +55 -0
- data/ruby_ex/drb/drb_undumped_indexed_object.rb +54 -0
- data/ruby_ex/drb/insecure_protected_methods.rb +103 -0
- data/ruby_ex/drb/session_client_test.rb +40 -0
- data/ruby_ex/drb/session_manager.rb +246 -0
- data/ruby_ex/drb/session_server.rb +53 -0
- data/ruby_ex/dtime.rb +143 -0
- data/ruby_ex/dumpable_proc.rb +63 -0
- data/ruby_ex/exception.rb +32 -0
- data/ruby_ex/filetype.rb +229 -0
- data/ruby_ex/fileutils_ex.rb +44 -0
- data/ruby_ex/fold.rb +58 -0
- data/ruby_ex/generate_id.rb +44 -0
- data/ruby_ex/hookable.rb +262 -0
- data/ruby_ex/hooker.rb +54 -0
- data/ruby_ex/inactive_timeout.rb +137 -0
- data/ruby_ex/indexed_node.rb +66 -0
- data/ruby_ex/io_marshal.rb +100 -0
- data/ruby_ex/ioo.rb +194 -0
- data/ruby_ex/labeled_node.rb +63 -0
- data/ruby_ex/logger_observer.rb +23 -0
- data/ruby_ex/md5sum.rb +66 -0
- data/ruby_ex/mktemp.rb +208 -0
- data/ruby_ex/module/attr_once.rb +36 -0
- data/ruby_ex/module/autoload_tree.rb +75 -0
- data/ruby_ex/module/hierarchy.rb +335 -0
- data/ruby_ex/module/instance_method_visibility.rb +73 -0
- data/ruby_ex/module_ex.rb +11 -0
- data/ruby_ex/node.rb +80 -0
- data/ruby_ex/object_monitor.rb +145 -0
- data/ruby_ex/object_monitor_activity.rb +33 -0
- data/ruby_ex/observable.rb +140 -0
- data/ruby_ex/observable_pool.rb +293 -0
- data/ruby_ex/orderedhash.rb +252 -0
- data/ruby_ex/pathname_ex.rb +152 -0
- data/ruby_ex/pp_hierarchy.rb +29 -0
- data/ruby_ex/pseudo_cache.rb +190 -0
- data/ruby_ex/queue.rb +56 -0
- data/ruby_ex/random_generators.rb +25 -0
- data/ruby_ex/random_generators/random_generator.rb +31 -0
- data/ruby_ex/random_generators/ruby.rb +23 -0
- data/ruby_ex/safe_eval.rb +348 -0
- data/ruby_ex/sendmail.rb +215 -0
- data/ruby_ex/service_manager.rb +121 -0
- data/ruby_ex/session/administrable.rb +120 -0
- data/ruby_ex/session/client.rb +153 -0
- data/ruby_ex/session/const.rb +18 -0
- data/ruby_ex/session/dispatcher.rb +184 -0
- data/ruby_ex/session/error.rb +21 -0
- data/ruby_ex/session/fetchable.rb +57 -0
- data/ruby_ex/session/fetcher.rb +62 -0
- data/ruby_ex/session/hookable.rb +26 -0
- data/ruby_ex/session/profile.rb +110 -0
- data/ruby_ex/session/server.rb +582 -0
- data/ruby_ex/session/test/administrable_test.rb +337 -0
- data/ruby_ex/session/test/basic_test.rb +523 -0
- data/ruby_ex/session/test/dispatcher_test.rb +409 -0
- data/ruby_ex/session/test/fetchable_test.rb +119 -0
- data/ruby_ex/session/test/sub_server_test.rb +188 -0
- data/ruby_ex/shuffle.rb +30 -0
- data/ruby_ex/spring.rb +136 -0
- data/ruby_ex/spring_set.rb +137 -0
- data/ruby_ex/string_ex.rb +28 -0
- data/ruby_ex/symtbl.rb +106 -0
- data/ruby_ex/synflow.rb +474 -0
- data/ruby_ex/test/unit/ui/yaml/testrunner.rb +164 -0
- data/ruby_ex/thread_mutex.rb +10 -0
- data/ruby_ex/timeout_ex.rb +81 -0
- data/ruby_ex/top_down.rb +73 -0
- data/ruby_ex/trace.rb +26 -0
- data/ruby_ex/uri/druby.rb +81 -0
- data/ruby_ex/uri/file.rb +65 -0
- data/ruby_ex/uri/ftp_ex.rb +37 -0
- data/ruby_ex/uri/http_ex.rb +43 -0
- data/ruby_ex/uri/ssh.rb +92 -0
- data/ruby_ex/uri/svn.rb +118 -0
- data/ruby_ex/uri_ex.rb +45 -0
- data/ruby_ex/verbose_object.rb +30 -0
- data/ruby_ex/version.rb +66 -0
- data/ruby_ex/yaml/basenode_ext.rb +63 -0
- data/ruby_ex/yaml/chop_header.rb +23 -0
- data/ruby_ex/yaml/transform.rb +449 -0
- data/ruby_ex/yaml/yregexpath.rb +76 -0
- data/src/changelog.rb +28 -18
- data/src/conflict.rb +20 -0
- data/src/diff.rb +18 -0
- data/src/diffstat.rb +9 -3
- data/src/last_changed_date.rb +18 -0
- data/src/mail.rb +33 -65
- data/src/message.rb +15 -9
- data/src/mycommit.rb +29 -14
- data/src/news.rb +24 -3
- data/src/status.rb +17 -0
- data/src/svn.rb +2 -2
- data/src/vcs.rb +24 -3
- metadata +124 -5
- data/lrdetools.rb +0 -12
data/ruby_ex/abstract.rb
ADDED
@@ -0,0 +1,254 @@
|
|
1
|
+
# Copyright: Copyright (c) 2004 Nicolas Despres. All rights reserved.
|
2
|
+
# Author: Nicolas Despres <polrop@lrde.epita.fr>.
|
3
|
+
# License: Gnu General Public License.
|
4
|
+
|
5
|
+
# $LastChangedBy: ertai $
|
6
|
+
# $Id: abstract.rb 210 2005-05-05 19:59:45Z ertai $
|
7
|
+
|
8
|
+
|
9
|
+
#FIXME: find a way to be thread safe.
|
10
|
+
|
11
|
+
|
12
|
+
require 'module/instance_method_visibility'
|
13
|
+
|
14
|
+
|
15
|
+
module Concrete; end
|
16
|
+
|
17
|
+
|
18
|
+
# When this module is included into a class, this class can't be instantiate
|
19
|
+
# any more until the Concrete module is included too. This module cannot be
|
20
|
+
# included if the Concrete module has been included before in one of the
|
21
|
+
# class' superclass.
|
22
|
+
module Abstract
|
23
|
+
|
24
|
+
def self.included(klass)
|
25
|
+
super
|
26
|
+
if klass.include?(Concrete)
|
27
|
+
raise(TypeError, "#{klass} - cannot make abstract a concrete class")
|
28
|
+
end
|
29
|
+
klass.module_eval do
|
30
|
+
class << self
|
31
|
+
unless private_method_defined?(:concrete_new)
|
32
|
+
alias_method :concrete_new, :new
|
33
|
+
visibility = instance_method_visibility('new')
|
34
|
+
def new(*args, &block)
|
35
|
+
raise(TypeError, "cannot instantiate an abstract class #{name}")
|
36
|
+
end
|
37
|
+
send(visibility, :new)
|
38
|
+
private :concrete_new
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end # module Abstract
|
45
|
+
|
46
|
+
|
47
|
+
# Include this module in an abstract class to make it concrete and so, to be
|
48
|
+
# able to instantiate it again. This module can be included if and only if the
|
49
|
+
# Abstract module has been included before in one of the class' superclass.
|
50
|
+
module Concrete
|
51
|
+
|
52
|
+
def self.included(klass)
|
53
|
+
super
|
54
|
+
unless klass.include?(Abstract)
|
55
|
+
raise(TypeError, "#{klass} - not an abstract class")
|
56
|
+
end
|
57
|
+
klass.module_eval do
|
58
|
+
class << self
|
59
|
+
visibility = instance_method_visibility('new')
|
60
|
+
def new(*args, &block)
|
61
|
+
concrete_new(*args, &block)
|
62
|
+
end
|
63
|
+
send(visibility, :new)
|
64
|
+
end
|
65
|
+
|
66
|
+
def is_a?(klass)
|
67
|
+
klass == Abstract ? false : super(klass)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end # module Concrete
|
73
|
+
|
74
|
+
|
75
|
+
class Class
|
76
|
+
|
77
|
+
def abstract
|
78
|
+
include Abstract
|
79
|
+
end
|
80
|
+
|
81
|
+
def concrete
|
82
|
+
include Concrete
|
83
|
+
end
|
84
|
+
|
85
|
+
def abstract?
|
86
|
+
include?(Abstract) ? (not include?(Concrete)) : false;
|
87
|
+
end
|
88
|
+
|
89
|
+
end # class Class
|
90
|
+
|
91
|
+
|
92
|
+
if (not defined? ABSTRACT_TESTED) and (defined? TEST_MODE or __FILE__ == $0)
|
93
|
+
ABSTRACT_TESTED = true
|
94
|
+
|
95
|
+
|
96
|
+
require 'test/unit/ui/yaml/testrunner'
|
97
|
+
require 'singleton'
|
98
|
+
|
99
|
+
|
100
|
+
class AbstractTest < Test::Unit::TestCase
|
101
|
+
|
102
|
+
class R; end
|
103
|
+
|
104
|
+
class A
|
105
|
+
include Abstract
|
106
|
+
|
107
|
+
attr_reader :initialized
|
108
|
+
|
109
|
+
def initialize(toto=nil)
|
110
|
+
@initialized = true
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
class B < A; end
|
116
|
+
|
117
|
+
def test_abstract
|
118
|
+
assert_nothing_raised { R.new }
|
119
|
+
assert(A.include?(Abstract))
|
120
|
+
assert_raises(TypeError) { A.new }
|
121
|
+
assert_raises(TypeError) { B.new }
|
122
|
+
assert_raises(TypeError) do
|
123
|
+
AbstractTest.module_eval %q{
|
124
|
+
class D
|
125
|
+
include Concrete
|
126
|
+
include Abstract
|
127
|
+
end
|
128
|
+
}
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
class C < A
|
133
|
+
include Concrete
|
134
|
+
|
135
|
+
attr_reader :toto
|
136
|
+
|
137
|
+
def initialize(toto=nil)
|
138
|
+
super
|
139
|
+
@toto = toto
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
class CC < C; end
|
144
|
+
|
145
|
+
def test_concrete
|
146
|
+
assert_raises(TypeError) do
|
147
|
+
AbstractTest.module_eval %q{ class D; include Concrete; end }
|
148
|
+
end
|
149
|
+
assert(C.new.initialized)
|
150
|
+
assert_nil(C.new.toto)
|
151
|
+
assert_equal('toto', C.new('toto').toto)
|
152
|
+
assert(CC.new.initialized)
|
153
|
+
assert_equal(SC.instance, SC.instance)
|
154
|
+
assert_equal(SCC.instance, SCC.instance)
|
155
|
+
assert_not_equal(SC.instance, SCC.instance)
|
156
|
+
end
|
157
|
+
|
158
|
+
class SA
|
159
|
+
include Singleton
|
160
|
+
include Abstract
|
161
|
+
|
162
|
+
attr_reader :initialized
|
163
|
+
|
164
|
+
def initialize(toto=nil)
|
165
|
+
@initialized = true
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
class SB < SA; end
|
171
|
+
|
172
|
+
def test_abstract_singleton
|
173
|
+
assert(SA.include?(Abstract))
|
174
|
+
assert_raises(NoMethodError) { SA.new }
|
175
|
+
assert_raises(TypeError) { SA.instance }
|
176
|
+
assert_raises(NoMethodError) { SB.new }
|
177
|
+
assert_raises(TypeError) { SB.instance }
|
178
|
+
assert_raises(TypeError) do
|
179
|
+
AbstractTest.module_eval %q{
|
180
|
+
class SD; include Concrete; include Abstract; end
|
181
|
+
}
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
class SC < SA
|
186
|
+
include Concrete
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
class SCC < SC; end
|
191
|
+
|
192
|
+
def test_concrete_singleton
|
193
|
+
assert_raises(TypeError) do
|
194
|
+
AbstractTest.module_eval %q{ class SD; include Concrete; end }
|
195
|
+
end
|
196
|
+
assert_raises(NoMethodError) { SC.new }
|
197
|
+
assert(SC.instance.initialized)
|
198
|
+
assert(SCC.instance.initialized)
|
199
|
+
assert_equal(SC.instance, SC.instance)
|
200
|
+
assert_equal(SCC.instance, SCC.instance)
|
201
|
+
assert_not_equal(SC.instance, SCC.instance)
|
202
|
+
end
|
203
|
+
|
204
|
+
class IsA; include Abstract; end
|
205
|
+
class IsB < IsA; include Concrete; end
|
206
|
+
|
207
|
+
def test_is_a
|
208
|
+
assert(! IsB.new.is_a?(Abstract))
|
209
|
+
assert(IsB.new.is_a?(IsA))
|
210
|
+
assert(IsB.include?(Abstract))
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_abstract?
|
214
|
+
assert(IsA.abstract?)
|
215
|
+
assert(! IsB.abstract?)
|
216
|
+
end
|
217
|
+
|
218
|
+
class AArg
|
219
|
+
include Abstract
|
220
|
+
|
221
|
+
attr_reader :arg
|
222
|
+
|
223
|
+
def initialize(arg)
|
224
|
+
@arg = arg
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
228
|
+
|
229
|
+
class CArg < AArg
|
230
|
+
include Concrete
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_arg
|
234
|
+
assert_nothing_raised { CArg.new('toto') }
|
235
|
+
assert_raises(ArgumentError) { CArg.new }
|
236
|
+
end
|
237
|
+
|
238
|
+
class AA_; include Abstract; end
|
239
|
+
class BB_ < AA_; include Abstract; end
|
240
|
+
class CC_ < BB_; include Concrete; end
|
241
|
+
class DD_ < CC_; include Concrete; end
|
242
|
+
|
243
|
+
def test_double_abstract
|
244
|
+
assert_raises(TypeError) { AA_.new }
|
245
|
+
assert_raises(TypeError) { BB_.new }
|
246
|
+
assert_nothing_raised { CC_.new }
|
247
|
+
assert_nothing_raised { DD_.new }
|
248
|
+
end
|
249
|
+
|
250
|
+
end # class AbstractTest
|
251
|
+
|
252
|
+
|
253
|
+
end
|
254
|
+
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# Copyright: Copyright (c) 2004 Nicolas Despres. All rights reserved.
|
2
|
+
# Author: Nicolas Despres <polrop@lrde.epita.fr>.
|
3
|
+
# License: Gnu General Public License.
|
4
|
+
|
5
|
+
# $LastChangedBy: ertai $
|
6
|
+
# $Id: abstract_node.rb 186 2005-04-03 00:07:45Z ertai $
|
7
|
+
|
8
|
+
|
9
|
+
require 'abstract'
|
10
|
+
require 'array_each_pair'
|
11
|
+
|
12
|
+
class AbstractNode
|
13
|
+
include Abstract
|
14
|
+
|
15
|
+
def initialize(data=nil, *sub_nodes)
|
16
|
+
@data = data
|
17
|
+
self.each_node { |sub_node| check_sub_node_type(sub_node) }
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :data, :sub_nodes
|
21
|
+
|
22
|
+
def [](index)
|
23
|
+
@sub_nodes[index]
|
24
|
+
end
|
25
|
+
|
26
|
+
def []=(index, sub_node)
|
27
|
+
check_sub_node_type(sub_node)
|
28
|
+
@sub_nodes[index] = sub_node
|
29
|
+
end
|
30
|
+
|
31
|
+
def merge!(sub_nodes)
|
32
|
+
sub_nodes.each { |index, sub_node| self[index] = sub_node }
|
33
|
+
end
|
34
|
+
|
35
|
+
def each_pair(&block)
|
36
|
+
@sub_nodes.each_pair { |index, sub_node| block[index, sub_node] }
|
37
|
+
end
|
38
|
+
|
39
|
+
def each_node(&block)
|
40
|
+
@sub_nodes.each_pair { |index, sub_node| block[sub_node] }
|
41
|
+
end
|
42
|
+
|
43
|
+
alias :each :each_node
|
44
|
+
|
45
|
+
def each_index(&block)
|
46
|
+
@sub_nodes.each_pair { |index, sub_node| block[index] }
|
47
|
+
end
|
48
|
+
|
49
|
+
def delete(index)
|
50
|
+
@sub_nodes.delete(index)
|
51
|
+
end
|
52
|
+
|
53
|
+
def nb_sub_nodes
|
54
|
+
@sub_nodes.size
|
55
|
+
end
|
56
|
+
|
57
|
+
alias size nb_sub_nodes
|
58
|
+
alias length nb_sub_nodes
|
59
|
+
|
60
|
+
def leaf?
|
61
|
+
@sub_nodes.empty?
|
62
|
+
end
|
63
|
+
|
64
|
+
def pre_depth_first(index=nil, &block)
|
65
|
+
block[index, self]
|
66
|
+
@sub_nodes.each_pair do |index, sub_node|
|
67
|
+
sub_node.pre_depth_first(index, &block)
|
68
|
+
end
|
69
|
+
nil
|
70
|
+
end
|
71
|
+
|
72
|
+
# FIXME: implement me
|
73
|
+
# def breadth_first(&block)
|
74
|
+
# end
|
75
|
+
|
76
|
+
protected
|
77
|
+
def check_sub_node_type(sub_node)
|
78
|
+
unless sub_node.is_a?(self.class)
|
79
|
+
raise(TypeError, "`#{sub_node}' - must be a #{self.class}")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end # class AbstractNode
|
84
|
+
|
85
|
+
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
|
+
# License:: GNU General Public License (GPL).
|
4
|
+
# Revision:: $Id$
|
5
|
+
|
6
|
+
require 'string_ex'
|
7
|
+
|
8
|
+
module Algorithms
|
9
|
+
|
10
|
+
class SimulatedAnnealing
|
11
|
+
|
12
|
+
# Example:
|
13
|
+
#
|
14
|
+
# obj = MySimulatedAnnealingObject.new
|
15
|
+
#
|
16
|
+
# SimulatedAnnealing.new(
|
17
|
+
# :support => obj,
|
18
|
+
# :global_thresold => 200,
|
19
|
+
# :step_multiplicator => 0.63,
|
20
|
+
# :initial_temperature => 10,
|
21
|
+
# :initial_cost => obj.cost,
|
22
|
+
# :iteration_modulus => 500, # display status once a 500
|
23
|
+
# :step_modulus => 5000 # change the temperature once a 5000
|
24
|
+
# )
|
25
|
+
#
|
26
|
+
def initialize ( opts )
|
27
|
+
@support = opts[:support]
|
28
|
+
@global_thresold = opts[:global_thresold]
|
29
|
+
@step_multiplicator = opts[:step_multiplicator]
|
30
|
+
@temperature = opts[:initial_temperature]
|
31
|
+
@cur_cost = opts[:initial_cost]
|
32
|
+
@output = opts[:output] || STDOUT
|
33
|
+
@iteration_modulus = opts[:iteration_modulus] || 1
|
34
|
+
@step_modulus = opts[:step_modulus] || 1
|
35
|
+
@progression = ' '
|
36
|
+
@diff_cost = 0
|
37
|
+
@iteration = 0
|
38
|
+
@probability_threshold = 0
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def run
|
43
|
+
@output.puts '---'
|
44
|
+
while @cur_cost > @global_thresold
|
45
|
+
# puts "Iteration(#{it}) #{@cur_cost}"
|
46
|
+
@transition = @support.choose_transition()
|
47
|
+
@diff_cost = @support.transition_cost(@cur_cost, @transition)
|
48
|
+
|
49
|
+
@iteration += 1
|
50
|
+
if (@iteration % @step_modulus).zero?
|
51
|
+
@temperature *= @step_multiplicator
|
52
|
+
end
|
53
|
+
|
54
|
+
if @diff_cost > 0
|
55
|
+
@probability_threshold = Math.exp(- @diff_cost.to_f / @temperature)
|
56
|
+
@proba = choose_probability()
|
57
|
+
if @proba < @probability_threshold
|
58
|
+
progression '+'
|
59
|
+
else
|
60
|
+
progression ' '
|
61
|
+
next
|
62
|
+
end
|
63
|
+
else
|
64
|
+
@probability_threshold = 1
|
65
|
+
@proba = 1
|
66
|
+
progression((@diff_cost.zero?)? '=' : '-')
|
67
|
+
end
|
68
|
+
|
69
|
+
@support.apply_transition(@transition)
|
70
|
+
@cur_cost += @diff_cost
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def disp ( output=@output )
|
76
|
+
args = [ @progression, @diff_cost.abs, @temperature,
|
77
|
+
@proba, @probability_threshold, @cur_cost ]
|
78
|
+
fmt = '- { diff: %s%-7d, temp: %-4f, ' +
|
79
|
+
'prob: %-7f, thres: %-7f, cost: %-5s }'
|
80
|
+
output.puts fmt % args
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
def summary
|
85
|
+
@output.puts %Q[
|
86
|
+
|---
|
87
|
+
|Found a mininum: #@cur_cost
|
88
|
+
|Temperature at the end: #@temperature
|
89
|
+
|Nb iterations: #@iteration
|
90
|
+
].head_cut!
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
def progression ( x )
|
95
|
+
@progression = x
|
96
|
+
disp if (@iteration % @iteration_modulus).zero?
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def choose_probability
|
101
|
+
rand()
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
module Support
|
106
|
+
|
107
|
+
def included ( aModule )
|
108
|
+
|
109
|
+
aModule.module_eval do
|
110
|
+
|
111
|
+
#
|
112
|
+
# Return a transition which can be applied by apply_transition.
|
113
|
+
#
|
114
|
+
def choose_transition
|
115
|
+
raise NotImplementedError
|
116
|
+
end
|
117
|
+
|
118
|
+
#
|
119
|
+
# Return a cost difference
|
120
|
+
#
|
121
|
+
def transition_cost ( current_cost, transition )
|
122
|
+
raise NotImplementedError
|
123
|
+
end
|
124
|
+
|
125
|
+
#
|
126
|
+
# Apply the given transition to your current object.
|
127
|
+
#
|
128
|
+
def apply_transition ( transition )
|
129
|
+
raise NotImplementedError
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
end # module Support
|
137
|
+
|
138
|
+
end # class SimulatedAnnealing
|
139
|
+
|
140
|
+
end # module Algorithms
|