-3

I want to find a variable in C++ that allows a given nonlinear formula to have a maximum value in a constraint.

It is to calculate the maximum value of the formula below in the given constraint in C++. You can also use the library.(e.g. Nlopt)

  • formula : ln(1+ax+by+c*z)

  • a, b, c are numbers input by the user

  • x, y, z are variables to be derived

  • variable constraint is that x, y, z are positive and x+y+z<=1

1 Answers1

0

This can actually be transformed into a linear optimization problem.

max ln(1+ax+by+cz) <--> max (ax+by+cz) s.t. ax+by+cz > -1

This means that it is a linear optimization problem (with one more constraint) that you can easily handle with whatever C++ methods together with your Convex Optimization knowledge.

Reminders to write a good code:

  • Check the validity of input value.
  • Since the input value can be negative, you need to consider this circumstance which can yield different results.

P.S.

  • This problem seems to be Off Topic on SO.
  • If it is your homework, it is for your own good to write the code yourself. Besides, we do not have enough time to write that for you.
  • This should have been a comment if I had more reputation.
Teddy van Jerry
  • 176
  • 1
  • 3
  • 11