[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Require Thoughts on Coding Approach

JensB

4/26/2012 4:50:00 AM

This is more of a theoretical question, as I can't seem to get my head
around how to do this. What I am hoping for is that someone could
define an approach - once I have that, I can code it.

The situation is as follows.

We have four possible positions, and each of those positions may have a
number of availabilities.

We have two canditates, who each have a valid score for each of those
positions. We need to establish if a candidate is required to fill a
position, based on what would give us the greatest total score - there
is no positional weighting.

It is best to explain with examples: -

Candidate 1 scores - P1:12, P2:29, P3:12, P4:9
Candidate 2 scores - P1:10, P2:29, P3:10, P4:9

1. No positions available. Neither candidate is assigned a position.
2. P1 Available only - C1 Assigned to P1, C2 Unassigned (12 Total)
3. 2 x P1 Available - C1 and C2 both assigned to P1
4. P1 and P2 Available - C1 Assigned to P1, C2 assigned to P2 (41
Total)
5. 2 x P1 and 1 x P2 Available - C1 Assigned to P1, C2 assigned to P2
(41 Total)
6. 1 x P1 and 2 x P2 Available - C1 and C2 both assigned to P2 (58
Total)
7. P1 and P3 Available - C1 Assigned to P1, C2 assigned to P3 (22 Total
- either combination will give same score, so order irrelivent)
8. P2 Available only - C1 Assigned to P2, C2 Unassigned (29 Total -
both have same score so either is acceptable - pick first)
9. P2 and P3 Available - C1 Assigned to P3, C2 assigned to P2 (41
Total)
A. P1, P2 and P3 Available - C1 Assigned to P1, C2 assigned to P2 (41
Total - again, same notes on C1 assignment - whether it is P1 or P3
does not change the score)

I could give more examples, but this should hopefully explain it
enough. If you have any further questions, please ask.

--
Michael Cole


3 Answers

GS

4/26/2012 5:43:00 AM

0

Since you've numbered the possible scenarios for position availability,
I'd use that numbering as a code for an index to pass to a routine that
processes the results via a Select Case construct. IOW, tell the
procedure what to assign based on a 'pick list' representing the
positions available.

I'd do nothing when no positions are available and so would start my
index at P1 available only. I'd probably use a zero base so my indexes
match a check list or option control array. You could pass the scores
as a delimited string containing the scores in order of the positions
available, which the procedure could dump into a variant that you can
iterate LBound to UBound OR directly access elements according to
scenario-specific criteria.

Optionally, you could list candidate scores in a textbox (one line per
candidate) and have the procedure dump those into a variant, then
process each element as a separate set of candidate scores. This will
make the solution flexible for the number of candidates.

The simplest configuration would be a form with a textbox and a listbox
where you can check which position scenario to run the scores against.
I'd use the listbox_click event to fire the procedure. Optionally, you
could include buttons for firing code or closing the form but IMO
neither is necessary.

HTH...

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


JensB

4/26/2012 6:13:00 AM

0

GS wrote on 26/04/2012 :
> Since you've numbered the possible scenarios for position availability, I'd
> use that numbering as a code for an index to pass to a routine that processes
> the results via a Select Case construct. IOW, tell the procedure what to
> assign based on a 'pick list' representing the positions available.

The problem is that there are many possible scenarios for position
availability - there may be 0, 1 or 2 availabilities for each of the
four positions, which gives us 3^4 or 81 possibilities. I have only
shown a few examples, and then for each possibility, we need to perform
a calculation and an assignment.

--
Michael Cole


Larry Serflaten

4/26/2012 2:22:00 PM

0

On Wednesday, April 25, 2012 11:49:51 PM UTC-5, Michael Cole wrote:
> This is more of a theoretical question, as I can't seem to get my head
> around how to do this. What I am hoping for is that someone could
> define an approach - once I have that, I can code it.


Enumerate all possible combinations of the positions and then eliminate those
combinations that are not possible. If for example the most number of open
positions is 3 and the most openings for any one position is 2 then the start
of the enumeration would show up something like:

P1 P2 P3 P4
0 0 0 0 valid
1 0 0 0 valid
2 0 0 0 valid
0 1 0 0 valid
1 1 0 0 valid
2 1 0 0 valid
0 2 0 0 valid
1 2 0 0 valid
2 2 0 0 invalid
0 0 1 0 valid
1 0 1 0 valid

etc... (Think counting in base 3) to the last count:

2 2 2 2 invalid


For each combination that is valid, enumerate all possible combinations of
candidate assignments to tally the score

0 0 0 0 (no assignments)
1 0 0 0 C1:P1=12, C2:P1=10
2 0 0 0 C1:P1=12, C2:P1=10, C1:P1+C2:P1=22
....
2 1 0 0 C1:P1=12, C1:P2=29, C2:P1=10, C2:P2=29, C1:P1+C2:P1=22, C1:P1+C2:P2=41, C1:P2+C2:P1=39

I skipped a few there to get to one where there was more than 2 openings...

Once you have the totals calculated, you can then sort them out to find the best combination(s).

Does that make sense to you?

LFS