Thread Subject:
optimization problem: get a feasible point for running an optimization

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 1 Jun, 2012 09:58:08

Message: 1 of 44

Hi all,

I know fmincon needs to feasible starting point. But how could I get a feasible starting point if the problem has many constraints?

Thanks

Best regards

Subject: optimization problem: get a feasible point for running an optimization

From: Sargondjani

Date: 1 Jun, 2012 10:41:06

Message: 2 of 44

i dont think it needs a feasible point to start... i mean, during iterations it can also violate constraints, so i dont see why your initial guess should be feasible...

Subject: optimization problem: get a feasible point for running an optimization

From: Seth Deland

Date: 1 Jun, 2012 11:48:56

Message: 3 of 44

To add to what Sargondjani said, if the solver is having trouble finding any
feasible point, there is this section of the documentation which provides
some guidance:
http://www.mathworks.com/help/toolbox/optim/ug/br44iv5-1.html#br44i73


"Sargondjani " <sponsstimo@hotmail.com> wrote in message
news:jqa682$76k$1@newscl01ah.mathworks.com...
> i dont think it needs a feasible point to start... i mean, during
> iterations it can also violate constraints, so i dont see why your initial
> guess should be feasible...

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 4 Jun, 2012 09:28:09

Message: 4 of 44

"Seth Deland" <sdeland@mathworks.com> wrote in message <jqaa7l$m85$1@newscl01ah.mathworks.com>...
> To add to what Sargondjani said, if the solver is having trouble finding any
> feasible point, there is this section of the documentation which provides
> some guidance:
> http://www.mathworks.com/help/toolbox/optim/ug/br44iv5-1.html#br44i73
>
>
> "Sargondjani " <sponsstimo@hotmail.com> wrote in message
> news:jqa682$76k$1@newscl01ah.mathworks.com...
> > i dont think it needs a feasible point to start... i mean, during
> > iterations it can also violate constraints, so i dont see why your initial
> > guess should be feasible...

Thanks for yout reply,

I used many times fmincon with a not feasible starting point and I got an
unfeasible solution. I read on a matlab documentation, fmincon needs a feasible starting point, therefore I was wondering it was possible to find one througn the optimization toolbox.

Subject: optimization problem: get a feasible point for running an optimization

From: Torsten

Date: 4 Jun, 2012 09:40:01

Message: 5 of 44

>
> I used many times fmincon with a not feasible starting point and I got an
> unfeasible solution. I read on a matlab documentation, fmincon needs a feasible starting point, therefore I was wondering it was possible to find one througn the optimization toolbox.

Depends on the kind of constraints that you have.
E.g. if they are all linear, you could use LINPROG to find a feasible
starting point.

Best wishes
Torsten.

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 4 Jun, 2012 13:50:07

Message: 6 of 44

"pietro " <bracardi82@email.it> wrote in message <jqhv39$1fc$1@newscl01ah.mathworks.com>...
>
>
> I used many times fmincon with a not feasible starting point and I got an
> unfeasible solution.
==============

Yes, the solution can be unfeasible, but not by more than TolCon. And that's true regardless of whether your initial point is feasible.


>I read on a matlab documentation, fmincon needs a feasible starting point,
=============

Show us where.

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 5 Jun, 2012 10:27:07

Message: 7 of 44

Torsten <Torsten.Hennig@umsicht.fraunhofer.de> wrote in message <cf273176-8afa-4fe1-b517-8ac62ade02ea@k5g2000vbf.googlegroups.com>...
> >
> > I used many times fmincon with a not feasible starting point and I got an
> > unfeasible solution. I read on a matlab documentation, fmincon needs a feasible starting point, therefore I was wondering it was possible to find one througn the optimization toolbox.
>
> Depends on the kind of constraints that you have.
> E.g. if they are all linear, you could use LINPROG to find a feasible
> starting point.
>
> Best wishes
> Torsten.

Hi,

my constrains are not linear so I have to use fmincon.

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 5 Jun, 2012 10:46:07

Message: 8 of 44

"Matt J" wrote in message <jqieef$59u$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <jqhv39$1fc$1@newscl01ah.mathworks.com>...
> >
> >
> > I used many times fmincon with a not feasible starting point and I got an
> > unfeasible solution.
> ==============
>
> Yes, the solution can be unfeasible, but not by more than TolCon. And that's true regardless of whether your initial point is feasible.
>
>
> >I read on a matlab documentation, fmincon needs a feasible starting point,
> =============
>
> Show us where.

Hi,

unfortunately the solution is unfeasible much more than TolCon. I don't understand why.

Subject: optimization problem: get a feasible point for running an optimization

From: Torsten

Date: 5 Jun, 2012 11:18:00

Message: 9 of 44

>
> Hi,
>
> my constrains are not linear so I have to use fmincon.

Even if your constaints were linear, but your objective function were
not, you had to use a nonlinear optimizer like fmincon.
But anyway:
To see whether a feasible point exists at all for your problem, you
could apply FSOLVE to the constraints while ignoring the objective
function.

Best wishes
Torsten.

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 5 Jun, 2012 13:52:07

Message: 10 of 44

"pietro " <bracardi82@email.it> wrote in message <jqko1f$eng$1@newscl01ah.mathworks.com>...
>
>
> unfortunately the solution is unfeasible much more than TolCon. I don't understand why.
===============

Then fmincon failed to converge. You should look at the exitflag output argument to investigate why.

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 5 Jun, 2012 19:38:07

Message: 11 of 44

"Matt J" wrote in message <jql2u7$2e3$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <jqko1f$eng$1@newscl01ah.mathworks.com>...
> >
> >
> > unfortunately the solution is unfeasible much more than TolCon. I don't understand why.
> ===============
>
> Then fmincon failed to converge. You should look at the exitflag output argument to investigate why.

Thanks for your replies. The exitflag is -2. Here the fmincon plot results.

http://imageshack.us/f/593/fminconres.jpg/

I can't understand.

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 5 Jun, 2012 19:39:10

Message: 12 of 44

"Matt J" wrote in message <jql2u7$2e3$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <jqko1f$eng$1@newscl01ah.mathworks.com>...
> >
> >
> > unfortunately the solution is unfeasible much more than TolCon. I don't understand why.
> ===============
>
> Then fmincon failed to converge. You should look at the exitflag output argument to investigate why.

PS. the starting point is a feasible point

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 5 Jun, 2012 19:49:07

Message: 13 of 44

"pietro " <bracardi82@email.it> wrote in message <jqln8u$9dd$1@newscl01ah.mathworks.com>...
>
>
> PS. the starting point is a feasible point
==============

