If you're using the LPM monad, then this is about as easy as that: you use<br><br>do (x1:x2:x3:_) <- newVariables<br> ......<br><br>I mean, run is equivalent to<br><br>run f = execLPM (newVariables >>= put . f)<br>
<br>so...yeah, I think this is a reasonable solution.<br><br>Alternatively, I'm almost positive there's a monad out there that lets you draw on unique values. It'd look something like<br><br>type Variable = Int<br>
newtype UniqueM a = UniqueM (Variable -> (Variable, a))<br><br>-- monad instance, etc.<br><br>getUnique :: UniqueM Variable<br>getUnique = UniqueM (\ x -> (x+1, x))<br><br>Then you can use the LPT monad transformer to construct a linear program around this, just by working in the "LPT Variable c UniqueM" monad.<br>
<br>That's actually a nicer solution than my current implementation. I'll do that, then...<br><br clear="all">Louis Wasserman<br><a href="mailto:wasserman.louis@gmail.com">wasserman.louis@gmail.com</a><br><a href="http://profiles.google.com/wasserman.louis">http://profiles.google.com/wasserman.louis</a><br>
<br><br><div class="gmail_quote">On Mon, Mar 1, 2010 at 9:29 AM, Henning Thielemann <span dir="ltr"><<a href="mailto:lemming@henning-thielemann.de">lemming@henning-thielemann.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
On Sun, 28 Feb 2010, Louis Wasserman wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
It's an expensive operation, though -- since I don't track the set of all<br>
variables as the LP is built, I need to construct the set of all variables<br>
before generating new ones -- so it's recommended that you get all the<br>
variables you need in one or two passes.<br>
</blockquote>
<br></div>
Then you might prefer a single operation that generates all variables and runs an enclosed problem on them:<br>
<br>
run :: ([Variable] -> LP a) -> LP a<br>
<br>
<br>
Use as<br>
<br>
run $ \x0:x1:x2:_ -> do<br>
...<br>
</blockquote></div><br>