Info

This question is closed. Reopen it to edit or answer.

cant find the value of 'f' for various values of b(1) and b(2)

1 view (last 30 days)
function f = objfun1(x)
x(1)=1
x(2)=1
b(1)=x(1)
b(2)=x(2)
%minimize the objective function f for various values of b(1) and b(2)
f= 2.2+256.1777777*b(2)^-2+3.7333334*b(1)^2*b(2)^-2-31.733333*b(2)^-1+4.0*b(1)*b(2)^-1
x=fmincon(@objfun1,[1;1],[0],[0])

Answers (1)

Walter Roberson
Walter Roberson on 31 Aug 2015
objfun1 = @(b) 2.2+256.1777777*b(2)^(-2)+3.7333334*b(1)^2*b(2)^(-2)-31.733333*b(2)^(-1)+4.0*b(1)*b(2)^(-1);
x = fmincon(objfun1,[1;1],[0],[0]);
However, please check your fmincon() call. You are calling with A=0 and b=0, so you are imposing the condition that A*x <= b which is then 0*x <= 0 which is then 0 <= 0 which is always going to be true. Are you sure you are not trying to code lower bounds?
A = [], b = []; Aeq = [], beq = []; lb = [0,0]; ub = [];
x = fmincon(objfun1, [1;1], A, b, Aeq, beq, lb, ub);
  3 Comments
Walter Roberson
Walter Roberson on 31 Aug 2015
If b(1) and b(2) are non-negative then you can simplify the formula by examination. b(1) only occurs in locations that have positive coefficients multiplied by a power of b(1) multiplied by a power of b(2). b(2) is nonnegative as well, so the powers are going to be non-negative; when you combine that with the positive coefficient, the minimum contribution for those terms is going to occur when b(1) is 0 (or b(2) is infinite.)
You can therefore simplify the expression to an expression in one variable, which is then easier to minimize. For example, differentiate it with respect to b(2), solve for 0; you can get the exact result to within the limitations of the accuracy of your coefficients. The solution is b[1] = 0, b[2] = 4610992496 / 285587145
Walter Roberson
Walter Roberson on 2 Sep 2015
I suspect that there was more to the error message, such as the reason for failure.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!