Doesn't look that way. Your graphs show very large constraint violations at Iteration 0.

You should probably start describing your problem mathematically and also showing the misbehaving code...

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 6 Jun, 2012 13:11:06

Message: 14 of 44

"Matt J" wrote in message <jqlnri$c46$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <jqln8u$9dd$1@newscl01ah.mathworks.com>...
> >
> >
> > PS. the starting point is a feasible point
> ==============
>
> Doesn't look that way. Your graphs show very large constraint violations at Iteration 0.
>
> You should probably start describing your problem mathematically and also showing the misbehaving code...

Thanks for your reply.
I am performing an optization of a mechanism composed of two four-linkage bars where some joint loads must be reduced. The problem variables are the bar lengths and the non linear constraints due to the available space for the mechanism. When the problem variables are changed by the solver, not always the mechanism can be built and thefore the forces can't be computed. Therefore I have added two linear constraints on the nonlinear constraint functions, this impose the length of one barlower than the sum of the other three. Due to this, I think my optimization problem has several discontinuities. Despite of the starting point is a feasible one, maybe around it's not a feasible point so for this reason on the plot I get a constraint violation at zero iterations, right?

Moreover I have set the objective function @(x)0 and the solver has found a feasible point. So I think the constrain function is fine, right?

thanks

best regars

Pietro

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 6 Jun, 2012 13:49:07

Message: 15 of 44

"pietro " <bracardi82@email.it> wrote in message <jqnkta$e94$1@newscl01ah.mathworks.com>...
>
>Due to this, I think my optimization problem has several discontinuities. Despite of the starting point is a feasible one, maybe around it's not a feasible point so for this reason on the plot I get a constraint violation at zero iterations, right?
>
> Moreover I have set the objective function @(x)0 and the solver has found a feasible point. So I think the constrain function is fine, right?
=============

Not if it contains discontinuities, as you've supposed. The algorithms of FMINCON assume the objective function and constraints to be not only continuous, but also twice continuously differentiable.

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 6 Jun, 2012 20:11:06

Message: 16 of 44

"Matt J" wrote in message <jqnn4j$o1q$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <jqnkta$e94$1@newscl01ah.mathworks.com>...
> >
> >Due to this, I think my optimization problem has several discontinuities. Despite of the starting point is a feasible one, maybe around it's not a feasible point so for this reason on the plot I get a constraint violation at zero iterations, right?
> >
> > Moreover I have set the objective function @(x)0 and the solver has found a feasible point. So I think the constrain function is fine, right?
> =============
>
> Not if it contains discontinuities, as you've supposed. The algorithms of FMINCON assume the objective function and constraints to be not only continuous, but also twice continuously differentiable.

I got it. On reality the function and the constraints are twice continuosly differentiable, but it's how the solver choises the variables at each iteration that makes the problem not smooth. I have a four-linkage bar and the lenghts must build a quadrilater, if not the force calculation is wrong. Not at each iteration I have a quadrilater this make the problem not smooth. Is it possible to help the solver in choosing the variables?

thanks

Best regards

Pietro

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 6 Jun, 2012 20:32:06

Message: 17 of 44

"pietro " <bracardi82@email.it> wrote in message <jqodgq$8kt$1@newscl01ah.mathworks.com>...
> "Matt J" wrote in message <jqnn4j$o1q$1@newscl01ah.mathworks.com>...
> > "pietro " <bracardi82@email.it> wrote in message <jqnkta$e94$1@newscl01ah.mathworks.com>...
> > >
> > >Due to this, I think my optimization problem has several discontinuities. Despite of the starting point is a feasible one, maybe around it's not a feasible point so for this reason on the plot I get a constraint violation at zero iterations, right?
> > >
> > > Moreover I have set the objective function @(x)0 and the solver has found a feasible point. So I think the constrain function is fine, right?
> > =============
> >
> > Not if it contains discontinuities, as you've supposed. The algorithms of FMINCON assume the objective function and constraints to be not only continuous, but also twice continuously differentiable.
>
> I got it. On reality the function and the constraints are twice continuosly differentiable, but it's how the solver choises the variables at each iteration that makes the problem not smooth. I have a four-linkage bar and the lenghts must build a quadrilater, if not the force calculation is wrong. Not at each iteration I have a quadrilater this make the problem not smooth. Is it possible to help the solver in choosing the variables?
==============

You need to add more constraints to express this requirement. Maybe constrain the angles between neighboring bars to be >=0. Maybe also constrain the sum of these angles to be 360 degrees.

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 9 Jun, 2012 09:11:07

Message: 18 of 44

"Matt J" wrote in message <jqoeo6$eev$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <jqodgq$8kt$1@newscl01ah.mathworks.com>...
> > "Matt J" wrote in message <jqnn4j$o1q$1@newscl01ah.mathworks.com>...
> > > "pietro " <bracardi82@email.it> wrote in message <jqnkta$e94$1@newscl01ah.mathworks.com>...
> > > >
> > > >Due to this, I think my optimization problem has several discontinuities. Despite of the starting point is a feasible one, maybe around it's not a feasible point so for this reason on the plot I get a constraint violation at zero iterations, right?
> > > >
> > > > Moreover I have set the objective function @(x)0 and the solver has found a feasible point. So I think the constrain function is fine, right?
> > > =============
> > >
> > > Not if it contains discontinuities, as you've supposed. The algorithms of FMINCON assume the objective function and constraints to be not only continuous, but also twice continuously differentiable.
> >
> > I got it. On reality the function and the constraints are twice continuosly differentiable, but it's how the solver choises the variables at each iteration that makes the problem not smooth. I have a four-linkage bar and the lenghts must build a quadrilater, if not the force calculation is wrong. Not at each iteration I have a quadrilater this make the problem not smooth. Is it possible to help the solver in choosing the variables?
> ==============
>
> You need to add more constraints to express this requirement. Maybe constrain the angles between neighboring bars to be >=0. Maybe also constrain the sum of these angles to be 360 degrees.

thanks of your reply. you were on right a constraint is missing.

I try to figure out how i set up it.

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 9 Jun, 2012 13:32:09

Message: 19 of 44

