Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maths Problem - Sorta VFP - Pro Rata Distributions

Status
Not open for further replies.

GriffMG

Programmer
Mar 4, 2002
6,333
FR
I have a maths issue for a little VFP project I have on the go, it is in VFP but it's the math I am struggling with, please forgive if I am bending the rules a smidge.

I have a record where there are four fields which should add up to a target, so A+B+C+D = Target.
I have a form which has the four fields as data entry boxes and the target is displayed.
The target can change - it is really the product of a long complex process, not just A+B+C+D - when it changes
the user is alerted and pops up the form and decides how the target should be split across the four fields.

Simple enough, the user has complete discretion how the target is split. I provide buttons for each of the fields, with All (all target in A for example B,C & D set to zero),
Balance (the difference between the sum of the other fields and the target) and Nil, which zeros out the field.

The user wants a Pro Rata button, so his previous decision is used as the basis for the current situation.

i.e. if the previous target was 200 and he split it equally in four parts A,B,C & D would be 50 each, the new target is now 300 so
the Pro Rata button would work out each 'contribution' to the original target and change A,B,C & D to 75.

Works a treat - except where the split involves a negative in one of the fields.

In the above if the target was 200 and the original split 100,100,100 & -100 I think the Pro Rata split for a 300 target should be
150,150,150,-150.

But what about an original split to a zero target such as 100,-100,100 & -100? I don't think the Pro Rata split for a 300 target can be made.

Any thoughts? Hide the Pro Rata button for zero sum situations?




Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
The last example scales the same way, doesn't it? Once you accept the 4 values can also sum to anything else but the target (do I have to understand this logic) then still what you do to apply the same ratios is simply a common factor. And that is the factor new target divided by /old target. As long as the target itself wasn't zero that can be computed.

So 100,-100,100,-100 scale to -150,150,150,-150 by the factor 300/200 = 1.5, just as 1.5*(100,100,100,-100) scaled to (150,150,150,-150) you don't need to look at the sum at all.

Unless the ruleset is more complex. Is it too long winding to simply post the specs? Or are they not even given, is it your decision to define the splits? Because it really becomes playing poker and giving advice from across the universe to something you only have seen a glimpse of. Don't make me your scapegoat if this won't work out, this is advice with redflag warnings.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Hi Olaf,

Thanks, no scapegoats here, just wondering if anyone has any ideas, but I think you misread the last example.

The target for the original situation in the last example is zero, not 200, the new situation is a target of 300, but I don't think can rely on a pro rata even if you ABS() the numbers.

Your line
So 100,-100,100,-100 scale to -150,150,150,-150 by the factor 300/200 = 1.5, just as 1.5*(100,100,100,-100) scaled to (150,150,150,-150) you don't need to look at the sum at all.

Would become
Code:
So 100,-100,100,-100 does not scale to -150,150,150,-150 because the factor is 300/0 = infinity (divide by zero).

Closest might be to take the original target as a very small number when it is actually nil... all you would really get then is a meaningless very large set : infinity, -infinity, infinity, -infinity

As for specs, I don't really get them - not in the last 40 years anyway - I don't think anyone has ever actually written down what they want me to do.


Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Okay,

sorry for missing that point, but still as I said:
myself said:
As long as the target itself wasn't zero that can be computed.
so this fails for target change from 0 to anything else. Well, in that case, I think the user can't get the Pro Rata button, as you can't divide by 0, that's the simple truth.

Bye, Olaf.

Olaf Doschke Software Engineering
 
No problem Olaf

It's common sense really, any 'scaling' of four numbers that sum to zero is going to result in zero, not 300.

I've made the button disabled under those circumstances, and added a label 'Cannot Pro-Rata a Zero Balance' when it is disabled.

The user will 'get it' most likely.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Yes, I think they will.

I confused your description of "it is really the product of a long complex process, not just A+B+C+D" and got it as 100,100,100 & -100 could actually be a correct splitting for the target 0, too.
But when it's all just about the way to get to the target value or how a split is fair or valid in any way, then that's something else.

Oh, I remember fine discussions about formula scaling, quite similar topic. Some formulas simply had a target weight, so that's given and hwne you then add ingredients their percentage is known before you get to the target wight, as you rely on it and the recipe only becomes final when all ingredients sum to that wight. For some reason that same method was applied to percentages with a partial recipe of a multi component formula making up a target percentage of the overall formula and that kind of building block principles blew some peoples minds, even though they are professionals in chemistry...

Bye, Olaf.

Olaf Doschke Software Engineering
 
Well, you've beaten me Olaf, not got a clue if you are talking chemistry or baking (which is of course chemistry anyway).

The app is a cost control thing, where you have given someone a contract to do something, then issue instructions to do parts of it as they are required, the client
wants to know how much of each instruction was spent on which part of the building (say) and how much of each part of that was spent on (say) labour, plant hire, materials and other things.

Most of the time the instructions are for MORE work, at extra cost, but sometimes they are omitting work and making things cheaper, so you get some negatives and some zero
cost activities where you don't buy bricks (materials), but do hire a digger or a crane (plant) and still need a driver (labour) who is more expensive than the brickwork guy and it doesn't need an inspection or certification (the other things).

Of course the Pro-Rata stuff is where you priced for six units of whatever it was you are doing, and then need 3 more, so a Pro-Rata is a sensible way to deal with the allocation of costs for the extra 50%.

All good fun.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Ah, I see. Cost splits.

Are the four parts assigned to parties involved it could be likely the one causing the change will get the full difference. Or if its same parties cooperating over many contracts, perhaps let them pick from previous splits for the same or a similar target? Whatever, I think these suggestions just will be horrible in details. But you could offer a diffing , so when the make a manual change they could see the effective change. each party sees, sometimes not unimportant to see who'll likely not accept a change.

Well, I didn't have to do with the chemistry itself, but the absolute and relative formula proportion calculations where hard enough to understand even for the employees using that software. Overall product lifecycle and on tha large scale even ERP, or in short everything from resource planning to development, studies formula certifications, etc.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top