11 Dec 2004 12:28:01 -0500

Related articles |
---|

sampling algoritm based on indexed constrains lbrtchx@hotmail.com (Albretch) (2004-12-01) |

Re: sampling algoritm based on indexed constrains johnlawson@gmail.com (John Lawson) (2004-12-11) |

From: | "John Lawson" <johnlawson@gmail.com> |

Newsgroups: | comp.compilers |

Date: | 11 Dec 2004 12:28:01 -0500 |

Organization: | http://groups.google.com |

References: | 04-12-015 |

Posted-Date: | 11 Dec 2004 12:28:01 EST |

Albretch wrote:

*> I have been thinking about an implementation of a sampling algorithm*

*> that would conditionally constrain selections preferably in Java (ANSI*

*> C/C++ are fine, too).*

*>*

*> Say, you have a number of items you may conditionally select. Cases*

*> would be:*

*>*

*> 1._ you may select any and any number of them,*

*> 2._ you may select any, but only a given number of them, say 1, 2 or*

3

*> 3._ you either select the first or second and any other one,*

*> 4._ you may select any as long as the total of certain weight remains*

*> in a range*

*> 5._ you -must- select all*

*> . .*

*> I did search and could not find anything similar to what I was*

*> looking for. Maybe you know of something like this or can avail me*

*> of some leads in the right direction.*

Yes, you *could* write a simple scanner and parser to determine the

validity of sampling criteria. What you do with valid criteria after

that is up to you!

I would type "Scanners", "parsers" and "simple examples" into Google

and try and find a tutorial on how to write them. You will also need

to define the grammar.

Flex would be a good tool to use to see how parsers and scanners work,

although for your problem it might be a little overcomplex :)

A Java binary is available here and there are also some useful papers

and tutorials:

http://www.flex-compiler.lcs.mit.edu/Harpoon/

John

Post a followup to this message

Return to the
comp.compilers page.

Search the
comp.compilers archives again.