"pietro " <bracardi82@email.it> wrote in message <jqv3vb$jb4$1@newscl01ah.mathworks.com>...
> "Matt J" wrote in message <jqoeo6$eev$1@newscl01ah.mathworks.com>...
> > "pietro " <bracardi82@email.it> wrote in message <jqodgq$8kt$1@newscl01ah.mathworks.com>...
> > > "Matt J" wrote in message <jqnn4j$o1q$1@newscl01ah.mathworks.com>...
> > > > "pietro " <bracardi82@email.it> wrote in message <jqnkta$e94$1@newscl01ah.mathworks.com>...
> > > > >
> > > > >Due to this, I think my optimization problem has several discontinuities. Despite of the starting point is a feasible one, maybe around it's not a feasible point so for this reason on the plot I get a constraint violation at zero iterations, right?
> > > > >
> > > > > Moreover I have set the objective function @(x)0 and the solver has found a feasible point. So I think the constrain function is fine, right?
> > > > =============
> > > >
> > > > Not if it contains discontinuities, as you've supposed. The algorithms of FMINCON assume the objective function and constraints to be not only continuous, but also twice continuously differentiable.
> > >
> > > I got it. On reality the function and the constraints are twice continuosly differentiable, but it's how the solver choises the variables at each iteration that makes the problem not smooth. I have a four-linkage bar and the lenghts must build a quadrilater, if not the force calculation is wrong. Not at each iteration I have a quadrilater this make the problem not smooth. Is it possible to help the solver in choosing the variables?
> > ==============
> >
> > You need to add more constraints to express this requirement. Maybe constrain the angles between neighboring bars to be >=0. Maybe also constrain the sum of these angles to be 360 degrees.
>
> thanks of your reply. you were on right a constraint is missing.
>
> I try to figure out how i set up it.

This is the ojbective funtion @(x)0 e now the nonlinear constraint function is fine, but I always get constraints violation. I started with an unfeasible starting point for understing if the solver can get a feasible one, but it can't. I used the interior point and SQP algorithms. Any other suggestion? I'll try also with the genetic algorithm...

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 9 Jun, 2012 14:02:08

Message: 20 of 44

"pietro " <bracardi82@email.it> wrote in message <jqvj8p$gi2$1@newscl01ah.mathworks.com>...
>
> This is the ojbective funtion @(x)0 e now the nonlinear constraint function is fine, but I always get constraints violation. I started with an unfeasible starting point for understing if the solver can get a feasible one, but it can't. I used the interior point and SQP algorithms. Any other suggestion? I'll try also with the genetic algorithm...
==============

It would be a good idea to give a mathematical description of the problem so that the community can have a better understanding of it. By this, I mean we should see equations.

You should also show what you've coded. It's always a bad idea to start with the assumption that what you've coded is correct...

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 10 Jun, 2012 09:40:05

Message: 21 of 44

"Matt J" wrote in message <jqvl10$ms1$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <jqvj8p$gi2$1@newscl01ah.mathworks.com>...
> >
> > This is the ojbective funtion @(x)0 e now the nonlinear constraint function is fine, but I always get constraints violation. I started with an unfeasible starting point for understing if the solver can get a feasible one, but it can't. I used the interior point and SQP algorithms. Any other suggestion? I'll try also with the genetic algorithm...
> ==============
>
> It would be a good idea to give a mathematical description of the problem so that the community can have a better understanding of it. By this, I mean we should see equations.
>
> You should also show what you've coded. It's always a bad idea to start with the assumption that what you've coded is correct...

Hi MattJ,

Thanks for your reply. Here the optimization setup. I need throught constraints to get a feasible mechanism. The mechanism is something like this:
http://img703.imageshack.us/img703/1644/quadri.jpg

Where on my code they are named
r1 is l_f1
r2 is l_c
r3 is l_lr
R4 is l_lalr
R11 is l_f2
R5 is l_ua
R6 is m_h
R44 is l_la

l_f3, l_hc and l_chc aren't shown but it's a hydraulic cylinder placed that connect the frame to the l_c element. The nonlinear constraint is exitflag of fsolve for solving the equation loop of the mechanism.

Here the code.

m_h=685;

%vars
%1 P_fla_x
%2 P_fla_y
%3 Pfla_z
%4 l_c
%5 l_chc
% 6 l_f1
% 7 l_f2
% 8 l_f3
% 9 l_hc_min
% 10 l_hc_max
% 11 l_la
% 12 l_lalr
% 13 l_lr_min
% 14 l_lr_max
% 15 l_ua_min
% 16 l_ua_max
% 17 phi_f1
% 18 phi_f2
% 19 phi_f3
% 20 alfa_la

%The mechanism is composed of two quadrilateral and one triangle.
%1° quadrilateral: l_c, l_f1, l_lalr, l_lr. l_lr can be extended in from l_lr_min to l_lr_max
%2° quadrilateral: l_ua, l_f2, l_la,m_h. l_lua can be extended in from l_ua_min to l_ua_max
% triangle l_chc, l_hc, l_f3. l_hc can be extended from l_hc_min to l_hc_max
% A quadrilater(triangles) can be constructed only if the sum of three (two) edges is upper than the other %%one. Therefore I'have created the lin inquality matrices

% 1 l_f1-l_c-l_lalr-l_lr_min<0
A= [zeros(1,3) 1 0 -1 zeros(1,5) -1 -1 0 zeros(1,6);
    % 2 l_f1-l_c-l_lalr-l_lr_max<0
    zeros(1,3) 1 0 -1 zeros(1,5) -1 0 -1 zeros(1,6);
    % 3 -l_f1+l_c-l_lalr-l_lr_min<0
    zeros(1,3) -1 0 1 zeros(1,5) -1 -1 0 zeros(1,6);
    % 4 -l_f1+l_c-l_lalr-l_lr_max<0
    zeros(1,3) -1 0 1 zeros(1,5) -1 0 -1 zeros(1,6);
    % 5 -l_f1-l_c+l_lalr-l_lr_min<0
    zeros(1,3) -1 0 -1 zeros(1,5) 1 -1 0 zeros(1,6);
    % 6 -l_f1-l_c+l_lalr-l_lr_max<0
zeros(1,3) -1 0 -1 zeros(1,5) 1 0 -1 zeros(1,6);
    % 7 -l_f1-l_c-l_lalr+l_lr_min<0
    zeros(1,3) -1 0 -1 zeros(1,5) -1 1 0 zeros(1,6);
    % 8 -l_f1-l_c-l_lalr+l_lr_max<0
zeros(1,3) -1 0 -1 zeros(1,5) -1 0 1 zeros(1,6);
    % 9 -m_h>-l_f2-l_ua_min-l_la
    zeros(1,6) -1 zeros(1,3) -1 zeros(1,3) -1 0 zeros(1,4);
    % 10 -m_h>-l_f2-l_ua_max-l_la
    zeros(1,6) -1 zeros(1,3) -1 zeros(1,3) 0 -1 zeros(1,4);
    % 11 m_h>l_f2-l_ua_min-l_la
    zeros(1,6) 1 zeros(1,3) -1 zeros(1,3) -1 0 zeros(1,4);
    % 12 m_h>l_f2-l_ua_max-l_la
    zeros(1,6) 1 zeros(1,3) -1 zeros(1,3) 0 -1 zeros(1,4);
    % 13 m_h>-l_f2+l_ua_min-l_la
    zeros(1,6) -1 zeros(1,3) 1 zeros(1,3) -1 0 zeros(1,4);
    % 14 m_h>-l_f2+l_ua_max-l_la
    zeros(1,6) -1 zeros(1,3) 1 zeros(1,3) 0 -1 zeros(1,4);
    % 15 m_h>-l_f2+l_ua_min-l_la
    zeros(1,6) -1 zeros(1,3) -1 zeros(1,3) 1 0 zeros(1,4);
    % 16 m_h>-l_f2+l_ua_max-l_la
    zeros(1,6) -1 zeros(1,3) -1 zeros(1,3) 0 1 zeros(1,4);
    % 17 l_chc-l_f3-l_hc_min<0
    zeros(1,4) 1 zeros(1,2) -1 -1 0 zeros(1,10);
    % 18 l_chc-l_f3-l_hc_max<0
    zeros(1,4) 1 zeros(1,2) -1 0 -1 zeros(1,10);
    % 19 -l_chc+l_f3-l_hc_min<0
    zeros(1,4) -1 zeros(1,2) 1 -1 0 zeros(1,10);
    % 20 -l_chc+l_f3-l_hc_min<0
    zeros(1,4) -1 zeros(1,2) 1 0 -1 zeros(1,10);
    % 21 -l_chc-l_f3+l_hc_min<0
    zeros(1,4) -1 zeros(1,2) -1 1 0 zeros(1,10);
    % 22 -l_chc-l_f3+l_hc_max<0
    zeros(1,4) -1 zeros(1,2) -1 0 1 zeros(1,10);
    % 23 l_chc-l_c<0
    zeros(1,3) -1 1 zeros(1,15);
    % 24 l_lalr-l_la<0
    zeros(1,10) -1 1 zeros(1,8);
    % 25 l_lr_min-l_lr_max<0
    zeros(1,3) 0 0 0 zeros(1,5) 0 1 -1 zeros(1,6);
% 26 l_hc_min-l_hc_max<0
    zeros(1,8) 1 -1 zeros(1,10);
    % 27 l_ua_min-l_ua_max<0
    zeros(1,14) 1 -1 zeros(1,4);
    ];

%starting point
x0=rand(size(A(1,:)))'*200;
x0(17:20)=0;


B=ones(size(A(:,1)))*-200;
B(9:9+7)=[-m_h(classe); -m_h(classe) ;m_h(classe)*ones(6,1)]-200;
e
B(end-4:end)=-10;

    
%the lower bound of element position and of angles can be negative, but lengths must be >0
lb=[-1000*ones(1,3) 100*ones(1,13) -pi*ones(1,4)];
ub=[ones(1,16)*2000 pi*ones(1,4)];




% Start with the default options
options = optimset;
TolFun_Data=1e-5;
TolCon_Data=1e-5;
MaxFunEvals=1e5;
options = optimset(options,'Display', 'on');
options = optimset(options,'Display','iter');
options = optimset(options,'TolFun', TolFun_Data);
options = optimset(options,'MaxFunEvals',MaxFunEvals);
options = optimset(options,'Algorithm','interior-point');
% options = optimset(options,'PlotFcns', { @optimplotx @optimplotfunccount @optimplotfval @optimplotconstrviolation @optimplotstepsize @optimplotfirstorderopt });
% options = optimset(options,'Algorithm', 'sqp');
%options = optimset(options,'FinDiffType', 'forward');
%options = optimset(options,'GradConstr', 'on');
%options = optimset(options,'GradObj', 'on');
options = optimset(options,'TolCon', TolCon_Data);
options = optimset(options,'UseParallel', 'always');




[x, fval, exitflag_fmincon, output_fmincon] = fmincon(@(x)0, x0,A,B,[],[],lb,ub,@(x)confun_tph_iso_canc(x,d_hc,l_i,m_h(classe),p_hc,r_rw,P_PTO_x,w,W,W_f,W_frame,W_ral,constr,npti), options)

function [c ceq]=confun_tph_iso_canc(x,d_hc,l_i,m_h,p_hc,r_rw,P_PTO_x,w,W,W_f,W_frame,W_ral,constr,npti)



options = optimset('TolX',1e-10,'TolFun',1e-10,'Algorithm','levenberg-marquardt','MaxIter',10^8,'MaxFunEvals',10^8);
options_lsq = optimset('TolX',1e-10,'TolFun',1e-10,'Algorithm','trust-region-reflective','MaxIter',10^8,'MaxFunEvals',10^8);



P_fla_x=x(1);
P_fla_y=x(2);
P_fla_z=x(3);

l_c=x(4);

l_chc=x(5);

l_f1=x(6);

l_f2=x(7);

l_f3=x(8);

l_hc_min=x(9);

l_hc_max=x(10);

l_la=x(11);

l_lalr=x(12);

l_lr_min=x(13);

l_lr_max=x(14);

l_ua_min=x(15);

l_ua_max=x(16);

phi_f1=x(17);

phi_f2=x(18);

phi_f3=x(19);

alfa_la=x(20);


P_fc_x=P_fla_x+l_f1*cos(phi_f1);
P_fc_y=P_fla_y+l_f1*sin(phi_f1);

P_fua_x=P_fla_x+l_f2*cos(phi_f2);
P_fua_y=P_fla_y+l_f2*sin(phi_f2);

P_fhc_x=P_fla_x+l_f1*cos(phi_f1)+l_f3*cos(phi_f3);
P_fhc_y=P_fla_y+l_f1*sin(phi_f1)+l_f3*sin(phi_f3);


%position analysis of the mechanism
l_lr=l_lr_min;
l_ua=l_ua_min;
l_hc=l_hc_min;
x0=[0,72.64,90,0, 90, 0].*pi/180;
clear x
[x,fval,exitflag output] = fsolve(@(x)...
    fun_pos_analysis(P_fc_x,P_fc_y,P_fhc_x,P_fhc_y,l_c,l_chc,l_f1,l_f2,l_hc,l_la,l_lalr,l_lr,l_ua,m_h,x(1),phi_f1,...
    phi_f2,x(2),x(3),x(4),x(5),x(6)),x0,options);

