cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-481390%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EJSL%20and%20DOE%5B%5D%20platform%20for%20custom%20design%2C%20can%20you%20conditionally%20'Add%20a%20factor'%20based%20on%20the%20value%20of%20a%20variable%20from%20a%20modal%20window%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-481390%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20to%20create%26nbsp%3B%20a%20script%2C%20where%20based%20on%20some%20previous%20input%20variable%2C%20the%20DOE%5B%5D%20object%20is%20messaged%20to%20work%20with%20one%20additional%20factor.%3C%2FP%3E%3CP%3EThe%20DOE%20design%20generation%20is%20now%20heavy%20to%20run%20(about%20a%2030sec)%2C%20so%20I%20am%20looking%20for%20a%20lean%20way%20(e.g.%20tweak%20it%20before%20sending%20the%20'make%20design'%20message).%3C%2FP%3E%3CP%3EIdeally%20i%20would%20like%20to%20work%20with%20an%20if%20clause%2C%20checking%20if%20a%20said%20boolean%20variable%20is%20true%20and%20if%20so%20add%20the%20factor%20to%20the%20custom%20design.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESome%20'pseudocode'%3A%3C%2FP%3E%3CPRE%3EAddSpecialFactor%20%3D%201%3B%20%2F*%20decision%20rule%20to%20add%20factor%2C%20will%20be%20retrieved%20from%20a%20modal%20window%20based%20on%20some%20more%20complex%20molecule%20chemistry%20input%20*%2F%0A%0AD%20%3D%20DOE(%0A%0Acustom%20design%2C%0A%0AAdd%20Factor(continuous%2C%20%22A%22%2C.....)%2C%0A%0AAdd%20Factor(%20...)%2C%0A%0A..%0A%0AIf%26nbsp%3B%20%26nbsp%3B(AddSpecialFactor%20%3D%201)%20then%20Add%20Factor(....)%2C%0A%0A%0A%0AAdd%20Term()%2C%0A%0A..%0A%0AIf%20(AddSpecialFactor%20%3D%201)%26nbsp%3B%20then%20Add%20Term()%20...%2C%3C%2FPRE%3E%3CP%3EAll%20suggestions%20are%20more%20than%20welcome%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-481390%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3EScripting%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-482306%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20JSL%20and%20DOE%5B%5D%20platform%20for%20custom%20design%2C%20can%20you%20conditionally%20'Add%20a%20factor'%20based%20on%20the%20value%20of%20a%20variable%20from%20a%20modal%20window%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-482306%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EThat's%20kind%20of%20a%20cool%20idea%20for%20design%20generation.%3C%2FP%3E%0A%3CP%3EI%20was%20working%20on%20just%20taking%20designs%20from%20a%20CSV%20and%20generating%20DOEs.%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FByron-Wingerd-s-Blog%2FAutomating-Design-Generation%2Fba-p%2F407039%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.jmp.com%2Ft5%2FByron-Wingerd-s-Blog%2FAutomating-Design-Generation%2Fba-p%2F407039%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%20might%20work%20to%20have%20your%20script%20concept%20generate%20a%20data%20table%20and%20then%20use%20the%20script%20in%20the%20blog%20above%20to%20load%20and%20run%20the%20DOE%20platform.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMaybe%20get%20a%20list%20of%20column%20names%2C%20and%20if%20that%20list%20contains%20certain%20words%2C%20then%20add%20columns%20with%20the%20appropriate%20factor%20levels%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-541402%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20JSL%20and%20DOE%5B%5D%20platform%20for%20custom%20design%2C%20can%20you%20conditionally%20'Add%20a%20factor'%20based%20on%20the%20value%20of%20a%20variable%20from%20a%20modal%20window%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-541402%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EThank%20you%20Byron%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELoading%20from%20a%20table%20is%20a%20nice%20idea.%3C%2FP%3E%3CP%3EThough%20I%20have%20to%20adjust%20the%20model%26nbsp%3B%20as%20it%20is%20more%20complicated%20as%20a%20RSM%3A%20it%20has%20branching%20factors%20as%20in%20the%20publication%20by%20Peter%20Goos%20and%20Bradley%20Jones%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGoos%20and%20Jones%20(2019)%20Optimal%20Experimental%20Design%20in%20the%20presence%20of%20Nested%20Factors.%20Technometrics.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdoi.org%2F10.1080%2F00401706.2018.1562986%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdoi.org%2F10.1080%2F00401706.2018.1562986%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20you%20also%20have%20examples%20where%20the%20code%20is%20build%20in%20text%20format%20and%20then%20used%20to%20an%20evaluate()%20expression.%3C%2FP%3E%3CP%3ELike%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EDOECODE%20%3D%20%22Part%20of%20the%20code%20%22%20%7C%7C%20if(..%2C)%20%7C%7C%20etc...%0A.%0A.%0ADOEcommand%20%3D%20evaluate(DOECODE)%3B%0A%0ADOETable%20%3D%20(DOEcommand%20%26lt%3B%26lt%3B%20Make%20Table)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-541427%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20JSL%20and%20DOE%5B%5D%20platform%20for%20custom%20design%2C%20can%20you%20conditionally%20'Add%20a%20factor'%20based%20on%20the%20value%20of%20a%20variable%20from%20a%20modal%20window%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-541427%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHere%20is%20an%20example%20of%20how%20you%20might%20script%20this%20process.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20to%20Here(%201%20)%3B%0A%0Adialog%20%3D%20New%20Window(%20%22Optional%20Factor%22%2C%20%26lt%3B%26lt%3B%20Modal%2C%0A%20Outline%20Box(%20%22Choice%22%2C%0A%20%20Text%20Box(%20%22Add%20X4%3F%22%20)%2C%0A%20%20Text%20Box(%20%22Click%20OK%20to%20add%22%20)%2C%0A%20%20Text%20Box(%20%22Click%20Cancel%20to%20skip%22%20)%0A%20)%2C%0A%20H%20List%20Box(%0A%20%20Button%20Box(%20%22OK%22%20)%2C%0A%20%20Button%20Box(%20%22Cancel%22%20)%0A%20)%0A)%3B%0A%0Adoe%20%3D%20DOE(%20Custom%20Design%2C%0A%20%7BAdd%20Response(%20Maximize%2C%20%22Y%22%2C%20.%2C%20.%2C%20.%20)%2C%0A%20Add%20Factor(%20Continuous%2C%20-1%2C%201%2C%20%22X1%22%2C%200%20)%2C%0A%20Add%20Factor(%20Continuous%2C%20-1%2C%201%2C%20%22X2%22%2C%200%20)%2C%0A%20Add%20Factor(%20Continuous%2C%20-1%2C%201%2C%20%22X3%22%2C%200%20)%2C%20Set%20Random%20Seed(%2030650037%20)%2C%0A%20Add%20Term(%20%7B1%2C%200%7D%20)%2C%20Add%20Term(%20%7B1%2C%201%7D%20)%2C%20Add%20Term(%20%7B2%2C%201%7D%20)%2C%20Add%20Term(%20%7B3%2C%201%7D%20)%2C%0A%20Add%20Term(%20%7B1%2C%201%7D%2C%20%7B2%2C%201%7D%20)%2C%20Add%20Term(%20%7B1%2C%201%7D%2C%20%7B3%2C%201%7D%20)%2C%0A%20Add%20Term(%20%7B2%2C%201%7D%2C%20%7B3%2C%201%7D%20)%2C%20Set%20Sample%20Size(%2012%20)%2C%20Simulate%20Responses(%200%20)%2C%0A%20Save%20X%20Matrix(%200%20)%7D%0A)%3B%0A%0A%2F%2F%20add%204th%20factor%20and%20the%20associated%20main%20effect%20and%20interaction%20terms%0AIf(%20dialog%5B%22Button%22%5D%20%3D%3D%201%2C%0A%20doe%0A%20%20%26lt%3B%26lt%3B%20Add%20Factor(%20Continuous%2C%20-1%2C%201%2C%20%22X4%22%2C%200%20)%0A%20%20%26lt%3B%26lt%3B%20Add%20Term(%20%7B4%2C%201%7D%20)%0A%20%20%26lt%3B%26lt%3B%20Add%20Term(%20%7B1%2C%201%7D%2C%20%7B4%2C%201%7D%20)%0A%20%20%26lt%3B%26lt%3B%20Add%20Term(%20%7B2%2C%201%7D%2C%20%7B4%2C%201%7D%20)%0A%20%20%26lt%3B%26lt%3B%20Add%20Term(%20%7B3%2C%201%7D%2C%20%7B4%2C%201%7D%20)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-541536%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20JSL%20and%20DOE%5B%5D%20platform%20for%20custom%20design%2C%20can%20you%20conditionally%20'Add%20a%20factor'%20based%20on%20the%20value%20of%20a%20variable%20from%20a%20modal%20window%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-541536%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EThank%20you%20!%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20works%20brilliantly%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Acara_con_una_leve_sonrisa%3A%22%3E%3C%2FLI-EMOJI%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
Not_A_Student
Level II

JSL and DOE[] platform for custom design, can you conditionally 'Add a factor' based on the value of a variable from a modal window ?

Hello,

 

I would like to create  a script, where based on some previous input variable, the DOE[] object is messaged to work with one additional factor.

The DOE design generation is now heavy to run (about a 30sec), so I am looking for a lean way (e.g. tweak it before sending the 'make design' message).

Ideally i would like to work with an if clause, checking if a said boolean variable is true and if so add the factor to the custom design.

 

Some 'pseudocode':

AddSpecialFactor = 1; /* decision rule to add factor, will be retrieved from a modal window based on some more complex molecule chemistry input */

D = DOE(

custom design,

Add Factor(continuous, "A",.....),

Add Factor( ...),

..

If   (AddSpecialFactor = 1) then Add Factor(....),



Add Term(),

..

If (AddSpecialFactor = 1)  then Add Term() ...,

All suggestions are more than welcome

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: JSL and DOE[] platform for custom design, can you conditionally 'Add a factor' based on the value of a variable from a modal window ?

Here is an example of how you might script this process.

 

Names Default to Here( 1 );

dialog = New Window( "Optional Factor", << Modal,
	Outline Box( "Choice",
		Text Box( "Add X4?" ),
		Text Box( "Click OK to add" ),
		Text Box( "Click Cancel to skip" )
	),
	H List Box(
		Button Box( "OK" ),
		Button Box( "Cancel" )
	)
);

doe = DOE( Custom Design,
	{Add Response( Maximize, "Y", ., ., . ),
	Add Factor( Continuous, -1, 1, "X1", 0 ),
	Add Factor( Continuous, -1, 1, "X2", 0 ),
	Add Factor( Continuous, -1, 1, "X3", 0 ), Set Random Seed( 30650037 ),
	Add Term( {1, 0} ), Add Term( {1, 1} ), Add Term( {2, 1} ), Add Term( {3, 1} ),
	Add Term( {1, 1}, {2, 1} ), Add Term( {1, 1}, {3, 1} ),
	Add Term( {2, 1}, {3, 1} ), Set Sample Size( 12 ), Simulate Responses( 0 ),
	Save X Matrix( 0 )}
);

// add 4th factor and the associated main effect and interaction terms
If( dialog["Button"] == 1,
	doe
		<< Add Factor( Continuous, -1, 1, "X4", 0 )
		<< Add Term( {4, 1} )
		<< Add Term( {1, 1}, {4, 1} )
		<< Add Term( {2, 1}, {4, 1} )
		<< Add Term( {3, 1}, {4, 1} )
);

View solution in original post

4 REPLIES 4
Byron_JMP
Staff

Re: JSL and DOE[] platform for custom design, can you conditionally 'Add a factor' based on the value of a variable from a modal window ?

That's kind of a cool idea for design generation.

I was working on just taking designs from a CSV and generating DOEs. Automating Design Generation 

 

It might work to have your script concept generate a data table and then use the script in the blog above to load and run the DOE platform. 

Maybe get a list of column names, and if that list contains certain words, then add columns with the appropriate factor levels?

 

 

JMP Systems Engineer, Health and Life Sciences (Pharma)
Not_A_Student
Level II

Re: JSL and DOE[] platform for custom design, can you conditionally 'Add a factor' based on the value of a variable from a modal window ?

Thank you Byron,

 

Loading from a table is a nice idea.

Though I have to adjust the model  as it is more complicated as a RSM: it has branching factors as in the publication by Peter Goos and Bradley Jones:

 

Goos and Jones (2019) Optimal Experimental Design in the presence of Nested Factors. Technometrics.

https://doi.org/10.1080/00401706.2018.1562986

 

Do you also have examples where the code is build in text format and then used to an evaluate() expression.

Like:

 

DOECODE = "Part of the code " || if(..,) || etc...
.
.
DOEcommand = evaluate(DOECODE);

DOETable = (DOEcommand << Make Table);

Re: JSL and DOE[] platform for custom design, can you conditionally 'Add a factor' based on the value of a variable from a modal window ?

Here is an example of how you might script this process.

 

Names Default to Here( 1 );

dialog = New Window( "Optional Factor", << Modal,
	Outline Box( "Choice",
		Text Box( "Add X4?" ),
		Text Box( "Click OK to add" ),
		Text Box( "Click Cancel to skip" )
	),
	H List Box(
		Button Box( "OK" ),
		Button Box( "Cancel" )
	)
);

doe = DOE( Custom Design,
	{Add Response( Maximize, "Y", ., ., . ),
	Add Factor( Continuous, -1, 1, "X1", 0 ),
	Add Factor( Continuous, -1, 1, "X2", 0 ),
	Add Factor( Continuous, -1, 1, "X3", 0 ), Set Random Seed( 30650037 ),
	Add Term( {1, 0} ), Add Term( {1, 1} ), Add Term( {2, 1} ), Add Term( {3, 1} ),
	Add Term( {1, 1}, {2, 1} ), Add Term( {1, 1}, {3, 1} ),
	Add Term( {2, 1}, {3, 1} ), Set Sample Size( 12 ), Simulate Responses( 0 ),
	Save X Matrix( 0 )}
);

// add 4th factor and the associated main effect and interaction terms
If( dialog["Button"] == 1,
	doe
		<< Add Factor( Continuous, -1, 1, "X4", 0 )
		<< Add Term( {4, 1} )
		<< Add Term( {1, 1}, {4, 1} )
		<< Add Term( {2, 1}, {4, 1} )
		<< Add Term( {3, 1}, {4, 1} )
);
Not_A_Student
Level II

Re: JSL and DOE[] platform for custom design, can you conditionally 'Add a factor' based on the value of a variable from a modal window ?

Thank you ! 

It works brilliantly  

Recommended Articles