mardi 23 janvier 2018

how can i put variables into if using python, pyomo

I want to simulate using python Among the necessary constraints, there is a constraint that contains the max function. I separated it using 'if'. However, 'if' contains variables and can not be executed. Could you tell me how to include variables in 'if' or variables in max?

==========================================

def comfirststage_rule(model): 

    if (-model.wind1 - model.discharge[1,1] + model.charge[1,1] + model.bidding[1,1]) <= 0.0 :*

        return model.FirstStageCost - model.price[1,1]*model.bidding[1,1] - (model.wind2 +model.discharge[1,1] - model.charge[1,1] - model.bidding[1,1])*model.penalty[1,1] - model.bidding[1,2]*(model.price[1,2] + model.coeffru[1,1]*model.price[1,1]) - model.bidding[1,3]*(model.price[1,3]-model.price[1,1]*model.coeffrd[1,1]) == 0.0
    else:
        return model.FirstStageCost - model.price[1,1]*model.bidding[1,1] + (model.bidding[1,1]-model.discharge[1,1]+model.charge[1,1]-model.wind1)*model.penalty[1,2] - model.bidding[1,2]*(model.price[1,2] + model.coeffru[1,1]*model.price[1,1]) - model.bidding[1,3]*(model.price[1,3]-model.price[1,1]*model.coeffrd[1,1]) == 0.0

model.comfirststage = Constraint(rule=comfirststage_rule)

Aucun commentaire:

Enregistrer un commentaire