Пример #1
0
 def test_prod2(self):
     model = ConcreteModel()
     model.A = Set(initialize=[1,2,3], doc='set A')
     model.x = Var(model.A)
     expr = prod(model.x[i] for i in model.x)
     baseline = "x[1]*x[2]*x[3]"
     self.assertEqual( str(expr), baseline )
     expr = prod(model.x)
     self.assertEqual( expr, 6)
Пример #2
0
 def R_J_ub_init(model, j):  # !!!
     if pe.value(model.R_J_func_type) == 1:
         return (model.R_J_base[j] + (sum(
             model.z_ub[g] * model.upsilon_tilde[g, pe.value(model.Hz)] *
             (model.D_J_base[j]) + (1 / model.z_lb[g]) *
             model.upsilon_tilde[g, pe.value(model.sec)] *
             (model.D_J_base[j]) for g in model.G)) / 1000 + 1)
     if pe.value(model.R_J_func_type) is 2:
         return (
             model.R_J_base[j] +
             sum(model.z_J_ub[g, j] *
                 model.upsilon_tilde[g, pe.value(model.Hz)] * (
                     model.D_J_base[j] + pe.prod(model.z_J_ub[g, j]  #!!!
                                                 * model.upsilon_r[g]
                                                 for g in model.G)) +
                 (1 / model.z_J_lb[g, j]) *
                 model.upsilon_tilde[g, pe.value(model.sec)] * (
                     model.D_J_base[j] + pe.prod(model.z_J_ub[g, j]  #!!!
                                                 * model.upsilon_r[g]
                                                 for g in model.G))
                 for g in model.G) / 1000 + 1)
 def new_load_rule(mdl):
     temp = sum([mdl.phi[l, u, h] * mdl.alpha[l, u, h] *
                 pyo.prod([(1 - sum([(mdl.x[b, l, u, h] / mdl.alpha[l, u, h]) * mdl.eta[b, l, u]
                                     if ((pyo.value(mdl.alpha[l, u, h]) > 1e-6) &
                                         ((b, gamma) in mdl.BMPGRPING) &
                                         ((b, u) in mdl.BMPSRCLINKS))
                                     else 0
                                     for b in mdl.BMPS]))
                           if (gamma, u) in mdl.BMPGRPSRCLINKS
                           else 1
                           for gamma in mdl.BMPGRPS])
                 for l, u, h in mdl.PARCELS])
     return temp
Пример #4
0
 def Compute_R_J_rule(model, j):
     if pe.value(model.R_J_func_type) == 1:
         return (model.R_J[j] == model.R_J_base[j] +
                 (sum(model.z_kappa[g, j] *
                      model.upsilon_tilde[g, pe.value(model.Hz)] *
                      (model.D_J_base[j]) + (1 / model.z_kappa[g, j]) *
                      model.upsilon_tilde[g, pe.value(model.sec)] *
                      (model.D_J_base[j]) for g in model.G)) / 1000)
     if pe.value(model.R_J_func_type) is 2:
         return (
             model.R_J[j] == model.R_J_base[j] +
             sum(model.z_kappa[g, j] *
                 model.upsilon_tilde[g, pe.value(model.Hz)] * (
                     model.D_J_base[j] + pe.prod(model.z_kappa[g, j]  #!!!
                                                 * model.upsilon_r[g]
                                                 for g in model.G)) +
                 (1 / model.z_kappa[g, j]) *
                 model.upsilon_tilde[g, pe.value(model.sec)] * (
                     model.D_J_base[j] + pe.prod(model.z_kappa[g, j]  #!!!
                                                 * model.upsilon_r[g]
                                                 for g in model.G))
                 for g in model.G) / 1000)
Пример #5
0
    def new_load_rule(mdl, p):
        newload = pyo.quicksum(
            mdl.phi[s, u, h, p] * mdl.alpha[s, u, h] *
            pyo.prod([(1 - sum((mdl.x[b, s, u, h] / mdl.alpha[s, u, h]) *
                               mdl.eta[b, s, u, p] if (
                                   (pyo.value(mdl.alpha[s, u, h]) > 1e-6) & (
                                       (b, G) in mdl.BMPGRPING) & (
                                           (b, u) in mdl.BMPSRCLINKS)) else 0
                               for b in mdl.BMPS)) if
                      (G, u) in mdl.BMPGRPSRCLINKS else 1
                      for G in mdl.BMPGRPS]) for s, u, h in mdl.PARCELS)

        return newload
Пример #6
0
    def new_load_rule_for_each_lrseg(mdl, thisl, p):
        newload = pyo.quicksum(
            mdl.phi[s, u, h, p] * mdl.alpha[s, u, h] *
            pyo.prod([(1 - sum((mdl.x[b, s, u, h] / mdl.alpha[s, u, h]) *
                               mdl.eta[b, s, u, p] if (
                                   (pyo.value(mdl.alpha[s, u, h]) > 1e-6) & (
                                       (b, gamma) in mdl.BMPGRPING) & (
                                           (b, u) in mdl.BMPSRCLINKS)) else 0
                               for b in mdl.BMPS)) if
                      (gamma, u) in mdl.BMPGRPSRCLINKS else 1
                      for gamma in mdl.BMPGRPS]) if (s == thisl) else 0
            for s, u, h in mdl.PARCELS)

        return newload
Пример #7
0
 def test_prod1(self):
     self.assertEqual(prod([1,2,3,5]),30)
Пример #8
0
def a2Category_rule(model, n):
    return sum(
        pyomo.prod([model.DSA[t, n] for t in range(q, model.Req[n] + q)])
        for q in range(len(model.T) - model.Req[n])) >= 1
Пример #9
0
 def lowere_rule(mdl, f, l):
     temp_val = pyo.prod([
         1 - mdl.eta[(bmp_tuple, l)] for bmp_tuple in fi_dict_fkeys[f]
     ])
     # lowerecalc[(fi_dict_fkeys[(b1, b2)], lrsegid)] =
     return temp_val