Re: pilog solver
Hi Joe, thanks for sharing this! Please forgive any style issues The style looks perfect! :) A minor issue might be the '+Choice' argument in (setq Oats (new NIL '+Choice 'capital 18 'labor 2 'revenue 55)) (setq Corn (new NIL '+Choice 'capital 36 'labor 6 'revenue 125)) It looks like a class (due to the '+' convention), but if Oats and Corn are supposed to be objects, then the class(es) must be a list. So I would suggest (setq Oats (new '(+Choice) 'capital 18 'labor 2 'revenue 55)) (setq Corn (new '(+Choice) 'capital 36 'labor 6 'revenue 125)) This is ok even if no class '+Choice' is defined, as the code doesn't use any OO-message-passing (yet). Cheers, - Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: pilog solver
I can't say for sure if prolog is a good fit or not. The problems seems a little bit too arithmetic maybe but do not trust my word on it. Otherwise it seems like a typical curve examination problem to find all the maxima, the maxima with the highest profit is the solution. On Thu, Jul 26, 2012 at 3:11 PM, Joe Bogner joebog...@gmail.com wrote: Hi, I'd like to explore the use of pilog for solving linear programming problems. I'm not exactly sure where to start because I'm just starting to learn prolog. Is it the right tool to solving a problem like this? *Example*: A farmer has 100 acres on which to plan oats or corn. Each acre of oats requires $18 capital and 2 hours of labor. Each acre of corn requires $36 capital and 6 hours of labor. Labor costs are $8 per hour. The farmer has $2100 available for capital and $2400 available for labor. If the revenue is $55 from each acre of oats and $125 from each acre of corn, what planting combination will produce the greatest total profit? What is the maximun profit? http://galileo.stmarys-ca.edu/jsauerbe/m3f09/solver.html Any examples or guidance on where to look would be very helpful. Thank you Joe
Re: pilog solver
My interest also piqued when I saw the amb example in rosettacode. It seems like that could be combined with something to backtrack if a permutation goes out of bounds. http://www.randomhacks.net/articles/2005/10/11/amb-operator On Thu, Jul 26, 2012 at 12:21 PM, Joe Bogner joebog...@gmail.com wrote: Thank you. My researched suggested that it was possible with other prolog implementations so I wasn't sure if I was missing something simple in pilog. I also wasn't sure if with a simple problem space I could combine something like permute with a known range of possibilities. In the example below, I could generate a list of the whole numbers from 1-100 for the acreage and then have some helper functions to test for ranges. I wouldn't need to solve for a real number. It sounds like there are better ways to do it. I was hoping to come up with something as nicely declarative/expressive as pilog that didn't have a bunch of conditionals. I could probably use some dsl though. I have no experience with pilog and was interested in an application of it. Thanks again On Thu, Jul 26, 2012 at 11:31 AM, Alexander Burger a...@software-lab.dewrote: On Thu, Jul 26, 2012 at 04:02:07PM +0200, Henrik Sarvell wrote: I can't say for sure if prolog is a good fit or not. The problems seems a little bit too arithmetic maybe but do not trust my word on it. I also don't think that Prolog or Pilog are well suited for that. Linear programming is an optimization technique, often employing the simplex algorithm where you solve a number of linear equations by pivoting their terms. I think this can be easier solved in plain Lisp than in Pilog. Cheers, - Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe