Hacker News new | past | comments | ask | show | jobs | submit login

I didn't know glpk takes text input.

I'd write the program anyway, however - the text file would actually be quite large. This problem has 15 variables and 27 constraints (if I counted correctly). Your plain text input to glpk would be at least 43 lines long (counting the objective function), compared to about 30 lines of haskell.

If your usage pattern varied daily (e.g., one pattern for monday, a different one for tuesday), your input would become even bigger. The only modification to the haskell code would be:

    main = do
        printLPSolution (Map.fromList [ ("mon_0", 12.2), ("mon_1", 25.1), ("mon_2", 53.5),
                                        ("tues_0", 15.8), ("tues_1", 33.9), ("tues_2", 76.2),
                                        ...
                                       ])



Yes

Here's the docs for the language glpk uses

http://www.cs.unb.ca/~bremner/docs/glpk/gmpl.pdf

Yeah, with 15 (effective) variables it's better to write in some higher level way.

And there's always the canonical way, but that's awful to write by hand, like

k00.v00 + K01.v01 + K02.v02 + k03.v03 < C0 k10.v10 + K11.v11 + K12.v12 + k13.v13 < C1


I used it for a problem recently, and just wrote code to generate the text file for me.


Please insert a newline somewhere in there so your alignment doesn't throw off all the code to the right-most 1/4 of the screen...


glpk takes text input, csv input, and certain database inputs.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: