LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Constrained nonlinear optimization, how to program equality/inequality constraints?

Hi All,

 

I need to solve following problem:

 

 

Y1 = exp(-x1/12)*23

Y2 = exp(-x2/5)*4 + Y1

 

Constraints:

 4 <= x1 <= 9

12 <= x2 <= 49

 

Y2 = 88

 

Object function (to be minimized):

 

J = 1.2*x1 + 1.8*x2

 

 

Can someone told me how I should wire equality/inequality constraints in object function VI? If I use initial values which are near constraints limits I don't achieve minimum objective function. That is the reason why I think that something is wrong in contraints programming.

 

BR, Jim   

 

 

 

0 Kudos
Message 1 of 9
(5,237 Views)
I am not convinced that there is any value of x1 and x2 in your range that meets the Y2 constraint.
0 Kudos
Message 2 of 9
(5,213 Views)
That was just an example. Only format of equations are right not numbers byself. I know from excel results that there is a solution. I'm interested to see how to program constraints because there is no ready made example for that.
0 Kudos
Message 3 of 9
(5,204 Views)

You seem to be asking for an awful lot.  NI gives you several examples using Constrained Nonlinear Optimization and you think that showing you how to use constraints in a constrained optimization is important?  Besides that they give you a template for the objective function, didn't you find the minimally documented controls placed haphazardly on the FP and BD to be enough of a hint?  Finally, the main VI is not password protected so you can easily follow the code on the BD.  Sometimes it is tough to follow code, but increasing the size of the BD like they do here is very helpful.  Of course the hardest part for beginners in LV is to master dataflow.  Here they save you the trouble by using a stacked sequence in one of the first subVIs along with some sequence locals since left to right is so overrated.

 

(As Homer Simpson once said "By the way I am being sarcastic").  What a complete mess, from the code itself to the documentation and examples.  But the icon is spiffy so at least there is some quality control.

 

On to the task at hand:  Having stepped into that steaming pile of poo that is the BD, it seems that the equality and inequality constraints are simply bundled together.  You can ignore the equality constraint output of the objective function VI (I guess).  For your equality constraint Y2=88, just wire Y2 to an inequality constraint, and make the max and min value equal to 88.  Your x1 and x2 constraints are handled via the x minimum and maximum controls.  Try the following VI to see if it works and makes some sense.  I changed the range for x1 and x2 to include a region where the Y2 constraint is met, otherwise I get an error. 

 

 

Message Edited by Darin.K on 05-26-2010 10:27 AM
Download All
Message 4 of 9
(5,189 Views)

Darin,

 

Thanks a lot for your examples and detail answer. My own objective function was exactly same as yours. I made same decision to set inequality constraints to same value 88 and I get almost every time optimum result. But if I change initial conditions little bit sometimes I don't get optimum result. That is the reason why I think that I must wire something to equality constraint indicator in odjective function VI. This is little bit academic question but I think that many people needs this information: What kind of problem I must have that I have to wire something to equality constraint indicator in objective function VI?

 

At least community get very good examples, thanks!

 

BR, Jim

0 Kudos
Message 5 of 9
(5,175 Views)

Hi,SnowForest .Have you solve the problem? I meet the same difficulity with you, maybe we can disscuss this quessstion and look for the answer.

Best regards.

0 Kudos
Message 6 of 9
(4,924 Views)
My example is following, object function minimize F(X)=0.785*x1^2*x2; constrants: 8.33*x2-x1^3<=0; 6.25-x1^3<=0; 0.34*x2^3-x1^4<=0; 8-x2<=0;How can I use the constraints in this vi?
0 Kudos
Message 7 of 9
(4,920 Views)

Continues here.

0 Kudos
Message 8 of 9
(4,840 Views)

Hello,

 

I wasn't able to solve this. And I also get very unstable results when I tryed to program this problem. Sometimes it found a solution sometimes not. Hopefully we will finally get a good example here how to program this kind of problem.

0 Kudos
Message 9 of 9
(4,836 Views)