%the mechanism must be solved
c(1)=-exitflag;


Function F=fun_pos_analysis (P_fc_x,P_fc_y,P_fhc_x,P_fhc_y,l_c,l_chc,l_f1,l_f2,l_hc,l_la,l_lalr,l_lr,l_ua,m_h,phi_c,phi_f1, phi_f2,phi_hc,phi_i,phi_la,phi_lr,phi_ua)



    F=[
%first loop
        P_fhc_x+l_hc*cos(phi_hc)-P_fc_x-l_chc*cos(phi_c);
        P_fhc_y+l_hc*sin(phi_hc)-P_fc_y-l_chc*sin(phi_c);
%second loop
        l_f1*cos(phi_f1)+l_c*cos(phi_c)-l_lr*cos(phi_lr)-l_lalr*cos(phi_la);
        l_f1*sin(phi_f1)+l_c*sin(phi_c)-l_lr*sin(phi_lr)-l_lalr*sin(phi_la);
%third loop
        l_ua*cos(phi_ua)+l_f2*cos(phi_f2)-m_h*cos(phi_i)-l_la*cos(phi_la)
        l_ua*sin(phi_ua)+l_f2*sin(phi_f2)-m_h*sin(phi_i)-l_la*sin(phi_la)

       ];

end


So in this way I get sometimes a linear constraint violation and sometimes not....
I want to make my code more robust.

Thanks

Best regards

Pietro

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 10 Jun, 2012 13:40:07

Message: 22 of 44

"pietro " <bracardi82@email.it> wrote in message <jr1q1l$btf$1@newscl01ah.mathworks.com>...
>
> l_f3, l_hc and l_chc aren't shown but it's a hydraulic cylinder placed that connect the frame to the l_c element. The nonlinear constraint is exitflag of fsolve for solving the equation loop of the mechanism.
===========

That's not really legal. EXITFLAG is discrete-valued, so a constraint like that can't be continuous or differentiable. Regardless, it's not clear why you would allow EXITFLAG=0 to pass your constraints, because that indicates that fsolve has failed to converge.

There are a few other confusing things as well. You return no ceq argument from your constraints. Even if you have no nonlinear equality constraints, I'm pretty sure you're required to return ceq=[]. Don't know why FMINCON isn't complaining about that. Similarly, you have GradObj and GradConstr turned on, but you return no gradients from your objective function and constraints.


> So in this way I get sometimes a linear constraint violation and sometimes not....
> I want to make my code more robust.
=============

Did you really mean "linear constraint violation" or was it the nonlinear ones? The Nonlinear ones look harder to satisfy (and of course you've formulated them in a problematic way, as I've mentioned).

Regardless, you can check whether a solution at least exists to your linear constraints (and lb,ub bounds) using this tool

http://www.mathworks.com/matlabcentral/fileexchange/30892-representing-polyhedral-convex-hulls-by-vertices-or-inequalities

If the linear constrained region has no polyhedron vertices, then a solution doesn't exist.

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 10 Jun, 2012 14:24:07

Message: 23 of 44

"Matt J" wrote in message <jr283n$4mn$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <jr1q1l$btf$1@newscl01ah.mathworks.com>...
> >
> > l_f3, l_hc and l_chc aren't shown but it's a hydraulic cylinder placed that connect the frame to the l_c element. The nonlinear constraint is exitflag of fsolve for solving the equation loop of the mechanism.
> ===========
>
> That's not really legal. EXITFLAG is discrete-valued, so a constraint like that can't be continuous or differentiable. Regardless, it's not clear why you would allow EXITFLAG=0 to pass your constraints, because that indicates that fsolve has failed to converge.
>
> There are a few other confusing things as well. You return no ceq argument from your constraints. Even if you have no nonlinear equality constraints, I'm pretty sure you're required to return ceq=[]. Don't know why FMINCON isn't complaining about that. Similarly, you have GradObj and GradConstr turned on, but you return no gradients from your objective function and constraints.
>
>
> > So in this way I get sometimes a linear constraint violation and sometimes not....
> > I want to make my code more robust.
> =============
>
> Did you really mean "linear constraint violation" or was it the nonlinear ones? The Nonlinear ones look harder to satisfy (and of course you've formulated them in a problematic way, as I've mentioned).
>
> Regardless, you can check whether a solution at least exists to your linear constraints (and lb,ub bounds) using this tool
>
> http://www.mathworks.com/matlabcentral/fileexchange/30892-representing-polyhedral-convex-hulls-by-vertices-or-inequalities
>
> If the linear constrained region has no polyhedron vertices, then a solution doesn't exist.

thanks a lot for your reply.

it's the nonlinear constraint violation. How would you suggest me to formulate it the non linear constraint in a bertter way? The linear constraints impose the lenghts can form a triangle and two quadrilateral, but to compose the mechanism it's necessary the vector l_la and l_lalr form the same angle with the horizontal. The same for the vector l_c and l_chc. The only way I got for imposing this constrain is the way I have done.
Through the genetic algorithm it's much easier to get a feasible solution, but the computation time is much slower.

I tried your tool. It's really useful. I get this error:

[V,nr,nre]=lcon2vert(A,B);

??? Error using ==> lcon2vert>con2vert at 304
Non-bounding constraints detected. (Consider box constraints on
variables.)

Error in ==> lcon2vert at 234
           [Zt,nr]=con2vert(AAA,bbb,TOL,checkbounds);

What does it mean?

thanks again!

Best regards

Pietro

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 10 Jun, 2012 15:11:07

Message: 24 of 44

"pietro " <bracardi82@email.it> wrote in message <jr2am7$e4h$1@newscl01ah.mathworks.com>...
>
> it's the nonlinear constraint violation. How would you suggest me to formulate it the non linear constraint in a bertter way?
=========

Why not just use equality constraints with ceq=F, where F is the output of fun_pos_analysis?





> ??? Error using ==> lcon2vert>con2vert at 304
> Non-bounding constraints detected. (Consider box constraints on
> variables.)
>
> Error in ==> lcon2vert at 234
> [Zt,nr]=con2vert(AAA,bbb,TOL,checkbounds);
>
> What does it mean?
============


You probably forgot to include your lb and ub in the constraints. Your total constraints, when expressed in inequality form would be

[A, eye(20),-eye(20)]*x<=[B,ub,-lb].';

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 10 Jun, 2012 15:19:07

