Optimization Constraints using non-constants, percentages summing to 1.0

Use this forum to post Vensim related questions.
Post Reply
nicholas.andrianas
Junior Member
Posts: 4
Joined: Wed Jun 30, 2021 8:23 pm
Vensim version: DSS

Optimization Constraints using non-constants, percentages summing to 1.0

Post by nicholas.andrianas »

Good morning! I've been self-learning vensim DSS working on a staffing optimization model in response to a disaster event, and am having trouble determining how to include policy optimization constraints that are not constant values, or in substitute - combining 3 constants into a single constraint.

The general problem: I'm optimizing a policy using a negative weight, which works well. There are 3 decision parameters that I want to optimize in various input conditions which are represented as percentages in my model - the percent of total staff allocated to any of three exclusive and exhaustive areas of support - for example, if I have 5000 nurses after requesting additional support for staffing, I want the model to consider how to optimize the outcome, let's say minimize total infections given a COVID-like pandemic, by configuring the % of that 5000 nurses that are allocated to one of three areas - hospital-based care, public health tracing, OR behavioral health change campaigning, such that the sum of that divvied % sums to exactly 1.0.

The specific problem: I can include each of these percent allocations as line items in my constraint inputs, but then that allows each of them to range between [0,1], where I want the constraint to instead be presented something like .99 <= %a + %b + %c = 1.01 (to allow for some natural rounding error tolerance). Is there any way to do this? I've tried to create a new variable that, in the model, sums these percentages and then constrains that variable in a similar fasion, but of course the optimizer doesn't allow non-constants as constraints.

Thanks in advance.
Nick
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Optimization Constraints using non-constants, percentages summing to 1.0

Post by Administrator »

You can use the inputs to calculate proportions instead and use those in your model.

Something like

input 1 = 10
input 2 = 20
input 3 = 30

total input = input 1 + input 2 + input 3

proportion input 1 = zidz ( input 1 , total input)
proportion input 2 = zidz ( input 1 , total input)
proportion input 3 = zidz ( input 1 , total input)

The sum of "proportion input x" will = 1.

Even easier with subscripts.

input[sub] = 10 (or some other value)

total input = sum(input[sub!])

proportion[sub] = zidz ( input[sub] , total input)
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
nicholas.andrianas
Junior Member
Posts: 4
Joined: Wed Jun 30, 2021 8:23 pm
Vensim version: DSS

Re: Optimization Constraints using non-constants, percentages summing to 1.0

Post by nicholas.andrianas »

Thanks for such a prompt reply and I think it makes sense to me in principle. Would these be new variables I'd include? Where might I fold in these inputs (in the model, or just in the optimization tool?)
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Optimization Constraints using non-constants, percentages summing to 1.0

Post by Administrator »

You haven't uploaded the model so I cannot really say where you put them in.

Whatever you modify with the optimizer and need to sum to 1, insert this new structure after that.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Optimization Constraints using non-constants, percentages summing to 1.0

Post by tomfid »

You need to put these in the model as new equations.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Optimization Constraints using non-constants, percentages summing to 1.0

Post by tomfid »

There is another way to do it, which is to create an additional term in the payoff that penalizes deviation from sum=100%. However that's usually less efficient.
nicholas.andrianas
Junior Member
Posts: 4
Joined: Wed Jun 30, 2021 8:23 pm
Vensim version: DSS

Re: Optimization Constraints using non-constants, percentages summing to 1.0

Post by nicholas.andrianas »

Hmm ok, I think I might be getting lost, and apologies for not posting the model - I can't share it outside of my organization unfortunately.

As for the approach proposed that uses proportion calculations, I'm not sure I follow - so the input itself that I'd be asking for from a user would be the # to be reuqested, and then I would use those values to calculate the proportion that that accounts for? I may have phrased the problem poorly - that is actually the result I'm hoping to optimize for / answer - "what is the ideal / optimal percentage or proportional allocation?" It's a bit of a two-stage optimization where part of the goal is to determine how many total nurses (e.g. the 5000) mentioned from before, and then secondary to that is what proportion by which to allocate them in the model, rather than asking for that as a user input. Of course those two things are interleaved and I may need to re-evaluate my approach in the first place, but I feel like given the multi-start or MCMC options, this is a reasonable set of variables to explore the result space over.

Thanks very much for this help, and it's nice and nostalgic to have to dust off my (albiet not very strong to begin with) Ops Research skills haha
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Optimization Constraints using non-constants, percentages summing to 1.0

Post by tomfid »

This sounds somewhat like a Bayesian estimation problem, where you want to find a parameter value that best fits the data, subject to some prior belief about the plausible range of values. In this case, user input could be taken as a suggestion, and the optimizer could be turned loose to maximize some outcome, subject to a weight representing the strictness of sticking to the user input.

I think the question that has to be answered first is, how are users going to interact with this? Directly in Vensim, or via an interface? If it's the latter, it would be easier to enforce the sum=100% constraint in the interface layer - javascript or VBS or whatever. If it's inside Vensim, there is only a formalism for linking sliders in Venapp, so you'd have to use that. (It's called SLIDEVARTIE as I recall.)
nicholas.andrianas
Junior Member
Posts: 4
Joined: Wed Jun 30, 2021 8:23 pm
Vensim version: DSS

Re: Optimization Constraints using non-constants, percentages summing to 1.0

Post by nicholas.andrianas »

In theory it will be a dashboard, like Venapps, but I'm not sure I have enough time to fully develop venapps, and in the mean while I've been developing simplified Views that just display Snythesim sliders for the select parameters I would like Users to engage with (inside of Vensim) which works for now.

The more I think about this, is there maybe a different way to handle this using the "Constraint" variable type? Or maybe a reality check? Since there's also a chance for users to submit not just 1 request and then set a series of 3 exclusive allocation %s (summing to 1.0), but they may exercise another option to then request again at a later time, with a potentially different set of allocation %s. I'm thinking there may be a way to create a Constraint variable or Reality check that corresponds to every group of 3 allocation %s and ensures that each set sums exactly = 1, then I can have the optimizer use all of the individual % allocation variables as optimization parameters (constants) over which to search for optimum outputs to the payoff. Overall, I'm just not sure I have a good enough grasp on what Constraint and Reality checks are able to do re: optimization (e.g. will the model actually prevent those %'s from exceeding a sum of 1, or just throw an error but allow the excessive values?)

Again, sorry this is convoluted but really appreciate your engagement here.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Optimization Constraints using non-constants, percentages summing to 1.0

Post by tomfid »

Reality Check and optimization don't interact at all. Reality Checks could tell you there was a problem with the allocation, but not correct the problem.

Optimization may not be good for the user experience because it takes time and doesn't work with synthesim (though that may change in the future). Better to use it as a comlement than to try to make every run an optimization.

"Again at a later time" - does this mean the user is running in gaming mode, making decisions at several points throughout the simulation? Or do they have the opportunity to set different suggested staffing levels over time?

Here are a bunch of ways to do it, all of which are compatible with optimization I think:
staffing UI 1.mdl
(8.89 KiB) Downloaded 128 times
None is really as satisfying as the SLIDEVARTIE, but OTOH allocating fractions of a fixed staff pool is often not the way things really work. Reality is often more like the bottom right option, in which warring factions make (possibly conflicting) staff requests and the boss enforces a budget constraint.
Post Reply