cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar

maximize function

Hello!

is there any way to implement the maximize function to find or search for the max values of a linear fit or in a polynomial graph? 

Thanks 

1 REPLY 1
ih
Super User (Alumni) ih
Super User (Alumni)

Re: maximize function

When working interactively you might do this with the profiler.  Create a column with the formula you want to maximize, then open the profiler, set desirability functions, and then maximize desirability.

Table with formula:

     ih_0-1690219205203.png

 

In profiler of y, show desirability functions:

     ih_1-1690219242442.png

 

Control+click (in windows) on the desirability function, set it to maximize and give it a range to search:

     ih_2-1690219373121.png

 

Adjust the axis settings and then run maximize desirability:

ih_3-1690219443737.png

 

Which does identify the value of X that maximizes Y:

     ih_4-1690219504243.png

 

Here is code to recreate the chart:

View more...
Names default to here(1);

dt = New Table( "WithFormula",
	Add Rows( 1 ),
	New Column( "X",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1] )
	),
	New Column( "Y",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( 15 - (:X-3) ^ 2 )
	)
);

// show the interaction
dt << Graph Builder(
	Size( 533, 456 ),
	Show Control Panel( 0 ),
	Variables( X( :X ), Y( :Y ) ),
	Elements( Formula( X, Y, Legend( 5 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"X",
			ScaleBox,
			{Format( "Best", 12 ), Min( -5.83914231679298 ), Max( 5.61125768320702 ),
			Inc( 2 ), Minor Ticks( 0 )}
		),
		Dispatch(
			{},
			"Y",
			ScaleBox,
			{Format( "Best", 12 ), Min( -22.4207925102041 ), Max( 16.6726794897959 ),
			Inc( 10 ), Minor Ticks( 0 )}
		)
	)
);

// Use the profiler with a desirability function to indicate that the Y variable should
// be maximized and give a range in which to maximize it 
prof = dt << Profiler(
	Y( :Y ),
	Profiler(
		1,
		Desirability Functions( 1 ),
		Y << Response Limits(
			{Lower( -100, 0.066 ), Middle( 0, 0.5 ), Upper( 100, 0.9819 ),
			Goal( "Maximize" ), Importance( 1 )}
		),
		Term Value(
			X(
				0,
				Min( -10 ),
				Max( 10 ),
				Lock( 0 ),
				Show( 1 )
			)
		)
	)
);

prof << Maximize Desirability;