Message: 25 of 44

"Matt J" wrote in message <jr2deb$oii$1@newscl01ah.mathworks.com>...
>
> You probably forgot to include your lb and ub in the constraints. Your total constraints, when expressed in inequality form would be
>
> [A, eye(20),-eye(20)]*x<=[B,ub,-lb].';

That should have been

[A; eye(20); -eye(20)]*x<=[B,ub,-lb].'; %SEMICOLONS on lhs

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 13 Jun, 2012 08:17:07

Message: 26 of 44

"Matt J" wrote in message <jr2dtb$pvr$1@newscl01ah.mathworks.com>...
> "Matt J" wrote in message <jr2deb$oii$1@newscl01ah.mathworks.com>...
> >
> > You probably forgot to include your lb and ub in the constraints. Your total constraints, when expressed in inequality form would be
> >
> > [A, eye(20),-eye(20)]*x<=[B,ub,-lb].';
>
> That should have been
>
> [A; eye(20); -eye(20)]*x<=[B,ub,-lb].'; %SEMICOLONS on lhs

Hi MattJ,

really thanks for your help. There was something bad in the variable I choosed. Through your suggestions I found it. Really thanks...Now the mechanism is always solved at each iteration.

Best regards
Pietro

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 13 Jun, 2012 17:35:07

Message: 27 of 44

"pietro " <bracardi82@email.it> wrote in message <jr9ia3$oh0$1@newscl01ah.mathworks.com>...
>
>
> really thanks for your help. There was something bad in the variable I choosed. Through your suggestions I found it. Really thanks...Now the mechanism is always solved at each iteration.
==========

Glad to hear it, but I also hope you're also using exitflag as your constraint function anymore. Yuck...

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 13 Jun, 2012 17:49:07

Message: 28 of 44

"Matt J" wrote in message <jraj0b$g27$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <jr9ia3$oh0$1@newscl01ah.mathworks.com>...
>
> Glad to hear it, but I also hope you're also using exitflag as your constraint function anymore. Yuck...
===========

That should say, I hope you're NOT using exitflag anymore...

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 19 Jun, 2012 20:18:07

Message: 29 of 44

"Matt J" wrote in message <jrajqj$jj7$1@newscl01ah.mathworks.com>...
> "Matt J" wrote in message <jraj0b$g27$1@newscl01ah.mathworks.com>...
> > "pietro " <bracardi82@email.it> wrote in message <jr9ia3$oh0$1@newscl01ah.mathworks.com>...
> >
> > Glad to hear it, but I also hope you're also using exitflag as your constraint function anymore. Yuck...
> ===========
>
> That should say, I hope you're NOT using exitflag anymore...

Hi Matt,

despite I have changed deeply my optimization problem, it's still not work as good as I think.
Now every iteration there is a feasbile mechanism, so the constraint are only for checking the dimension of the mechanism as stated in the standard.
The starting point is feasible point. If I set up as objective problem with this unction @(x)0, linear constraints and non linear one.
The problem is really slow to converge to a feasible solution with a suitable tollerance. after 1039 Fcounts the algorithms runs much slower than the first iterations and after 3hours with any change I halted the algorithm.
So I tried again to check the linear bounds with your tool, but I get this error
>> size(A)
ans =
    10 16
