0

Here is my the optimization problem I want to solve. I want to add a new constraint which is the following:

enter image description here

  • Z is the set of products in the user basket
  • similarity(zi,zj) is a similarity function measuring the similarity of products zi and zj.

The goal of this new constraint is to ensure that our user basket does not contain similar (redundant) products.

How can I add this constraint, if we suppose that I have a similarity function called similarity(product1, product2) that takes as argument two products and gives as a result the similarity between them.

Thank

sel
  • 942
  • 1
  • 12
  • 25

1 Answers1

1

Let me share an example. Compared to the previous model I shared you could add:

float similarity[i in allProducts][j in allProducts]=
abs(ord(allProducts,i)-ord(allProducts,j));

float sim=4;

before the subject to block and then:

ctSim:
     forall(ordered i,j in allProducts) z[i]*z[j]*similarity[i][j]<=sim;
}

in the subject to block.

halfer
  • 19,824
  • 17
  • 99
  • 186
Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15