comparison org/lpsolve.org @ 18:2bec94944460

changed macro lp-solve to work in other namespaces.
author Robert McIntyre <rlm@mit.edu>
date Mon, 06 Aug 2012 22:28:11 -0400
parents 0f6ace87343a
children 47fa6dc56e30
comparison
equal deleted inserted replaced
17:0f6ace87343a 18:2bec94944460
419 #+begin_src clojure :results silent 419 #+begin_src clojure :results silent
420 (in-ns 'pokemon.lpsolve) 420 (in-ns 'pokemon.lpsolve)
421 (defn initialize-lpsolve-row-oriented 421 (defn initialize-lpsolve-row-oriented
422 "fill in an lpsolve instance using a constraint matrix =A=, the 422 "fill in an lpsolve instance using a constraint matrix =A=, the
423 objective function =c=, and the right-hand-side =b=" 423 objective function =c=, and the right-hand-side =b="
424 [#^LpSolve lps A b c] 424 [#^lpsolve.LpSolve lps A b c]
425 ;; set the name of the last column to _something_ 425 ;; set the name of the last column to _something_
426 ;; this appears to be necessary to ensure proper initialization. 426 ;; this appears to be necessary to ensure proper initialization.
427 (.setColName lps (count c) (str "C" (count c))) 427 (.setColName lps (count c) (str "C" (count c)))
428 428
429 ;; This is the recommended way to "fill-in" an lps instance from the 429 ;; This is the recommended way to "fill-in" an lps instance from the
596 [#^LpSolve lps constraint] 596 [#^LpSolve lps constraint]
597 (dorun (map (fn [index] (.setConstrType lps index constraint)) 597 (dorun (map (fn [index] (.setConstrType lps index constraint))
598 ;; ONE based indexing!!! 598 ;; ONE based indexing!!!
599 (range 1 (inc (.getNrows lps)))))) 599 (range 1 (inc (.getNrows lps))))))
600 600
601
602 (defn set-discrete 601 (defn set-discrete
603 "sets every variable in an lps problem to be a discrete rather than 602 "sets every variable in an lps problem to be a discrete rather than
604 continuous variable" 603 continuous variable"
605 [#^LpSolve lps] 604 [#^LpSolve lps]
606 (dorun (map (fn [index] (.setInt lps index true)) 605 (dorun (map (fn [index] (.setInt lps index true))