cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Optimisation problem: Find the best N pts (x,y) to meet criteria?

JBlackhole
16-Pearl

Optimisation problem: Find the best N pts (x,y) to meet criteria?

to all,

A bit of an open question as I do not know how to go about solving the following – if it can be done at all

I have a curve C1, define between [x1,xn] and I would like to create a curve C2 using N pts so that some criteria are met. Essentially is a “double optimisation” problem. Consider the following; I want C2 to be made of p points p(xi,yi) – Generally a few points (say no more than 10)

Criteria 1:-  xn > xn-1 > x1 . xn and x1 are given

Criteria 2: In a given x range [xn,x+1] rms C1 ~ rms C2 . Within a given a tolerance (say +/-1%).

 

Is there of way of using Mathcad to find the best pair of points to meet criteria #2

Does it require some sort of loop, or is there some built-in optimisation tool one can use

Attached a mcad 15 file swith some preliminary stuff - Not much

ACCEPTED SOLUTION

Accepted Solutions

Hi,

 

Is this what you mean by finding the y values?

Capture.JPG

View solution in original post

8 REPLIES 8
DJF
16-Pearl
16-Pearl
(To:JBlackhole)

I think your explanation could be expanded as it's not fully clear to me what you are after.  From what I 'think' you're asking, aren't you just trying to get points off of C1?  If your criteria is rms(c1)=rms(c2) then c2=c1 is your obvious answer, you just want a smaller set of points along a given interval.  You could fit a b-spline and grab spaced points along c1.  Or other interpolation type.  Not exactly what you asked for but I think gets your end goal.  Otherwise there are an infinite number of solutions where rms(c2) = rms(c1).

JBlackhole
16-Pearl
(To:DJF)

Thanks for the reply. I appreciate I wasn’t clear about what I am trying to do. Still trying to put it in words 

imagine the following. Using the Simpson method for integration by splitting a range [a,b] into n equivalent length. Let’s say I split this range into 2 rectangles. It’s fairly easy to find the “middle” point so that the area A of each rectangle is close to the exact integral 

 

what I am thinking at the moment is if there is a way of “automatically” finding the best positions of say N points so that the area in each “bin” is a close match. If the raw data as a x increment =1 over say [10-2000] range then choosing 1990 points would be an exact match

 

With the attached diagram

I split the range into 3 areas . I therefore "decided" I want to use a vector {f1,f2,f3,f4} in all cases f1 and f4 are "fixed" i.e. decided by the user. I therefore will have a vector y={y1,y2,y3,y4}

Is there a way of finding the best values for (f2,y2) & (f3,y3) so that

area sqrt(A1) ~ sqrt(A'1); sqrt(A2) ~ sqrt(A'2) and sqrt(A3)~ sqrt(A'3) where the A areas from Curve C1 and A' the areas from the points I am trying to establish

 

also added a mcad 15 example but needed 5 pts to "look" good. Not checked the areas,etc

Hi,

 

"what I am thinking at the moment is if there is a way of “automatically” finding the best positions of say N points so that the area in each “bin” is a close match"

 

look up "Gaussian quadrature" on the internet for exactly this problem and solution.

 

Cheers

Terry

Thanks Terry. I realised very late last night that it’s more or less what I want to - was thinking about integration in finite element method in range -1 to 1. 

What I am not sure is the weighting factors. Would wC1(x) be the value I am after if I chose x?

I have in mind selecting a number of n points (x) by judgment eye-balling the curve and then have mathcad find all the appropriate y values for the selected set.

would there be a way in math and to solve this?

 

Thanks

Hi,

Are you ultimately after the integral of whole set of data.  A similar technique can be used to determine integral (area) between any two data points.

 

Capture.JPG

Thanks. Not really as the (sqrt of the) integral is a given i.e easy to set-up I am using the same method as you kindly offered but use a log-log integration. I also have a method somewhere  which fits a cspline to the data first and then do integration.

 

Did some searches on the Gauss integration-attached pdf. It is what I am trying to do but I do not know if the "solving" can be done in mcad. I suspect it can. Might be a minimisation problem! I think I started laying out the problem  a bit better and the "key" step is how to use and set up the 'Given' block

Hi,

 

Is this what you mean by finding the y values?

Capture.JPG

I think so. 

I'll have a look as I need to correct a few thing in the posted sheet - I need to modify it so that I deal with "sloping" rectangle (trapezoid) rather than rectangle as this approach is too limiting and woudl only work is very few special cases (when I get to the real "thing")

May need a loop

start with (x1,y1) (x2) find best value of y2 to match the area A1

use (x2,y2) and x3 find best value of y3 to match the area A2

and so on

the selectin of the x values will always be a user's choice

Announcements

Top Tags