data = randn(n)
model = Model(Ipopt.Optimizer)
@variable(model, a) #max distance
y[ii=1:10], sum( sin(x*data[i]) for i = 1+floor(Int,(n/10)*ii-1):floor(Int,(n/10)*ii) ) # 10 segments y[1:10] - just cumsum
yy[ii=1:9], (-y[ii]+y[ii+1] )^2 # just abs(distance) , but ^2
@NLconstraint(model, [i=1:9],yy[i] <= a) #max distance , 10 segments=9 distances
#@NLconstraint(model, [i=1:9],yy[i] >= 2) #next to implement : slope of process, each segment must raise minimum 2)
a # minimize max distance
print( objective_value(model) )
value.(y) # currently zeros(10), but when slope added
Normaly I just min/max objective function, but in graph (y here) I observe sometimes very strange behaviours. So if graph of process looks like line, it would be very good.
I have other max objective function working with Ipopt. Sometimes value of y[i] jumps above global optimum, then went down.
From time perspective (y…y), I was curious, if there is (simplyfied ) way to ‘model’ graph.
(1) Current situation, ignoring graph, only min/max obj (newest y
(2) Better graph
*(3) Line graph
*(4) Best line graph with high obj
( * good solutions)