How to define subtle change in vector depending if values are different in a summation?

31 Views Asked by At

I have a matrix which helps to calculate the selected inlet flow of a reservoir based on a selection variable, we use this to give us the flow rates in shape of (7, 1). We can reshape this variable to meet our preexisting needs of calculating all within the reservoir, however for some cases this may not be a true reflection on what happens.

Consider the following; in some instances we may be limited to how fast the flow rate can be increased over period of time. The shape (7, 1) looks at 7 different time periods across a 24 hour period. Assume we CHANGE_RATE is 0.5 per half hour (48 in 24 hours) currently our input_flow_ would look like the following: [112 0 0 0 0 0 0], which would reshape for the first 8 hour period something like this [112 112 112 112 112 112 112 112 ]. This would not be a true reflection of what will happen when we control as we will need to adjust assuming our CURRENT_FLOW_RATE is something like 114, I would require an output of [113.5 113 112.5 112 112 112 112 112] thus allowing a better calculation of what we thing the reservoir should do.

See below code of what I currently have implemented, I am unsure how to further develop in what I would require as it would also need to change similar if we selected different flows throughout the day say from 112 to 113 etc.

        input_flow_matrix=np.zeros((max(period_lengths),len(period_lengths)))
        for i,l in enumerate(period_lengths):
            input_flow_matrix[:l,i]=1
        selection = cp.Variable(shape=cost_.shape,boolean=True)
        assignment_constraint = cp.sum(selection,axis=1) == 1
        input_flow_= cp.sum(cp.multiply(flow_,selection),axis=1)

        current_flow = 114.0
        ramp_rate = 0.5

        input_flow_vector=cp.vec(cp.multiply(input_flow_matrix,np.ones((max(period_lengths), 1)) @ cp.reshape(input_flow_,(1,len(period_lengths)))))

max(period_lengths) == 16 len(period_lengths) == 7

I would really appreciate any guidance into how to progress with this problem.