# Partitioning values into sets

#### nerdjock

Hello,

I have a problem where I have a set of positive real numbers and must partition this set into two new sets such that:

1. The sum of the values in each set is as close as possible to the sum of the values in the other set. i.e. the difference is as close to zero as is possible.

2. A function f defined over the elements of each set is simultaneously minimized for both sets.

Essentially such that (Absolute value of difference of the sum in each set)+ (Sum of value of function in each set) is as small as possible. One condition may be more important than the other, so weights may be applied to both conditions to signify relative importance.

What techniques could I use for this? It would be great if someone could identify which branch of mathematics this falls under, as I would very much like to learn about it for myself, but am unable to determine were I should be looking.

#### fresh_42

Mentor
2018 Award
You have two function $f,g\, : \,S \longmapsto \mathbb{R}_+$ and weights, which means a single function $H\, : \,\lambda f + (1-\lambda)g$ which you want to minimize. Depending on the amount of date, a brute force method could be successful. In case you can model your data by a continuous function, a Lagrange multiplier ansatz might work.

"Partitioning values into sets"

### Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving