Hello,

beginner here. I’m working on a model and i’m stuck on this part.

I have a set of items that are connected to each other. Each item either enhances the other items in the set or detracts from them.

So i created a table and gave a value to the interaction between the items and it looks something like this:

item1 item2 item3 item4

item1 1 3 2 -2

item2 3 1 -1 1

item3 2 -1 1 2

item4 -2 1 2 1

the model will choose a selection of the items based on some other constraints. What i would like to do is get the sum of the all the interactions of the items the model will choose and also get the number of items that were chosen. For example the model chose item1 item3 and item 4, the sum based on the table above would be ((3)+(-2))+((2)+(2))+((-2)+(2)) without choosing the interaction of the item with itself. And then the model would assign a value of 3 for the item number chosen because 3 items with chosen based on the other constraints (item1. item3, and item4)

if anyone would be kind enough to help i would greatly appreciate it.