>> size(B')
ans =
     1 10
>> size(B)
ans =
    10 1
>> size(ub)
ans =
     1 16
>> size(lb)
ans =
     1 16
An=[A, eye(10) ,-eye(10)];
Bn=[B' ub -lb];
>> [V,nr,nre]=lcon2vert(An,Bn);
??? Error using ==> lcon2vert>con2vert at 304
Non-bounding constraints detected. (Consider box constraints on
variables.)

Moreover why first oder feasibility change with a zero objective function? It should be always null, right?

Thanks

Pietro

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 20 Jun, 2012 17:31:07

Message: 30 of 44

"pietro " <bracardi82@email.it> wrote in message <jrqmpv$nt4$1@newscl01ah.mathworks.com>...
>
> despite I have changed deeply my optimization problem, it's still not work as good as I think.
================

Can you describe the changes (and show the new code)?
 
> Now every iteration there is a feasbile mechanism, so the constraint are only for checking the dimension of the mechanism as stated in the standard.
===========

What is "the standard"?

 
> The starting point is feasible point. If I set up as objective problem with this unction @(x)0, linear constraints and non linear one.
===========

Have you tried initializing with a non-feasible point? As we've been saying, it should be possible, and was not connected to your previous problems.


 
> The problem is really slow to converge to a feasible solution with a suitable tollerance. after 1039 Fcounts the algorithms runs much slower than the first iterations and after 3hours with any change I halted the algorithm.
==============

If there is no change, and FMINCON isn't stopping by itself, it means you have set the tolerances TolCon and TolX to zero. These are not appropriate tolerances...




> An=[A, eye(10) ,-eye(10)];
> Bn=[B' ub -lb];
==========

This should be as follows. Pay careful attention to all of the semicolons and transposes.

An=[A; eye(16) ;-eye(16)];
Bn=[B' ub -lb].';




> Moreover why first oder feasibility change with a zero objective function? It should be always null, right?
==============

Clarify what you mean by "first oder feasibility change" and why you think should be "null"?

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 20 Jun, 2012 20:12:06

Message: 31 of 44

"Matt J" wrote in message <jrt1cr$9bi$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <jrqmpv$nt4$1@newscl01ah.mathworks.com>...
> >
> > despite I have changed deeply my optimization problem, it's still not work as good as I think.
> ================
>
> Can you describe the changes (and show the new code)?
>
> > Now every iteration there is a feasbile mechanism, so the constraint are only for checking the dimension of the mechanism as stated in the standard.
> ===========
>
> What is "the standard"?
>
>
> > The starting point is feasible point. If I set up as objective problem with this unction @(x)0, linear constraints and non linear one.
> ===========
>
> Have you tried initializing with a non-feasible point? As we've been saying, it should be possible, and was not connected to your previous problems.
>
>
>
> > The problem is really slow to converge to a feasible solution with a suitable tollerance. after 1039 Fcounts the algorithms runs much slower than the first iterations and after 3hours with any change I halted the algorithm.
> ==============
>
> If there is no change, and FMINCON isn't stopping by itself, it means you have set the tolerances TolCon and TolX to zero. These are not appropriate tolerances...
>
>
>
>
> > An=[A, eye(10) ,-eye(10)];
> > Bn=[B' ub -lb];
> ==========
>
> This should be as follows. Pay careful attention to all of the semicolons and transposes.
>
> An=[A; eye(16) ;-eye(16)];
> Bn=[B' ub -lb].';
>
>
>
>
> > Moreover why first oder feasibility change with a zero objective function? It should be always null, right?
> ==============
>
> Clarify what you mean by "first oder feasibility change" and why you think should be "null"?

Hi Matt,

I'll try your suggestion. As it stated here the first order optimability is connected to the gradient, since the function is constant the gradient should be null, isn't it?
http://www.mathworks.it/help/toolbox/optim/ug/brhkghv-45.html

thanks

Pietro

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 20 Jun, 2012 20:27:07

Message: 32 of 44

"pietro " <bracardi82@email.it> wrote in message <jrtaqm$mhb$1@newscl01ah.mathworks.com>...
>
> I'll try your suggestion. As it stated here the first order optimability is connected to the gradient, since the function is constant the gradient should be null, isn't it?
> http://www.mathworks.it/help/toolbox/optim/ug/brhkghv-45.html
==================

For constrained optimization, it's the gradient of the Lagrangian L(x,lambda) that is used to measure first order optimality. See equations (3-5) through (3-8) at the link you mention.

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 22 Jun, 2012 17:07:06

Message: 33 of 44

"Matt J" wrote in message <jrtbmr$qb4$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <jrtaqm$mhb$1@newscl01ah.mathworks.com>...
> >
> > I'll try your suggestion. As it stated here the first order optimability is connected to the gradient, since the function is constant the gradient should be null, isn't it?
> > http://www.mathworks.it/help/toolbox/optim/ug/brhkghv-45.html
> ==================
>
> For constrained optimization, it's the gradient of the Lagrangian L(x,lambda) that is used to measure first order optimality. See equations (3-5) through (3-8) at the link you mention.

Thanks Matt I got it. Anyway I tried as you suggested, but I can't because I have 10 linear constraints and 16 variables with their relative bounds...

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 22 Jun, 2012 17:25:07

Message: 34 of 44

"pietro " <bracardi82@email.it> wrote in message <js28np$dso$1@newscl01ah.mathworks.com>...
>
> Thanks Matt I got it. Anyway I tried as you suggested, but I can't because I have 10 linear constraints and 16 variables with their relative bounds...
=============

Sorry, the discussion has grown many forks and I'm not sure which suggestion we're talking about. What did I suggest and what are you now doing instead?

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 23 Jun, 2012 09:58:07

Message: 35 of 44

"Matt J" wrote in message <js29pj$ivk$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <js28np$dso$1@newscl01ah.mathworks.com>...
> >
> > Thanks Matt I got it. Anyway I tried as you suggested, but I can't because I have 10 linear constraints and 16 variables with their relative bounds...
> =============
>
> Sorry, the discussion has grown many forks and I'm not sure which suggestion we're talking about. What did I suggest and what are you now doing instead?

thanks for your reply, I meant for your code...
here a part of my variable description to make you to understand. I have 16 variables and 10 linear constraints
>> size(A)
ans =
    10 16
>> size(B')
ans =
     1 10
>> size(B)
ans =
    10 1
>> size(ub)
ans =
     1 16
>> size(lb)
ans =
     1 16
An=[A, eye(10) ,-eye(10)];
Bn=[B' ub -lb];
>> [V,nr,nre]=lcon2vert(An,Bn);
??? Error using ==> lcon2vert>con2vert at 304
Non-bounding constraints detected. (Consider box constraints on
variables.)

You have suggested me

to use this code:
An=[A; eye(16) ;-eye(16)];
Bn=[B' ub -lb].';

but the matrix concatenation can't work in this way.

thanks

Pietro

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 23 Jun, 2012 19:35:09

Message: 36 of 44

"pietro " <bracardi82@email.it> wrote in message <js43vf$biq$1@newscl01ah.mathworks.com>...
>
> You have suggested me
>
> to use this code:
> An=[A; eye(16) ;-eye(16)];
> Bn=[B' ub -lb].';
>
> but the matrix concatenation can't work in this way.
==============

Works fine for me, assuming the sizes you showed me are the ones you're actually using. See my example below:


>> A=rand(10,16); B=rand(10,1); ub=rand(1,16); lb=rand(1,16);

>> An=[A; eye(16) ;-eye(16)];
Bn=[B' ub -lb].';

>> whos An Bn
  Name Size Bytes Class Attributes

  An 42x16 5376 double
  Bn 42x1 336 double

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 25 Jun, 2012 08:22:07

Message: 37 of 44

"Matt J" wrote in message <js55pd$kha$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <js43vf$biq$1@newscl01ah.mathworks.com>...
> >
> > You have suggested me
> >
> > to use this code:
> > An=[A; eye(16) ;-eye(16)];
> > Bn=[B' ub -lb].';
> >
> > but the matrix concatenation can't work in this way.
> ==============
>
> Works fine for me, assuming the sizes you showed me are the ones you're actually using. See my example below:
>
>
> >> A=rand(10,16); B=rand(10,1); ub=rand(1,16); lb=rand(1,16);
>
> >> An=[A; eye(16) ;-eye(16)];
> Bn=[B' ub -lb].';
>
> >> whos An Bn
> Name Size Bytes Class Attributes
>
> An 42x16 5376 double
> Bn 42x1 336 double

Hi MattJ,

thanks for your reply, now I got the out-of memory message, but I have 4 gigas...:(

I will find a solution. Thanks!

 [V,nr,nre]=lcon2vert(An,Bn);
??? Error using ==> qhullmx
Out of memory. Type HELP MEMORY for your options.

Error in ==> convhulln at 65
[k,vv] = qhullmx(x', opt);

Error in ==> vert2lcon>vert2con at 179
k = convhulln(V);

Error in ==> vert2lcon at 112
          [A,b]=vert2con(Rsub,tol);

Error in ==> lcon2vert>con2vert at 301
    [aa,bb,aaeq,bbeq]=vert2lcon(A,TOL);

Error in ==> lcon2vert at 234
           [Zt,nr]=con2vert(AAA,bbb,TOL,checkbounds);

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 25 Jun, 2012 13:52:05

Message: 38 of 44

"pietro " <bracardi82@email.it> wrote in message <js973f$4bn$1@newscl01ah.mathworks.com>...
>
>
> thanks for your reply, now I got the out-of memory message, but I have 4 gigas...:(
>
> I will find a solution. Thanks!


Hi pietro. If you show me your A,B,ub,lb data I might be able to play with it and see why it's doing this. In any case, I just realized that lcon2vert can't handle empty polyhedron's right now. If your region were empty, it would just continue looking in an endless loop. I'll have to think more about how to handle that case.

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 25 Jun, 2012 14:28:07

Message: 39 of 44

"Matt J" wrote in message <js9qe5$nqq$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <js973f$4bn$1@newscl01ah.mathworks.com>...
> >
> >
> > thanks for your reply, now I got the out-of memory message, but I have 4 gigas...:(
> >
> > I will find a solution. Thanks!
>
>
> Hi pietro. If you show me your A,B,ub,lb data I might be able to play with it and see why it's doing this. In any case, I just realized that lcon2vert can't handle empty polyhedron's right now. If your region were empty, it would just continue looking in an endless loop. I'll have to think more about how to handle that case.

Hi Matt,

thanks for your reply,

these are my matrices:

A =[

     0 0 0 0 0 0 0 0 -1 1 0 0 0 0 0 0;
     0 0 0 0 0 0 0 0 0 0 -1 1 0 0 0 0;
     0 0 0 0 0 0 0 0 0 0 0 0 -1 1 0 0;
     0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1;
     0 0 0 0 -1 0 0 0 0 0 -1 0 0 0 0 0;
     0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0;
     0 -1 0 0 0 1 0 0 0 0 0 0 0 0 0 0;
     0 0 0 0 0 1 0 -1 0 0 0 0 0 0 0 0;
     0 0 1 0 -1 0 0 0 0 0 0 -1 0 0 0 0;
     0 0 0 0 0 0 0 0 1 0 0 -1 0 0 0 0;
];


B =[-100;-200;-0.3927;-0.31416;-1145;1245;-40;-40;-200;-70];

lb =[-300;-300;-300;-300;-300;-300;-300;-300;100;100;100;100;-0.5236;-1.0472;0.13963;0.13963];


ub =[500;500;500;500;500;500;500;500;1500;1500;1500;1000;1.309;1.309;0.7854;0.7854];
Thanks

Pietro

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 25 Jun, 2012 15:07:09

Message: 40 of 44

"pietro " <bracardi82@email.it> wrote in message <js9shn$4li$1@newscl01ah.mathworks.com>...
>
> these are my matrices:
>

I get an out-of-memory error, too, though a different one than yours. I think the problem dimension is just too big...

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 25 Jun, 2012 19:46:07

Message: 41 of 44

"Matt J" wrote in message <js9uqt$g56$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <js9shn$4li$1@newscl01ah.mathworks.com>...
> >
> > these are my matrices:
> >
>
> I get an out-of-memory error, too, though a different one than yours. I think the problem dimension is just too big...

Ok Matt thanks a lot anyway!

Subject: optimization problem: get a feasible point for running an optimization

From: pietro

Date: 6 Jul, 2012 08:29:07

Message: 42 of 44

"pietro " <bracardi82@email.it> wrote in message <jsaf5v$4b2$1@newscl01ah.mathworks.com>...
> "Matt J" wrote in message <js9uqt$g56$1@newscl01ah.mathworks.com>...
> > "pietro " <bracardi82@email.it> wrote in message <js9shn$4li$1@newscl01ah.mathworks.com>...
> > >
> > > these are my matrices:
> > >
> >
> > I get an out-of-memory error, too, though a different one than yours. I think the problem dimension is just too big...
>
> Ok Matt thanks a lot anyway!

I'm still woring on my optimization problem, and I have found a strange behaviour of fmincon. The starting point is a feasible one, but since iteration 0 I get a constrain violation. Why?
I stopped the calculation after 5 iterations, and the solution is still feasible and the obejective function is strongly increased. If I keep fmincon working I got an unfeasible point, but the constraint violation is much lower than the one of the starting point. Why?

Thanks

Best regards

Pietro

Subject: optimization problem: get a feasible point for running an optimization

From: Matt J

Date: 6 Jul, 2012 13:33:07

Message: 43 of 44

"pietro " <bracardi82@email.it> wrote in message <jt67kj$eou$1@newscl01ah.mathworks.com>...
>
> I'm still woring on my optimization problem, and I have found a strange behaviour of fmincon. The starting point is a feasible one, but since iteration 0 I get a constrain violation. Why?
>
> I stopped the calculation after 5 iterations, and the solution is still feasible and the obejective function is strongly increased. If I keep fmincon working I got an unfeasible point, but the constraint violation is much lower than the one of the starting point. Why?
==============

As we told you at the beginning of this thread, fmincon is only designed to converge to a feasible solution. It is not guaranteed to give feasible points at each iteration individually. The only thing that sounds surprising, therefore is where you say the objective function "strongly increased" because I thought all of fmincon's algorithms were monotonically minimizing. Do you actually mean that you have reformulated a maximization problem as a minimization problem and the thing you are interested in maximizing has increased?

Subject: optimization problem: get a feasible point for running an optimization

From: Marcelo Marazzi

Date: 6 Jul, 2012 16:49:26

Message: 44 of 44

Hi Pietro:

Could you post the options you're using, set the option Display to
'iter' and post the iterative output (the entire run) that you get when
running fmincon? This may help diagnose the issue.

-Marcelo

On 7/6/2012 4:29 AM, pietro wrote:
> "pietro " <bracardi82@email.it> wrote in message
> <jsaf5v$4b2$1@newscl01ah.mathworks.com>...
>> "Matt J" wrote in message <js9uqt$g56$1@newscl01ah.mathworks.com>...
>> > "pietro " <bracardi82@email.it> wrote in message
>> <js9shn$4li$1@newscl01ah.mathworks.com>...
>> > >
>> > > these are my matrices:
>> > > > > I get an out-of-memory error, too, though a different one than
>> yours. I think the problem dimension is just too big...
>>
>> Ok Matt thanks a lot anyway!
>
> I'm still woring on my optimization problem, and I have found a strange
> behaviour of fmincon. The starting point is a feasible one, but since
> iteration 0 I get a constrain violation. Why?
> I stopped the calculation after 5 iterations, and the solution is still
> feasible and the obejective function is strongly increased. If I keep
> fmincon working I got an unfeasible point, but the constraint violation
> is much lower than the one of the starting point. Why?
>
> Thanks
>
> Best regards
>
> Pietro

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
staircased objecti... Matt J 25 Jun, 2012 13:43:39
stationary initial... Matt J 25 Jun, 2012 13:43:39
fmincon pietro 1 Jun, 2012 05:59:08
optimization pietro 1 Jun, 2012 05:59:08
rssFeed for this Thread

Contact us