[英]Pyomo constraints and using pandas
I am using Pyomo to optimize a cashflow matching problem using bonds.我正在使用 Pyomo 使用债券优化现金流匹配问题。 I also want to have a detailed constraint that does looks at the cashflows I am expecting to get from my portfolio versus fixed requirements and conduct a number of calculations on the differences:我还希望有一个详细的约束来查看我期望从我的投资组合中获得的现金流与固定要求,并对差异进行一些计算:
[Excel description of process][1] [过程Excel说明][1]
Now Panda commands don't work in this situation.现在 Panda 命令在这种情况下不起作用。 Is there anything I can do to fix this?我能做些什么来解决这个问题吗? Alternative approaches?替代方法?
Thanks gmavrom.谢谢gmavrom。
Trying to think a different formulation.试图想一个不同的表述。 The code below has Multipliers as the model variable and everything else as parameters.下面的代码将乘数作为 model 变量,并将其他所有内容作为参数。 Unfortunately the below doesn't work and just prints out strings of:不幸的是,以下内容不起作用,只会打印出以下字符串:
54993.219033692505*Multipliers[Bond1] + 63662.18895851663*Multipliers[Bond2] + 64451.10079031628*Multipliers[Bond3] + … etc 54993.219033692505*Multipliers[Bond1] + 63662.18895851663*Multipliers[Bond2] + 64451.10079031628*Multipliers[Bond3] + ... 等
def Test1_Constraint(model, TimeIndex):
SumAccumulatedShortfall=0
for TimeCount in range(0,TimeIndex+1):
AccumulatedShortfall = (model.Liabilities[TimeCount] - \
sum(model.BondPayment[BondIndex, TimeCount] *model.Multipliers[BondIndex] for BondIndex in model.Bonds))* \
model.AccumulationFactor[TimeCount]
SumAccumulatedShortfall = SumAccumulatedShortfall + AccumulatedShortfall
print('SumAccum',SumAccumulatedShortfall)
return (SumAccumulatedShortfall/model.TotalLiabilityValue <= 0.03)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.