Linear Program

Use this forum to post Vensim related questions.
Post Reply
tomauro
Member
Posts: 41
Joined: Thu Mar 25, 2010 3:17 pm

Linear Program

Post by tomauro »

Tom (et al),

Any thoughts lately about incorporating a linear program for optimizing allocations? Last I was grappling with this, the only option was the market clearing algorithms (built-in) or trying to trade data with Excel and using their LP.

Cheers,
Lou
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Linear Program

Post by tomfid »

It's available now as an external function. Take a look, then we can talk ... http://vensim.com/workbench/
tomauro
Member
Posts: 41
Joined: Thu Mar 25, 2010 3:17 pm

Re: Linear Program

Post by tomauro »

Tom,

Awesome!! I actually did a search way back when and saw that solver too.

I'll explore and let you know if I have any issues implementing.

Cheers,
Lou
tomauro
Member
Posts: 41
Joined: Thu Mar 25, 2010 3:17 pm

Re: Linear Program

Post by tomauro »

Tom,

I'm having some issues getting this running. I put the venextLP and venextLP_dp in the “C:\Users\SAO\Vensim\plugins” folder as shown. I put the lpsolve55.dll in the “C:\lp_solve” folder (and added it to my system path). I even put the dlls in the “C:\Users\SAO\Vensim\dll” and “C:\Windows\System32” paths, just in case. Here are my issues:

1) I’m using the DP version, so I point to the venextLP_dp file in the Tools>Options>Startup>External Function Library, but I get the “Expected 51051…” error. When I point to venextLP instead, I get the opposite error and something about (-2)? I even tried this with the MultiExtLib files (instead of VenextLP)…same problem.

2) The sample model opens as text and won’t convert to a drawing since it sees the LP_SOLVE and LP_ALLOC function as syntax errors.

Any ideas?

Thanks and have a great Mem Day weekend,

Lou
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Linear Program

Post by Administrator »

I even put the dlls in the “C:\Users\SAO\Vensim\dll” and “C:\Windows\System32” paths, just in case.
Delete these from here, they might confuse things.
1) I’m using the DP version, so I point to the venextLP_dp file in the Tools>Options>Startup>External Function Library, but I get the “Expected 51051…” error.
What version of Vensim are you using (Help->About Vensim). These DLLs are compiled to work with the latest (6.0 upwards).
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomauro
Member
Posts: 41
Joined: Thu Mar 25, 2010 3:17 pm

Re: Linear Program

Post by tomauro »

I deleted the files out of the other locations.

I'm running Version 6.0b. Maintenance ran out so I can't download 6.1 (yet).
tomauro
Member
Posts: 41
Joined: Thu Mar 25, 2010 3:17 pm

Re: Linear Program

Post by tomauro »

BTW, I should have mentioned, I have a 64-bit OS...don't know if that makes a difference.
tomauro
Member
Posts: 41
Joined: Thu Mar 25, 2010 3:17 pm

Re: Linear Program

Post by tomauro »

Problem solved!!!

When I replaced the 64-bit version of lpsolve55.dll with the 32-bit version (in the C:\lp_solve folder), it worked!

You may want to mention this in the setup instructions on the Workbench page.

Thanks,
Lou
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Linear Program

Post by tomfid »

Great! I didn't think of that.

Let me know if you have specific thoughts about desired functionality.
ekempbenedict
Junior Member
Posts: 11
Joined: Fri Aug 26, 2016 9:49 pm
Vensim version: DSS

Re: Linear Program

Post by ekempbenedict »

The LP solver is great. However, I would prefer to use the double precision version if possible, and I had problems with it. First, Norton didn't like it -- it flagged it as a potential virus using heuristics, and I had to stop Norton from scanning venextLP_dp.dll before I could continue. Then when I did try to run it, using Vensim DSS for Windows Version 6.4a Double Precision (x32), I go the error "Failed to set global variables in external function library" (in a file where I hadn't yet put in any LP functions). I have no problem with the single-precision library.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Linear Program

Post by tomfid »

I think the external lib may need to be complied with the flag DPMATH so that it's variable types are compatible with DP Vensim. I don't recall the details, but I'm hoping Tony does.
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Linear Program

Post by Administrator »

"Failed to set global variables in external function library"
Do the LP functions still work as this should just be a warning rather than an error?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
ekempbenedict
Junior Member
Posts: 11
Joined: Fri Aug 26, 2016 9:49 pm
Vensim version: DSS

Re: Linear Program

Post by ekempbenedict »

I don't think so. I tried a test where I started putting in the function and then checked the expression, and got 'Do you want to add "LP SOLVE" to the model'. My understanding is that the name should have been loaded already and Vensim should recognize it. Is that right?

@tomfid: Thanks very much. I can compile it if need be, but right now I'm using the pre-compiled binaries for Windows. I've programmed Vensim extensions before, but it's been awhile and on a different machine. I'd need to pull the relevant libraries together, so I'm hoping to be able to use the pre-compiled versions.

Thanks,
Eric
ekempbenedict
Junior Member
Posts: 11
Joined: Fri Aug 26, 2016 9:49 pm
Vensim version: DSS

Re: Linear Program

Post by ekempbenedict »

To be clear, I don't actually need double precision on my current project -- I just want to have the option in case I do need it as the model evolves. Also, I wanted to raise the issue I had in case someone else ran into the same problem. But the single-precision version is working great, and I'm moving right along.

Thanks,
Eric
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Linear Program

Post by tomfid »

Cool.

When I first wrote the code, I had at least two ambitions that remain unrealized:
- use the LP infrastructure to create some custom allocation functions. For example, the LP makes it easy to solve the many-to-many noncommodity allocation problem, with unique costs (e.g. shipping) for each supplier x demander combination.
- persist the LP definition, for greater speed.

If you have any feedback as you progress, I'd appreciate hearing it.
Post Reply