From: RoopBK on
Continuing on with my quest in optimization, I am looking to find a particular solution using a multi-objective optimization function. My design variables would be BDLT, BALPHA, BALPHY, and BPHIP. Fx, Fy, Fz, Mx, My, Mz would be the objective. The function takes the following form:

[Fx, Fy, Fz, Mx, My, Mz] = aFunc(BDLT, BALPHA, BALPY, BPHIP)
%(where BDLT is a 1x4 Matrix)

After reading up on the optimization functions in Matlab, it looks as though the function fgoalattain would be best for a nonlinear, multiobjective function. I set up my solver as such:

XO = [0 0 0 0 0 0 0] % Set initial values to 0; steady state
goal = [0 1 0 0 1 0]; % This is the value that I want to set for [Fx, Fy, Fz, Mx, My, Mz]
weight = abs(goal); % Equal weight to all goal values
options = optimset('Display', 'iter'); % Set display parameter

[X, fval, attainfactor] = fgoalattain('aFunc', XO, goal, weight, [], [], [], [], [], [], [], options);

I put seven []'s, which should be the seven outputs I want: [BDLT(4), BALPHA, BALPHY, BPHIP]. By my understanding, X should output a vector with the seven values I want, given the defined goal. I receive the following error:

??? Input Argument “BALPHA” is undefined.

Error in ++> fgoalattain at 371
user_f = feval(funfcn(3), x, varargin(:));

I'm sure that I'm just not understanding my input and output vectors correctly, but I can't see where I'm going wrong. Do I need to change some of my variables to constraints? Thanks in advance for your thoughts.
From: Alan Weiss on
On 7/26/2010 6:06 PM, RoopBK wrote:
> Continuing on with my quest in optimization, I am looking to find a particular solution using a multi-objective optimization function. My design variables would be BDLT, BALPHA, BALPHY, and BPHIP. Fx, Fy, Fz, Mx, My, Mz would be the objective. The function takes the following form:
>
> [Fx, Fy, Fz, Mx, My, Mz] = aFunc(BDLT, BALPHA, BALPY, BPHIP)
> %(where BDLT is a 1x4 Matrix)
>
> After reading up on the optimization functions in Matlab, it looks as though the function fgoalattain would be best for a nonlinear, multiobjective function. I set up my solver as such:
>
> XO = [0 0 0 0 0 0 0] % Set initial values to 0; steady state
> goal = [0 1 0 0 1 0]; % This is the value that I want to set for [Fx, Fy, Fz, Mx, My, Mz]
> weight = abs(goal); % Equal weight to all goal values
> options = optimset('Display', 'iter'); % Set display parameter
>
> [X, fval, attainfactor] = fgoalattain('aFunc', XO, goal, weight, [], [], [], [], [], [], [], options);
>
> I put seven []'s, which should be the seven outputs I want: [BDLT(4), BALPHA, BALPHY, BPHIP]. By my understanding, X should output a vector with the seven values I want, given the defined goal. I receive the following error:
>
> ??? Input Argument “BALPHA” is undefined.
>
> Error in ++> fgoalattain at 371
> user_f = feval(funfcn(3), x, varargin(:));
>
> I'm sure that I'm just not understanding my input and output vectors correctly, but I can't see where I'm going wrong. Do I need to change some of my variables to constraints? Thanks in advance for your thoughts.

You need to define your variables as elements of a single vector. For
example
function out = aFunc(x)
BLDT = x(1);
BALPHA = x(2);
BALPY = x(3);
BPHIP = x(4);
....

For instructions on writing objective functions, see
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brhkghv-3.html

Alan Weiss
MATLAB mathematical toolbox documentation