Integrating time step of optimization problem

Use this forum to post Vensim related questions.
RWTH_FCN
Senior Member
Posts: 127
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Integrating time step of optimization problem

Post by RWTH_FCN » Mon Jun 18, 2018 4:40 pm

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

Administrator
Super Administrator
Posts: 3422
Joined: Wed Mar 05, 2003 3:10 am

Re: Integrating time step of optimization problem

Post by Administrator » Mon Jun 18, 2018 5:25 pm

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/magazine-27509559

tomfid
Administrator
Posts: 2808
Joined: Wed May 24, 2006 4:54 am

Re: Integrating time step of optimization problem

Post by tomfid » Tue Jun 19, 2018 2:02 am

One strategy would be to replace the 24hr cycle with a 24-element 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

RWTH_FCN
Senior Member
Posts: 127
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Integrating time step of optimization problem

Post by RWTH_FCN » Tue Jun 19, 2018 1:04 pm

Administrator wrote:
Mon Jun 18, 2018 5:25 pm
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?
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.
Best,

RWTH_FCN
Senior Member
Posts: 127
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Integrating time step of optimization problem

Post by RWTH_FCN » Tue Jun 19, 2018 1:26 pm

tomfid wrote:
Tue Jun 19, 2018 2:02 am
One strategy would be to replace the 24hr cycle with a 24-element 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
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.

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

RWTH_FCN
Senior Member
Posts: 127
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Integrating time step of optimization problem

Post by RWTH_FCN » Tue Oct 09, 2018 9:22 am

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,

Administrator
Super Administrator
Posts: 3422
Joined: Wed Mar 05, 2003 3:10 am

Re: Integrating time step of optimization problem

Post by Administrator » Tue Oct 09, 2018 9:33 am

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.
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

RWTH_FCN
Senior Member
Posts: 127
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Integrating time step of optimization problem

Post by RWTH_FCN » Thu Oct 11, 2018 7:29 am

Administrator wrote:
Tue Oct 09, 2018 9:33 am
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.
Thanks a lot for your helpful suggestion.

RWTH_FCN
Senior Member
Posts: 127
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Integrating time step of optimization problem

Post by RWTH_FCN » Wed Aug 21, 2019 2:29 pm

tomfid wrote:
Tue Jun 19, 2018 2:02 am


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.
Can you please describe or send a sample model how to model economic dispatch with Find Zero?

tomfid
Administrator
Posts: 2808
Joined: Wed May 24, 2006 4:54 am

Re: Integrating time step of optimization problem

Post by tomfid » Wed Aug 21, 2019 6:13 pm

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.

RWTH_FCN
Senior Member
Posts: 127
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Integrating time step of optimization problem

Post by RWTH_FCN » Wed Aug 21, 2019 6:51 pm

tomfid wrote:
Wed Aug 21, 2019 6:13 pm
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.
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

tomfid
Administrator
Posts: 2808
Joined: Wed May 24, 2006 4:54 am

Re: Integrating time step of optimization problem

Post by tomfid » Wed Aug 21, 2019 7:09 pm

Doesn't everyone who supplies > 0 get paid at the (single) market clearing price, rather than their bid price?

RWTH_FCN
Senior Member
Posts: 127
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Integrating time step of optimization problem

Post by RWTH_FCN » Wed Aug 21, 2019 7:19 pm

tomfid wrote:
Wed Aug 21, 2019 7:09 pm
Doesn't everyone who supplies > 0 get paid at the (single) market clearing price, rather than their bid price?
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.

tomfid
Administrator
Posts: 2808
Joined: Wed May 24, 2006 4:54 am

Re: Integrating time step of optimization problem

Post by tomfid » Wed Aug 21, 2019 7:33 pm

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?

tomfid
Administrator
Posts: 2808
Joined: Wed May 24, 2006 4:54 am

Re: Integrating time step of optimization problem

Post by tomfid » Wed Aug 21, 2019 7:38 pm

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?

RWTH_FCN
Senior Member
Posts: 127
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Integrating time step of optimization problem

Post by RWTH_FCN » Wed Aug 21, 2019 7:46 pm

tomfid wrote:
Wed Aug 21, 2019 7:33 pm
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?
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.

tomfid
Administrator
Posts: 2808
Joined: Wed May 24, 2006 4:54 am

Re: Integrating time step of optimization problem

Post by tomfid » Wed Aug 21, 2019 7:53 pm

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.

RWTH_FCN
Senior Member
Posts: 127
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Integrating time step of optimization problem

Post by RWTH_FCN » Wed Aug 21, 2019 7:55 pm

tomfid wrote:
Wed Aug 21, 2019 7:38 pm
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?
Yes, its more game theoretic. For capacity constraints I only consider upper limit and lower boundry is 0.
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.

RWTH_FCN
Senior Member
Posts: 127
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Integrating time step of optimization problem

Post by RWTH_FCN » Wed Aug 21, 2019 8:07 pm

tomfid wrote:
Wed Aug 21, 2019 7:53 pm
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.
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.
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)

tomfid
Administrator
Posts: 2808
Joined: Wed May 24, 2006 4:54 am

Re: Integrating time step of optimization problem

Post by tomfid » Wed Aug 21, 2019 9:06 pm

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.

RWTH_FCN
Senior Member
Posts: 127
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Integrating time step of optimization problem

Post by RWTH_FCN » Wed Aug 21, 2019 9:56 pm

tomfid wrote:
Wed Aug 21, 2019 9:06 pm
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.
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
Administrator
Posts: 2808
Joined: Wed May 24, 2006 4:54 am

Re: Integrating time step of optimization problem

Post by tomfid » Wed Aug 21, 2019 10:02 pm

I've attached two models, neither of which is really right, but both in the ballpark.
DEMAND AT PRICE elec 2.mdl
(10.1 KiB) Downloaded 20 times
DEMAND AT PRICE elec 1.mdl
(8.9 KiB) Downloaded 16 times
#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.

tomfid
Administrator
Posts: 2808
Joined: Wed May 24, 2006 4:54 am

Re: Integrating time step of optimization problem

Post by tomfid » Wed Aug 21, 2019 10:37 pm

Here's a simpler model, in which everyone bids marginal cost and receives the clearing price.
DEMAND AT PRICE elec 0.mdl
(8.55 KiB) Downloaded 13 times
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 profit-maximizing 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.

tomfid
Administrator
Posts: 2808
Joined: Wed May 24, 2006 4:54 am

Re: Integrating time step of optimization problem

Post by tomfid » Wed Aug 21, 2019 10:53 pm

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 next-cheapest 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.

RWTH_FCN
Senior Member
Posts: 127
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Integrating time step of optimization problem

Post by RWTH_FCN » Wed Aug 21, 2019 11:04 pm

tomfid wrote:
Wed Aug 21, 2019 10:02 pm
I'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.
Its greatly appreciated. I"ll work on both models and keep you posted about its improved version. (#2 can be improved with CDF well)

Results of previous wind auctions in Germany confirm your last paragraph.

Post Reply