Re: sampling algoritm based on indexed constrains

"John Lawson" <>
11 Dec 2004 12:28:01 -0500

          From comp.compilers

Related articles
sampling algoritm based on indexed constrains (Albretch) (2004-12-01)
Re: sampling algoritm based on indexed constrains (John Lawson) (2004-12-11)
| List of all articles for this month |

From: "John Lawson" <>
Newsgroups: comp.compilers
Date: 11 Dec 2004 12:28:01 -0500
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._ 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:


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.