Guest User

Untitled

a guest
Jan 16th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. model = AbstractModel()
  2.  
  3. model.tops = Set()
  4. model.bottoms = Set()
  5. model.shoes = Set()
  6. model.looks = Set()
  7.  
  8. model.theta = Param(within=NonNegativeIntegers)
  9. model.tol = Param(within=NonNegativeIntegers)
  10. model.hue_tops = Param(model.tops, within=UnitInterval)
  11. model.hue_bottoms = Param(model.bottoms, within=UnitInterval)
  12. model.hue_shoes = Param(model.shoes, within=UnitInterval)
  13.  
  14. model.top_cnt = Var(model.looks * model.tops, domain=Binary)
  15. model.bottom_cnt = Var(model.looks * model.bottoms, domain=Binary)
  16. model.shoe_cnt = Var(model.looks * model.shoes, domain=Binary)
  17.  
  18.  
  19. def split_comp_color(model, look):
  20. theta = model.theta # 30
  21. tol = model.tol # 10
  22. 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
  23.  
  24.  
  25. model.split_comp_color = Constraint(model.looks, rule=split_comp_color)
Add Comment
Please, Sign In to add comment