Class: Rglpk::ObjectiveFunction
- Inherits:
-
Object
- Object
- Rglpk::ObjectiveFunction
- Defined in:
- lib/rglpk.rb
Instance Method Summary collapse
- #coefs ⇒ Object
- #coefs=(a) ⇒ Object
- #dir ⇒ Object
- #dir=(d) ⇒ Object
- #get ⇒ Object
-
#initialize(problem) ⇒ ObjectiveFunction
constructor
A new instance of ObjectiveFunction.
- #mip ⇒ Object
- #name ⇒ Object
- #name=(n) ⇒ Object
- #set_coef(j, coef) ⇒ Object
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
#coefs ⇒ Object
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 |
#dir ⇒ Object
412 413 414 |
# File 'lib/rglpk.rb', line 412 def dir Glpk_wrapper.glp_get_obj_dir(@p.lp) end |
#dir=(d) ⇒ Object
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 |
#get ⇒ Object
429 430 431 |
# File 'lib/rglpk.rb', line 429 def get Glpk_wrapper.glp_get_obj_val(@p.lp) end |
#mip ⇒ Object
433 434 435 |
# File 'lib/rglpk.rb', line 433 def mip Glpk_wrapper.glp_mip_obj_val(@p.lp) end |
#name ⇒ Object
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 |