Thread Subject: help for constrained optimization -using fmincon

Subject: help for constrained optimization -using fmincon

From: Ramana Murthy

Date: 17 Sep, 2009 05:28:02

Message: 1 of 2

Hi
I am trying to minimize a function (y) with linearity constraint.
I was using the fmincon and I'm not getting desired results. Terminating message is coming.
So I also passed on gradient also. But now program is showing error. Can someone tell me where is the problem.

with regards,
murthy

******************
clear all
clc
global lk sk;
lk = [52,81,77,76,16,106,48,99,66,79];
sk = [0.39,0.56,1.03,0.47,0.93,1.20,1.74,1.86,1.23,0.54];
K = 10;
R = 350;
x0 = lk/4;
% f = @(x)parameterfun(x,sk,lk);
A = [];
b = [];
Aeq = ones(1,K);
beq = R;
lb = zeros(1,K);
ub = lk;
options = optimset('Algorithm','active-set');
options = optimset(options,'GradObj','on');
tic
[x,fval]=fmincon(@parameterfun,x0,A,b,Aeq,beq,lb,ub,[],options);
[x' rk']
toc
**********
function [y,g] = parameterfun(x)
global lk sk;
y = 0;
for i = 1:numel(x)
    y = y + sk(i)*exp(-2*pi/sk(i))*(exp(2*pi*x(i)/(lk(i)*sk(i)))-1);
end
if nargout > 1
    g = 0;
    for i = 1:numel(x)
        g = g + 2*pi/lk(i)*exp(-2*pi/sk(i))*exp(2*pi*x(i)/(lk(i)*sk(i)));
    end
end
**************

Subject: help for constrained optimization -using fmincon

From: Bruno Luong

Date: 17 Sep, 2009 06:29:04

Message: 2 of 2

"Ramana murthy" <omurthy@yahoo.com> wrote in message <h8shd2$sb6$1@fred.mathworks.com>...
> Hi
> I am trying to minimize a function (y) with linearity constraint.
> I was using the fmincon and I'm not getting desired results. Terminating message is coming.
> So I also passed on gradient also. But now program is showing error. Can someone tell me where is the problem.
>

The gradient is a VECTOR. I see you compute some sort of scalar, so it must NOT be a gradient.

Bruno

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
fmincon Sprinceana 17 Sep, 2009 05:08:28
rssFeed for this Thread

Contact us at files@mathworks.com