Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- model = AbstractModel()
- model.tops = Set()
- model.bottoms = Set()
- model.shoes = Set()
- model.looks = Set()
- model.theta = Param(within=NonNegativeIntegers)
- model.tol = Param(within=NonNegativeIntegers)
- model.hue_tops = Param(model.tops, within=UnitInterval)
- model.hue_bottoms = Param(model.bottoms, within=UnitInterval)
- model.hue_shoes = Param(model.shoes, within=UnitInterval)
- model.top_cnt = Var(model.looks * model.tops, domain=Binary)
- model.bottom_cnt = Var(model.looks * model.bottoms, domain=Binary)
- model.shoe_cnt = Var(model.looks * model.shoes, domain=Binary)
- def split_comp_color(model, look):
- theta = model.theta # 30
- tol = model.tol # 10
- return sum([model.top_cnt[look, top] * model.bottom_cnt[look, bottom] * model.shoe_cnt[look, shoe] * int(((p[0]-p[1])-math.floor(p[0]-p[1]) > ((180-theta/2)-tol/2)/360) & ((p[0]-p[1])-math.floor(p[0]-p[1]) < ((180-theta/2)+tol/2)/360) & ((p[0]-p[2])-math.floor(p[0]-p[2]) > ((180+theta/2)-tol/2)/360) & ((p[0]-p[2])-math.floor(p[0]-p[2]) < ((180+theta/2)+tol/2)/360)) for top in model.tops for bottom in model.bottoms for shoe in model.shoes for p in permutations(np.array([model.hue_tops[top], model.hue_bottoms[bottom], model.hue_shoes[shoe]]), 3)]) >= 0.1
- model.split_comp_color = Constraint(model.looks, rule=split_comp_color)
Add Comment
Please, Sign In to add comment