Class: OOL::Conmin::Minimizer
- Inherits:
-
GSL::Object
- Object
- GSL::Object
- OOL::Conmin::Minimizer
- Defined in:
- lib/ool/conmin.rb,
ext/gsl_native/ool.c
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
- #dx ⇒ Object
- #f ⇒ Object
- #fcount ⇒ Object
- #gcount ⇒ Object
- #gradient ⇒ Object
- #hcount ⇒ Object
- #is_optimal ⇒ Object
- #is_optimal? ⇒ Boolean
- #iterate ⇒ Object
- #minimum ⇒ Object
- #name ⇒ Object
- #parameters_default ⇒ Object
- #parameters_get ⇒ Object
- #parameters_set(params) ⇒ Object
- #restart ⇒ Object
- #set(*args) ⇒ Object
- #size ⇒ Object
- #x ⇒ Object
Methods inherited from GSL::Object
Class Method Details
.alloc(*args) ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'ext/gsl_native/ool.c', line 78
static VALUE rb_ool_conmin_minimizer_alloc(int argc, VALUE *argv, VALUE klass)
{
ool_conmin_minimizer *m;
VALUE obj;
if (argc < 2) rb_raise(rb_eArgError, "Too few arguments (%d for >= 2)", argc);
m = ool_conmin_minimizer_alloc(get_minimizer_type(argv[0]), FIX2INT(argv[1]));
obj = Data_Wrap_Struct(klass, 0, ool_conmin_minimizer_free, m);
if (argc > 2) rb_ool_conmin_minimizer_set(argc-2, argv+2, obj);
return obj;
}
|
Instance Method Details
#dx ⇒ Object
335 336 337 338 339 340 |
# File 'ext/gsl_native/ool.c', line 335
static VALUE rb_ool_conmin_minimizer_dx(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
return Data_Wrap_Struct(cgsl_vector, 0, NULL, m->dx);
}
|
#f ⇒ Object
311 312 313 314 315 316 |
# File 'ext/gsl_native/ool.c', line 311
static VALUE rb_ool_conmin_minimizer_f(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
return rb_float_new(m->f);
}
|
#fcount ⇒ Object
347 348 349 350 351 352 |
# File 'ext/gsl_native/ool.c', line 347
static VALUE rb_ool_conmin_minimizer_fcount(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
return INT2FIX((int) ool_conmin_minimizer_fcount(m));
}
|
#gcount ⇒ Object
353 354 355 356 357 358 |
# File 'ext/gsl_native/ool.c', line 353
static VALUE rb_ool_conmin_minimizer_gcount(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
return INT2FIX((int) ool_conmin_minimizer_gcount(m));
}
|
#gradient ⇒ Object
323 324 325 326 327 328 |
# File 'ext/gsl_native/ool.c', line 323
static VALUE rb_ool_conmin_minimizer_gradient(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
return Data_Wrap_Struct(cgsl_vector, 0, NULL, m->gradient);
}
|
#hcount ⇒ Object
359 360 361 362 363 364 |
# File 'ext/gsl_native/ool.c', line 359
static VALUE rb_ool_conmin_minimizer_hcount(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
return INT2FIX((int) ool_conmin_minimizer_hcount(m));
}
|
#is_optimal ⇒ Object
365 366 367 368 369 370 |
# File 'ext/gsl_native/ool.c', line 365
static VALUE rb_ool_conmin_minimizer_is_optimal(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
return INT2FIX((int) ool_conmin_is_optimal(m));
}
|
#is_optimal? ⇒ Boolean
371 372 373 374 375 376 377 |
# File 'ext/gsl_native/ool.c', line 371
static VALUE rb_ool_conmin_minimizer_is_optimal2(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
if (ool_conmin_is_optimal(m)) return Qtrue;
else return Qfalse;
}
|
#iterate ⇒ Object
378 379 380 381 382 383 |
# File 'ext/gsl_native/ool.c', line 378
static VALUE rb_ool_conmin_minimizer_iterate(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
return INT2FIX((int) ool_conmin_minimizer_iterate(m));
}
|
#minimum ⇒ Object
329 330 331 332 333 334 |
# File 'ext/gsl_native/ool.c', line 329
static VALUE rb_ool_conmin_minimizer_minimum(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
return rb_float_new(ool_conmin_minimizer_minimum(m));
}
|
#name ⇒ Object
305 306 307 308 309 310 |
# File 'ext/gsl_native/ool.c', line 305
static VALUE rb_ool_conmin_minimizer_name(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
return rb_str_new2(ool_conmin_minimizer_name(m));
}
|
#parameters_default ⇒ Object
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
# File 'ext/gsl_native/ool.c', line 395
static VALUE rb_ool_conmin_minimizer_parameters_default(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
if (m->type == ool_conmin_minimizer_spg) {
return rb_ool_conmin_spg_parameters_default(cool_conmin_spg);
} else if (m->type == ool_conmin_minimizer_pgrad) {
return rb_ool_conmin_pgrad_parameters_default(cool_conmin_pgrad);
} else if (m->type == ool_conmin_minimizer_gencan) {
return rb_ool_conmin_gencan_parameters_default(cool_conmin_gencan);
} else {
rb_raise(rb_eRuntimeError, "Unkowm minimizer type.");
}
return Qnil; /* never reaches here */
}
|
#parameters_get ⇒ Object
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'ext/gsl_native/ool.c', line 269
static VALUE rb_ool_conmin_minimizer_parameters_get(VALUE obj)
{
ool_conmin_minimizer *m;
ool_conmin_pgrad_parameters *Pp;
ool_conmin_spg_parameters *Ps;
ool_conmin_gencan_parameters *Pg;
void *P;
VALUE ary;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
ool_conmin_parameters_get(m, P);
if (m->type == ool_conmin_minimizer_pgrad) {
Pp = (ool_conmin_pgrad_parameters*) P;
ary = create_parameters_ary_pgrad(Pp);
} else if (m->type == ool_conmin_minimizer_spg) {
Ps = (ool_conmin_spg_parameters*) P;
ary = create_parameters_ary_spg(Ps);
} else {
Pg = (ool_conmin_gencan_parameters*) P;
ary = create_parameters_ary_gencan(Pg);
}
return ary;
}
|
#parameters_set(params) ⇒ Object
292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'ext/gsl_native/ool.c', line 292
static VALUE rb_ool_conmin_minimizer_parameters_set(VALUE obj, VALUE params)
{
ool_conmin_minimizer *m;
ool_conmin_pgrad_parameters *Pp;
ool_conmin_spg_parameters *Ps;
ool_conmin_gencan_parameters *Pg;
void *P;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
P = get_parameter(m->type, Pp, Ps, Pg, params);
ool_conmin_parameters_set(m, P);
return params;
}
|
#restart ⇒ Object
384 385 386 387 388 389 |
# File 'ext/gsl_native/ool.c', line 384
static VALUE rb_ool_conmin_minimizer_restart(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
return INT2FIX((int) ool_conmin_minimizer_restart(m));
}
|
#set(*args) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'ext/gsl_native/ool.c', line 91
static VALUE rb_ool_conmin_minimizer_set(int argc, VALUE *argv, VALUE obj)
{
ool_conmin_minimizer *m;
ool_conmin_function *F;
ool_conmin_constraint *C;
gsl_vector *v;
ool_conmin_pgrad_parameters Pp;
ool_conmin_spg_parameters Ps;
ool_conmin_gencan_parameters Pg;
void *P;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
switch (argc) {
case 3:
if (CLASS_OF(argv[0]) != cool_conmin_function)
rb_raise(rb_eTypeError, "Wrong argument type 0 (OOL::Conmin::Function expected)");
if (CLASS_OF(argv[1]) != cool_conmin_constraint)
rb_raise(rb_eTypeError, "Wrong argument type 1 (OOL::Conmin::Constraint expected)");
if (!VECTOR_P(argv[2]))
rb_raise(rb_eTypeError, "Wrong argument type 2 (GSL::Vector expected)");
Data_Get_Struct(argv[0], ool_conmin_function, F);
Data_Get_Struct(argv[1], ool_conmin_constraint, C);
Data_Get_Struct(argv[2], gsl_vector, v);
P = get_parameter(m->type, &Pp, &Ps, &Pg, Qnil);
ool_conmin_minimizer_set(m, F, C, v, P);
break;
case 4:
if (CLASS_OF(argv[0]) != cool_conmin_function)
rb_raise(rb_eTypeError, "Wrong argument type 0 (OOL::Conmin::Function expected)");
if (CLASS_OF(argv[1]) != cool_conmin_constraint)
rb_raise(rb_eTypeError, "Wrong argument type 1 (OOL::Conmin::Constraint expected)");
if (!VECTOR_P(argv[2]))
rb_raise(rb_eTypeError, "Wrong argument type 2 (GSL::Vector expected)");
if (!rb_obj_is_kind_of(argv[3], rb_cArray) && argv[3] != Qnil)
rb_raise(rb_eTypeError, "Wrong argument type 3 (Array expected)");
Data_Get_Struct(argv[0], ool_conmin_function, F);
Data_Get_Struct(argv[1], ool_conmin_constraint, C);
Data_Get_Struct(argv[2], gsl_vector, v);
P = get_parameter(m->type, &Pp, &Ps, &Pg, argv[3]);
ool_conmin_minimizer_set(m, F, C, v, P);
break;
default:
rb_raise(rb_eArgError, "Wrong number of arguments (%d for 3 or 4)", argc);
}
return obj;
}
|
#size ⇒ Object
341 342 343 344 345 346 |
# File 'ext/gsl_native/ool.c', line 341
static VALUE rb_ool_conmin_minimizer_size(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
return rb_float_new(ool_conmin_minimizer_size(m));
}
|
#x ⇒ Object
317 318 319 320 321 322 |
# File 'ext/gsl_native/ool.c', line 317
static VALUE rb_ool_conmin_minimizer_x(VALUE obj)
{
ool_conmin_minimizer *m;
Data_Get_Struct(obj, ool_conmin_minimizer, m);
return Data_Wrap_Struct(cgsl_vector, 0, NULL, m->x);
}
|