How to code a lookup table in the objective function in PyOMO

245 Views Asked by At

I need to solve an optimization problem to maximize the volume out of a group customers, which a function of parameter x.

S = customers.keys()
model_max_volume = ConcreteModel()

model_max_volume.x = Var(S, domain=PositiveIntegers, initialize=500)

model_max_volume.volume = Objective(expr=sum(volume(model_max_volume.x[acctnum], acctnum) for acctnum in S), sense=maximize)

In function volume, parameter x will change depending on a lookup table.

---------------------------------------------------------------------- 
x_lower_bound |x_upper_bound    |delta_change_lower_bound |delta change_upper_bound |change factor for x
---------------------------------------------------------------------- 
500           |1000             |0.0                      |0.3                      | 0.8
---------------------------------------------------------------------- 
500           |1000             |0.3                      |0.8                      | 0.4           
---------------------------------------------------------------------- 
1000          |2000             |0.0                      |0.5                      | 1.5           
----------------------------------------------------------------------

for example, if x is set to 500, and the value of another parameter follows between the lower bound and upper bound, the value in the column "change factor for x" needs to be returned.

The returned value will be used in the volume function, as shown in below.

def volume(x, acctnum):
    
    global dict_lookup, dict_delta
       
    delta_change = (x-dict_delta[acctnum]['a'])/dict_delta[acctnum]['a']

    returned_factor = f(x, delta_change)  ???????

    volume = f(x, returned_factor)
    
    return volume
        

My question is how to implement the lookup in PyOMO. Greatly appreciate anyone here can help me out!

Thanks!

0

There are 0 best solutions below