A
Axel Etzold
Dear all,
in Ruby-Gsl's multidimensional minimization, the FMinimizer function
requires an equal number of variables and parameters, as
illustrated in the example
include GSL::MultiMin
my_f = Proc.new { |v, params|
x = v[0]; y = v[1]
p0 = params[0]; p1 = params[1]
10.0*(x - p0)*(x - p0) + 20.0*(y - p1)*(y - p1) + 30.0
}
my_df = Proc.new { |v, params, df|
x = v[0]; y = v[1]
p0 = params[0]; p1 = params[1]
df[0] = 20.0*(x-p0)
df[1] = 40.0*(y-p1)
}
my_func = Function_fdf.alloc(my_f, my_df, 2)
my_func.set_params([1.0, 2.0]) # parameters
Can this be generalized somehow ... without tinkering with the
C code ?
More precisely, I'd like to do some minimization of the values
of a vector under some constraints, like:
m*(target-vector)= minimal,
where m is a matrix,
all entries of vectors target and vector are whole numbers,
but differ in a prescribed number of entries .
(Pseudo-)inverting m is not really an option, as can it be quite big ( several thousand lines / rows ).
I've tried to implement the constraints in a Proc involving m and
target, called on vector, but can't get it to work with the Ruby-GSL minimization
FMinimizer.
Any ideas?
Thank you very much,
Axel
in Ruby-Gsl's multidimensional minimization, the FMinimizer function
requires an equal number of variables and parameters, as
illustrated in the example
include GSL::MultiMin
my_f = Proc.new { |v, params|
x = v[0]; y = v[1]
p0 = params[0]; p1 = params[1]
10.0*(x - p0)*(x - p0) + 20.0*(y - p1)*(y - p1) + 30.0
}
my_df = Proc.new { |v, params, df|
x = v[0]; y = v[1]
p0 = params[0]; p1 = params[1]
df[0] = 20.0*(x-p0)
df[1] = 40.0*(y-p1)
}
my_func = Function_fdf.alloc(my_f, my_df, 2)
my_func.set_params([1.0, 2.0]) # parameters
Can this be generalized somehow ... without tinkering with the
C code ?
More precisely, I'd like to do some minimization of the values
of a vector under some constraints, like:
m*(target-vector)= minimal,
where m is a matrix,
all entries of vectors target and vector are whole numbers,
but differ in a prescribed number of entries .
(Pseudo-)inverting m is not really an option, as can it be quite big ( several thousand lines / rows ).
I've tried to implement the constraints in a Proc involving m and
target, called on vector, but can't get it to work with the Ruby-GSL minimization
FMinimizer.
Any ideas?
Thank you very much,
Axel