what's the design pattern for trial-fail-modify-retry

J

John Black

Hi,
I am wondering what's the best design pattern for such task: There
are some requirement for resource allocation scheme, the requirements
are not equally important, in another words, when it is impossible to
meet all the requirements, some of them can be discarded, this process
can repeat again and again until a satisfied solution is found.
This is basically trial-fail-adjust-retry, is there a pattern like
this?
Is there a pattern for managing layered requirements?

Thanks.
 
H

H. S. Lahman

Responding to Black...
I am wondering what's the best design pattern for such task: There
are some requirement for resource allocation scheme, the requirements
are not equally important, in another words, when it is impossible to
meet all the requirements, some of them can be discarded, this process
can repeat again and again until a satisfied solution is found.
This is basically trial-fail-adjust-retry, is there a pattern like
this?
Is there a pattern for managing layered requirements?

Not really. Resource allocation is basically an algorithmic problem.
It will probably be encapsulated in a method someplace and the best you
can hope for is to organize the data in an optimal fashion for the
algorithm. That will depend on the specific algorithm.

For example, one possibility is:
* prunes to one
[Resource] ----------------+
| * |
initially selects from | |
| |
* critical for 1 | 1 1 |
[Requirement] ----------------------- [Allocator] ---------------+
| * | 1
| | optional for
| |
+-------------------------------------+

This allows you to resolve the critical requirements first by navigating
that collection and then try to deal with the less critical requirements
by navigating the optional collection. Alternatively,

* prunes to one
[Resource] ---------------+
| * |
initially selects from | |
| |
| |
* allocates 1 | 1 1 |
[Requirement] ------------------------ [Allocator] --------------+
<ordered>

can be used if an absolute priority scheme is employed by the algorithm.

Note that both of these schemes assumes [Allocator] maintains a
temporary list of [Resources] that it prunes as requirements are
evaluated so that the list contains only [Resources] that satisfy all of
the [Requirements] processed thus far. That, in itself, defines much of
the resource allocation algorithm. B-) So if one chose a different
solution algorithm, one would need -- at a minimum -- different
relationships.

*************
There is nothing wrong with me that could
not be cured by a capful of Drano.

H. S. Lahman
(e-mail address removed)
Pathfinder Solutions -- Put MDA to Work
http://www.pathfindermda.com
(888)-OOA-PATH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top