Class: Rglpk::ObjectiveFunction

Inherits:
Object
  • Object
show all
Defined in:
lib/rglpk.rb

Instance Method Summary collapse

Constructor Details

#initialize(problem) ⇒ ObjectiveFunction

Returns a new instance of ObjectiveFunction.



395
396
397
# File 'lib/rglpk.rb', line 395

def initialize(problem)
  @p = problem
end

Instance Method Details

#coefsObject



425
426
427
# File 'lib/rglpk.rb', line 425

def coefs
  @p.cols.map{|c| Glpk_wrapper.glp_get_obj_coef(@p.lp, c.j)}
end

#coefs=(a) ⇒ Object



420
421
422
423
# File 'lib/rglpk.rb', line 420

def coefs=(a)
  @p.cols.each{|c| Glpk_wrapper.glp_set_obj_coef(@p.lp, c.j, a[c.j - 1])}
  a
end

#dirObject



412
413
414
# File 'lib/rglpk.rb', line 412

def dir
  Glpk_wrapper.glp_get_obj_dir(@p.lp)
end

#dir=(d) ⇒ Object

Raises:

  • (ArgumentError)


407
408
409
410
# File 'lib/rglpk.rb', line 407

def dir=(d)
  raise ArgumentError if d != GLP_MIN and d != GLP_MAX
  Glpk_wrapper.glp_set_obj_dir(@p.lp, d)
end

#getObject



429
430
431
# File 'lib/rglpk.rb', line 429

def get
  Glpk_wrapper.glp_get_obj_val(@p.lp)
end

#mipObject



433
434
435
# File 'lib/rglpk.rb', line 433

def mip
  Glpk_wrapper.glp_mip_obj_val(@p.lp)
end

#nameObject



403
404
405
# File 'lib/rglpk.rb', line 403

def name
  Glpk_wrapper.glp_get_obj_name(@p.lp)
end

#name=(n) ⇒ Object



399
400
401
# File 'lib/rglpk.rb', line 399

def name=(n)
  Glpk_wrapper.glp_set_obj_name(@p.lp, n)
end

#set_coef(j, coef) ⇒ Object



416
417
418
# File 'lib/rglpk.rb', line 416

def set_coef(j, coef)
  Glpk_wrapper.glp_set_obj_coef(@p.lp, j, coef)
end