I am new to JuMP and optimization using Julia and I am wondering if someone could explain to me why the following occurs. If I run the toy problem below with size_overall = 100 it takes some time, call it t1. The second time I do so it takes not even a second. Now if I rerun the code with size_overall = 1000 it again takes time even longer than t1. Reruning it again with size_overall = 100 takes again only seconds. I have also played around with bigger and smaller sizes.
What I need to do with a similar code is to run it consequetively many times with the size of x changing each time. However from this toy example it seems every time the size of the input vector is changed there is some large overhead. Would someone know why this is the case and how I can avoid it. It seems to be caused by optimize!(model) and I sould probably note that I am running it in a jupyter notebook.
Thank you very much for your help and time in advance!
size_overall = 1000
model = Model(Ipopt.Optimizer)
JuMP.register(model, :f, size_overall, cost_func,grad_cost_func)