# How to optimize a function by maximizing 1 variable and minimizing another?

Problem

I want to implement an optimization algorithm for my file transfer program.

The program buffers data in a local file before uploading to central server periodically and it compresses the files before transferring.

I would want the program to intelligently predict the time and size thresholds before transferring.

The objective function could be defined as following

f(u) = theta1*u + (theta2*u)/b + theta3

where

• u is the size of data
• b is the network bandwidth (bps)
• f(u) is the time taken to transfer u bytes of data.
• theta1*u refers to amount of time taken to compress u bytes of data
• theta2*u*b refers to time taken to transfer compressed data.
• theta3 is constant protocol overhead

I want to be able to optimize the transfer by minimizing time and maximizing uncompressed size. If I were to simply minimize f(u) that would have been easy but then in this particular case , I would also want to maximize amount of data to be transferred. The idea is to be able to come up with a machine learning algorithm which can change as per different network scenarios and fluctuating bandwidth , rather than user providing it at start of program.

Of course, I would implement it with some sane seed values and keep them within sane boundaries.

Solution space

Given the nature of this problem , which class of algorithms should I be looking into? Would gradient descent be the right way to approach this? is it possible to apply maximize and minimization on same function of 2 different variables? Am I over-thinking this ?

• I don't think you are clearly differentiating your objective function from your variables. You don't try to minimize or maximize your variables, you try to find variables which minimize or maximize your objective function. – Vaughn Cato Jan 20 '16 at 13:53
• Please edit the question to identify clearly which symbols refer to constants and which are variables that can be changed freely. Are theta1, theta2, theta3, b assumed to be known constants? Also theta2*u*b makes no sense as a representation of the time to transfer the compressed data: in real life, the larger the network bandwidth (b), the less time it takes to transfer the data (your formula predicts the opposite, which is clearly wrong). – D.W. Jan 21 '16 at 11:26
• Anyway, my answer still remains valid. You can't say "f(u) is my objective function" and then later say "I want to both minimize f(u) and maximize uncompressed size". That's self-contradictory. The definition of an objective function is that it's the thing you want to minimize. Saying "f(u) is my objective function" means that you want to minimize f(u) [without regard to anything else]. And as my answer explains, to make the problem well-defined, you need to pick a single objective function to minimize, not two. – D.W. Jan 21 '16 at 11:28

## 2 Answers

You would have to look at multiobjective optimisation, with these methods you can optimise two functions at the same time. Just be aware that, depending on the method that you end up using, you might have in the end a number of solutions equally good (trade offs) which you would have to choose from.

You can't. The optimal solution is not well-defined. In general there will be a range of tradeoffs between minimizing time and uncompressed size, and you haven't specified anything that would allow uniquely identifying which you want.

Your first step is that you need to specify a single objective function, where the goal is to find a solution that maximizes the objective function. Then you can try applying standard methods from mathematical optimization, e.g., gradient descent, Newton's method, and so on.

• Your comment clarified it for me! Thanks! – rajeshnair Jan 22 '16 at 10:55