LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

optimization of function with discrete (integer) arguments

Given: a matching unit (MU) with 2 motors which are controlled via RS232. Each motor can be driven to position from 0 to 1000 (integer only!).The value to be optimized is mismatch, which can take value from 0 to 100% and depends from the process (considered as external influence) and the MU motor positions (X1, X2).

 

The purpose is to get the perfect match, i.e. mismatch close to zero (from the practical point of view Mismatch<1% is zero). The dependence Loss(X1, X2) is from the experience rather well-behaved, with only 1 minimum, which is close enough to zero as a rule. However there may be some process noise, sometimes up to 1-2% mismatch.

I've tried (with a simulated process) the Constrained Nonlinear Optimization VI. It worked OK for floating X1, X2 values, but failed as I converted X1, X2 to integers. Is there any workaround with the ready-to-use LabVIEW VIs? We have LV full development system here.

What optimization algorithm would better suit for the task? If I'm to implement it myself, then is following to consider:

  • simplicity is strongly preferred
  • large changes of (X1, X2) values cost time
  • working with large mismatch should be avoided if possible
  • after the motors reached the position, th system settles immediately

Thanks

0 Kudos
Message 1 of 6
(2,565 Views)

Hello Elkb,

 

how did you convert the Datatypes (Int => DBL)?

 

Regards!

 

Moritz M.

0 Kudos
Message 2 of 6
(2,551 Views)

Using I32-->DBL function

 

Attached is my test. By a switch you can turn on or off the conversion (i.e. rounding) of the arguments. Without rounding, the optimizer finds the minimum in just a few steps. With it, it actually never moves off form the starting point.

0 Kudos
Message 3 of 6
(2,536 Views)

I am no optimization expert, but I think I can explain why your integer mode version does not work.

 

I put a functional global VI inside the nonlinear test objective function.vi to capture the values of the output.  I called the functional global in Read mode in a separate VI to display the results.

 

objective output (DBL)(I32)

19350.530000000 19350.530000000

19350.530000000 19350.530000000

19350.531144018 19350.530000000

19350.529324858 19350.530000000

18931.496465206 19350.530000000

......

 

X[0] (DBL)(I32)

500.00000000000 500.00000000000

500.00000000000 500.00000000000

500.00000477470 500.00000000000

500.00000000000 500.00000000000

261.70422390905 500.00000000000

......

 

The conversion to integer rounds out the small changes in the first few iterations. This keeps the optimization VI from moving towards the optimum.

 

Explaining what happens is one thing. Getting it to do what you want is another.  Can you optimize with DBL, convert to integers, and calculate the values for those integers (and possibly near neighbors)?

 

Lynn

0 Kudos
Message 4 of 6
(2,527 Views)

@johnsold wrote:
The conversion to integer rounds out the small changes in the first few iterations. This keeps the optimization VI from moving towards the optimum

...

Can you optimize with DBL, convert to integers, and calculate the values for those integers (and possibly near neighbors)?

 

Lynn


Thank you Lynn,
I've set up the global that way exactly with the aim to look what's happening.
The problem is, my aim is not optimizing some simulation, where I could use DBL (or even complex). In the end, I have a real world process, where I can only move motors in steps and measure (with limited precision and some noise) what's happening.

 

0 Kudos
Message 5 of 6
(2,511 Views)

I understand that you can only move in discrete steps.  My suggestion was to allow the optimization to run with floating point numbers and then move your motors the integer number nearest the floating point optimum.  Depending on your process, you might need to round down or up rather than using the nearest integer.

 

Lynn

0 Kudos
Message 6 of 6
(2,503 Views)