def __init__(self, fs): fs = tuple(fs) self.fs = fs mcdp_dev_warning('add promotion to SpaceProduct') dom = SpaceProduct(tuple(fi.get_domain() for fi in fs)) cod = SpaceProduct(tuple(fi.get_codomain() for fi in fs)) Map.__init__(self, dom=dom, cod=cod)
def __init__(self, baseline=100): self.baseline = baseline M = SpaceProduct(()) R = R_Weight_g F = R_Weight_g PrimitiveDP.__init__(self, F=F, R=R, M=M)
def __init__(self, T, alpha): self.T = T self.alpha = alpha M = SpaceProduct(()) F = R_Weight_g R = R_Energy PrimitiveDP.__init__(self, F=F, R=R, M=M)
def __init__(self, Tmax, W0, rho): self.Tmax = Tmax self.W0 = W0 self.rho = rho F = PosetProduct((R_Energy, R_Time)) R = R_Weight_g M = SpaceProduct(()) PrimitiveDP.__init__(self, F=F, R=R, M=M)
def __init__(self, energy_density): ''' :param energy_density: Joule/gram ''' self.energy_density = float(energy_density) M = SpaceProduct(()) F = R_Energy R = R_Weight_g PrimitiveDP.__init__(self, F=F, R=R, M=M)
def to_be_updated_check_evaluation(): ndp = parse_ndp(""" mcdp { sub f = instance mcdp { provides a [dimensionless] requires c [dimensionless] c >= square(a) } f.a >= square(f.c) # a^2 > c^2 } """) dp = ndp.get_dp() print(dp.repr_long()) M = dp.get_imp_space() assert_equal(M, SpaceProduct((R_dimensionless, ) * 4)) assert_equal(dp.get_res_space(), SpaceProduct(())) assert_equal(dp.get_fun_space(), SpaceProduct(())) print dp.solve(()) # = ↑{⟨⟩} imps = dp.get_implementations_f_r((), ()) print imps # here, (x,y) => (x,y,y,y) actually I'm not sure assert_feasible(dp, (), (0.0, 0.0, 0.0, 0.0), ()) assert_feasible(dp, (), (1.0, 1.0, 1.0, 1.0), ()) assert_unfeasible(dp, (), (0.0, 1.0, 1.0, 1.0), ()) assert_unfeasible(dp, (), (0.0, 0.9, 0.9, 0.9), ()) assert_feasible(dp, (), (0.5, 0.5, 0.5, 0.5), ()) assert_unfeasible(dp, (), (1.0, 0.0, 0.0, 0.0), ()) assert_unfeasible(dp, (), (1.1, 1.1, 1.1, 1.1), ()) assert_unfeasible(dp, (), (0.9, 0.0, 0.0, 0.0), ()) import numpy as np xs = np.linspace(0, 1.5, 30) ys = np.linspace(0, 1.5, 30) print_diagram(dp, xs, ys)
def to_be_updated_check_evaluation2(): ndp = parse_ndp(""" mcdp { sub f = instance mcdp { provides a [dimensionless] requires c [dimensionless] c >= sqrt(a) } f.a >= sqrt(f.c) } """) dp = ndp.get_dp() print(dp.repr_long()) M = dp.get_imp_space() Is = dp.get_implementations_f_r((), ()) print Is assert_equal(M, SpaceProduct((R_dimensionless, ) * 4)) assert_equal(dp.get_res_space(), SpaceProduct(())) assert_equal(dp.get_fun_space(), SpaceProduct(())) assert_feasible(dp, (), (0.0, 0.0, 0.0, 0.0), ()) assert_feasible(dp, (), (1.0, 1.0, 1.0, 1.0), ()) assert_feasible(dp, (), (1.1, 1.1, 1.1, 1.1), ()) assert_unfeasible(dp, (), (0.5, 0.5, 0.5, 0.5), ()) assert_unfeasible(dp, (), (2.0, 1.0, 1.0, 1.0), ()) assert_unfeasible(dp, (), (1.0, 2.0, 2.0, 2.0), ()) import numpy as np xs = np.linspace(0, 3.5, 30) ys = np.linspace(0, 3.5, 30) print_diagram(dp, xs, ys)
def __init__(self): F = R_dimensionless R = R_dimensionless M = SpaceProduct(()) PrimitiveDP.__init__(self, F=F, R=R, M=M)
def __init__(self): F = R_Weight_g R = R_Power M = SpaceProduct(()) PrimitiveDP.__init__(self, F=F, R=R, M=M)
def __init__(self, F, R): I = SpaceProduct(()) PrimitiveDP.__init__(self, F=F, R=R, I=I)