Integrating time step of optimization problem
Integrating time step of optimization problem
Hello,
I am working on a big model which simulates an electricity market hourly for 30 years(30years*365days*24hours). This model is complied with C++ and an external function is used for optimizing model hourly. My question is that for optimizing the model daily(24_hours together) do I have to implement it in C++ codes or is this period changing doable in Vensim itself? In other words, what is your suggestion for integrating time steps and optimizing in a 24_hours block instead of hourly.
Best Regards
I am working on a big model which simulates an electricity market hourly for 30 years(30years*365days*24hours). This model is complied with C++ and an external function is used for optimizing model hourly. My question is that for optimizing the model daily(24_hours together) do I have to implement it in C++ codes or is this period changing doable in Vensim itself? In other words, what is your suggestion for integrating time steps and optimizing in a 24_hours block instead of hourly.
Best Regards

 Super Administrator
 Posts: 3620
 Joined: Wed Mar 05, 2003 3:10 am
Re: Integrating time step of optimization problem
Given you are using external functions to do some sort of optimization, there is really very little we can suggest. Can you adapt your function to optimize over a 24 hour period?
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/magazine27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine27509559
Re: Integrating time step of optimization problem
One strategy would be to replace the 24hr cycle with a 24element array of hours of the day. However, that might wreck other time dynamics that play out during the day.
A more sophisticated possibility might be to use the same array of 24hrs to contain expectations about the coming day, then optimize within that. However, there might be surprises (unplanned outages), so the plan would have to be robust.
The one thing you can't do is run the Vensim optimizer at intervals within the simulation. OTOH you can do some kinds of optimization with FIND ZERO  I've used that before to dispatch power plants in a model.
Hard to say more without knowing what the question really is.
Tom
A more sophisticated possibility might be to use the same array of 24hrs to contain expectations about the coming day, then optimize within that. However, there might be surprises (unplanned outages), so the plan would have to be robust.
The one thing you can't do is run the Vensim optimizer at intervals within the simulation. OTOH you can do some kinds of optimization with FIND ZERO  I've used that before to dispatch power plants in a model.
Hard to say more without knowing what the question really is.
Tom
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Integrating time step of optimization problem
Thank you for response. Objective function of optimization problem is minizing cost of all power plants subject to grid constraints which it is optimized for each hour seperatly. I am working on exanding time period, but as it might messed up all other variables I just looked for any other optimized method for implementation of it.Administrator wrote: ↑Mon Jun 18, 2018 5:25 pmGiven you are using external functions to do some sort of optimization, there is really very little we can suggest. Can you adapt your function to optimize over a 24 hour period?
Best,
Re: Integrating time step of optimization problem
Thanks for your comment. As far I mentioned, objective function of model dispatchs electricity market hourly so some features such as linking storage systems are missing in current model, that's why I am changing its time period from hourly to 24 hrs cycle to be able to integrate storage systems. Anyway, I found your second suggestion useful but I am still wondering to change the objective function or changing vector from hourly to 24 hours. I want to use an efficient method which need least changes in other parts of the model.tomfid wrote: ↑Tue Jun 19, 2018 2:02 amOne strategy would be to replace the 24hr cycle with a 24element array of hours of the day. However, that might wreck other time dynamics that play out during the day.
A more sophisticated possibility might be to use the same array of 24hrs to contain expectations about the coming day, then optimize within that. However, there might be surprises (unplanned outages), so the plan would have to be robust.
The one thing you can't do is run the Vensim optimizer at intervals within the simulation. OTOH you can do some kinds of optimization with FIND ZERO  I've used that before to dispatch power plants in a model.
Hard to say more without knowing what the question really is.
Tom
This is part of the code for hourly dispatch which formulate for the Power Generation Asset Valuation Model
*********
double SUPPLY_CURVE_POINT(float *existing_capacities, float *existing_capacity_costs,
float *planned_capacities, float *planned_capacity_costs,
double num_plants, double demand, double debug_output)
{
int i = 0, entries = 0;
float cum_demand = 0.0;
double rval = 0.0;
struct bid_info *info;
#if DEBUG_OUTPUT
FILE *f; // for debugging output
#endif
*********
Best Regards
Re: Integrating time step of optimization problem
Hi,
I have one question, which is approximately related to first question of here.
I want to model a repeated electricity auction. In this auction, winner of each auction, should be able to sell freely for 20 further rounds because by winning once, auctioneer gives him/her guaranteed purchase for next 20 rounds(so it does not take part in 20 further auctions because it has permission for selling in 20 further rounds, but it can take part again in the auction after these 20 rounds). But looser can take part in the next auction again until winning (getting permission for selling in 20 next rounds. Can I ask you how can I model it in Vensim?
Best Regards,
I have one question, which is approximately related to first question of here.
I want to model a repeated electricity auction. In this auction, winner of each auction, should be able to sell freely for 20 further rounds because by winning once, auctioneer gives him/her guaranteed purchase for next 20 rounds(so it does not take part in 20 further auctions because it has permission for selling in 20 further rounds, but it can take part again in the auction after these 20 rounds). But looser can take part in the next auction again until winning (getting permission for selling in 20 next rounds. Can I ask you how can I model it in Vensim?
Best Regards,

 Super Administrator
 Posts: 3620
 Joined: Wed Mar 05, 2003 3:10 am
Re: Integrating time step of optimization problem
I'd assume each company has a price that they bid at, and you select a winner based on this price.
When the winner is selected, I'd use a level to store a value of 1 for 20 rounds. If the value is 1, make the price that they bid at very large.
When the winner is selected, I'd use a level to store a value of 1 for 20 rounds. If the value is 1, make the price that they bid at very large.
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/magazine27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine27509559
Re: Integrating time step of optimization problem
Thanks a lot for your helpful suggestion.Administrator wrote: ↑Tue Oct 09, 2018 9:33 amI'd assume each company has a price that they bid at, and you select a winner based on this price.
When the winner is selected, I'd use a level to store a value of 1 for 20 rounds. If the value is 1, make the price that they bid at very large.
Re: Integrating time step of optimization problem
Can you please describe or send a sample model how to model economic dispatch with Find Zero?
Re: Integrating time step of optimization problem
The FIND ZERO example model in the Help system is already pretty close to what you need. I'll see if I have something better.
Have you explored the allocation functions? That would be an even easier solution.
Have you explored the allocation functions? That would be an even easier solution.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Integrating time step of optimization problem
Yes but maybe I did not use it correctly. I used "Allocation by priority", in this case the thing is that I can not access successful bids because it just gives allocated capacity and priority( price in this case). My aim is to maximize profits of bidders in a pay as bid auction and I want to find both allocated capacities and their bids after each auction rounds.
Assume that I have two power plants, I want to maximize their expected profits(π) as follows:
Max E(π(b))=∑(bid(i) cost(i))
Bid constraints:
LCOE(A)< Bid of A< price cap
LCOE(B)< Bid of B< price cap
Capacity constraints:
100<Capacity of A<300
100<Capacity of B<300
Best Regards
Re: Integrating time step of optimization problem
Doesn't everyone who supplies > 0 get paid at the (single) market clearing price, rather than their bid price?
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Integrating time step of optimization problem
No, they get paid exactly their bid. So bidders bid at their individual cost with a margin on top. However uniform auction can help me but my main concern is modeling this maximization rather than just allocation by price priority.
Re: Integrating time step of optimization problem
Does your capacity constraint imply that A generates 100 to 300 or 0 ? That probably can't be done with the alloc functions. Not sure it could be done with FIND ZERO or even an LP either. It makes this more of a mixed integer programming problem, right?
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Integrating time step of optimization problem
Ah ... so the problem is more game theoretic. Each plant has to choose a bid that maximizes profit, subject to everyone else doing the same. We know the bid has to lie above marginal cost, and below a price cap (set by regulator?). Is the capacity constraint loose, in the sense that they want to run >100MW but don't really know where they'll end up?
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Integrating time step of optimization problem
Sorry, it should be (0<Capacity of A<300). If another one(B) provide better (smaller) bid A will loos so it doesn't produce anything. I think it shouldn't be mixed integer programming.
Re: Integrating time step of optimization problem
It seems like this should result in an outcome much like a single clearing price, but with a little more noise.
If I'm running unit X, I don't want to bid my marginal cost. I want to figure out where the market is likely to clear next period, and bid just below that.
However, the price in the next period will still be set by the marginal supplier, so the clearing logic in the alloc function applies. It's just that there's some uncertainty in what the load will be, and the supply curve is harder to observe, due to the strategic bidding behavior.
If I'm running unit X, I don't want to bid my marginal cost. I want to figure out where the market is likely to clear next period, and bid just below that.
However, the price in the next period will still be set by the marginal supplier, so the clearing logic in the alloc function applies. It's just that there's some uncertainty in what the load will be, and the supply curve is harder to observe, due to the strategic bidding behavior.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Integrating time step of optimization problem
Yes, its more game theoretic. For capacity constraints I only consider upper limit and lower boundry is 0.tomfid wrote: ↑Wed Aug 21, 2019 7:38 pmAh ... so the problem is more game theoretic. Each plant has to choose a bid that maximizes profit, subject to everyone else doing the same. We know the bid has to lie above marginal cost, and below a price cap (set by regulator?). Is the capacity constraint loose, in the sense that they want to run >100MW but don't really know where they'll end up?
We can use a cumulative distribution function (CDF) instead of solving a game theory. This CDF can describe each bidder's belief on the other bidder's bid but firstly I would like to know how is it possible to solve it by means of Vensim.
Re: Integrating time step of optimization problem
Good idea. Market clearance function can provide price of marginal supplier which is useful in this case. Can you a little bit elaborate using noise which you mentioned earlier.tomfid wrote: ↑Wed Aug 21, 2019 7:53 pmIt seems like this should result in an outcome much like a single clearing price, but with a little more noise.
If I'm running unit X, I don't want to bid my marginal cost. I want to figure out where the market is likely to clear next period, and bid just below that.
However, the price in the next period will still be set by the marginal supplier, so the clearing logic in the alloc function applies. It's just that there's some uncertainty in what the load will be, and the supply curve is harder to observe, due to the strategic bidding behavior.
Loads are fixed. I am modeling wind onshore auction, in these auctions we have 700 MW as a tendered capacity( let's say demand) for each auction round. In addition, only average price is announced after auctions, so we can assume that they try to bid near average bid( like what you proposed)
Re: Integrating time step of optimization problem
I mentioned noise for the following reason. If the auction is structured so that bids reveal true marginal costs, and that information is disclosed, then everyone has a pretty good idea what the aggregate supply curve looks like. Therefore they can do a pretty good job of anticipating the clearing price next period. But if the information is not disclosed, they're guessing a little more. In that case, I'd expect the same outcome on average, but with more noise from differences of opinion about what will happen.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Integrating time step of optimization problem
Thanks for the productive conversation but I did not get it whether it is possible to model with Find Zero or not. As a conclusion, if you are asked to model this auction, which functions do you use for maximization part in vensim? Do you suggest allocation functions?tomfid wrote: ↑Wed Aug 21, 2019 9:06 pmI mentioned noise for the following reason. If the auction is structured so that bids reveal true marginal costs, and that information is disclosed, then everyone has a pretty good idea what the aggregate supply curve looks like. Therefore they can do a pretty good job of anticipating the clearing price next period. But if the information is not disclosed, they're guessing a little more. In that case, I'd expect the same outcome on average, but with more noise from differences of opinion about what will happen.
Re: Integrating time step of optimization problem
I've attached two models, neither of which is really right, but both in the ballpark.
#1 implements what I originally suggested, which is that everyone bids close to MAX( marg cost, expected price ). That actually implements collusion, and the price gets bid up to a high level. The missing piece is that it doesn't account for utilization. As long as the bidders are small relative to the market, they're price takers, and therefore they make money by pushing utilization as high as possible at the clearing price.
#2 implements that idea heuristically, but i didn't spend much time on it, and there's some discrete instability due to the 1hr time step. I'm sure it can be improved, but it expresses the basic idea.
I think the bottom line is that as long as the market is competitive and suppliers do a decent job of forming expectations, the market outcome will be pretty close to what the alloc functions yield without this behavioral detail.
#1 implements what I originally suggested, which is that everyone bids close to MAX( marg cost, expected price ). That actually implements collusion, and the price gets bid up to a high level. The missing piece is that it doesn't account for utilization. As long as the bidders are small relative to the market, they're price takers, and therefore they make money by pushing utilization as high as possible at the clearing price.
#2 implements that idea heuristically, but i didn't spend much time on it, and there's some discrete instability due to the 1hr time step. I'm sure it can be improved, but it expresses the basic idea.
I think the bottom line is that as long as the market is competitive and suppliers do a decent job of forming expectations, the market outcome will be pretty close to what the alloc functions yield without this behavioral detail.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Integrating time step of optimization problem
Here's a simpler model, in which everyone bids marginal cost and receives the clearing price.
Even with imcomplete information and a different payment scheme, I would expect the market to converge to an outcome like this, as long as it's competitive and not too dynamic (i.e. startup/shutdown costs not too severe).
If it's not competitive, there might be interesting leverage in redesigning the market.
I think you don't need FIND ZERO, except for more general cases, perhaps involving differential transmission losses between pairs of suppliers and demanders.
One extension of this framework that might be useful is to add a dummy plant representing unserved energy, with a high bid price.
If you play with the bias parameter, you can see that it's not really possible for one supplier to improve its outcome more than a tiny bit by bidding strategically. So, as you'd hope, the alloc algorithm is solving for a profitmaximizing competitive market outcome.Even with imcomplete information and a different payment scheme, I would expect the market to converge to an outcome like this, as long as it's competitive and not too dynamic (i.e. startup/shutdown costs not too severe).
If it's not competitive, there might be interesting leverage in redesigning the market.
I think you don't need FIND ZERO, except for more general cases, perhaps involving differential transmission losses between pairs of suppliers and demanders.
One extension of this framework that might be useful is to add a dummy plant representing unserved energy, with a high bid price.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Integrating time step of optimization problem
In the model above, you may discover that [s3] can sustain a fairly large positive bias. I think that's because there's a big jump in marginal cost to the nextcheapest producer [s6]. So, s3 could bid just below s6's marginal cost, rather than at its own marginal cost. That wouldn't hold up in a market with more competitors or less information though.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Integrating time step of optimization problem
Its greatly appreciated. I"ll work on both models and keep you posted about its improved version. (#2 can be improved with CDF well)tomfid wrote: ↑Wed Aug 21, 2019 10:02 pmI've attached two models, neither of which is really right, but both in the ballpark.
DEMAND AT PRICE elec 2.mdlDEMAND AT PRICE elec 1.mdl
#1 implements what I originally suggested, which is that everyone bids close to MAX( marg cost, expected price ). That actually implements collusion, and the price gets bid up to a high level. The missing piece is that it doesn't account for utilization. As long as the bidders are small relative to the market, they're price takers, and therefore they make money by pushing utilization as high as possible at the clearing price.
#2 implements that idea heuristically, but i didn't spend much time on it, and there's some discrete instability due to the 1hr time step. I'm sure it can be improved, but it expresses the basic idea.
I think the bottom line is that as long as the market is competitive and suppliers do a decent job of forming expectations, the market outcome will be pretty close to what the alloc functions yield without this behavioral detail.
Results of previous wind auctions in Germany confirm your last paragraph.