cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Have your say in shaping JMP's future by participating in the new JMP Wish List Prioritization Survey
Choose Language Hide Translation Bar
RMSEBird223
Level II

Automatically change factor settings of a profiler object using a for loop

Hi all,

I would like to automatically change the factor settings of a profiler object. If I address each factor directly it works as expected:

 
dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
obj = dt << Profiler(
	Y(
		:Pred Formula ABRASION, :Pred Formula MODULUS, :Pred Formula ELONG,
		:Pred Formula HARDNESS
	),
	Desirability Functions( 1 )
);

//works
obj << Term Value("SILICA"(5, Min( -10 ), Max( 6 ), Lock( 1 ), Show( 1 ) ));
However, if I want to loop over all factors to change the respective settings, nothing happens. 
dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
obj = dt << Profiler(
	Y(
		:Pred Formula ABRASION, :Pred Formula MODULUS, :Pred Formula ELONG,
		:Pred Formula HARDNESS
	),
	Desirability Functions( 1 )
);

//does not work
FactorList = {"SILICA", "SILANE"};
for(i=1, i<=n items(FactorList), i++,
	Eval( 
		Eval Expr( 
			obj << Term Value(
				Expr(FactorList[i])( 5, Min( -10 ), Max( 6 ), Lock( 1 ), Show( 1 ) )
			)
		)
	)
);
Using Eval(Eval Expr()) usually solved it when I had similar issues. Sadly, this isn't helping this time.
Thanks for your help!

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Automatically change factor settings of a profiler object using a for loop

Using this method appears to work

dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
obj = dt << Profiler(
	Y(
		:Pred Formula ABRASION, :Pred Formula MODULUS, :Pred Formula ELONG,
		:Pred Formula HARDNESS
	),
	Desirability Functions( 1 )
);

//does not work
FactorList = {"SILICA", "SILANE"};
for(i=1, i<=n items(FactorList), i++,
	Eval( 
		Parse( 
			"obj << Term Value(
				\!""||FactorList[i]|| "\!"( 5, Min( -10 ), Max( 6 ), Lock( 1 ), Show( 1 ) )
			);"
		)
	)
);
Jim

View solution in original post

jthi
Super User

Re: Automatically change factor settings of a profiler object using a for loop

To debug your script, you can check what the EvalExpr() part does return

FactorList = {"SILICA", "SILANE"};
i = 1;
term_expr = Eval Expr(obj << Term Value(Expr(FactorList[i])(5, Min(-10), Max(6), Lock(1), Show(1))));
show(term_expr);

it is something like this which is incorrect syntax

term_expr = obj << Term Value("SILICA" << {5, Min(-10), Max(6), Lock(1), Show(1)});

And here is one way of dealing this

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Tiretread.jmp");
obj = dt << Profiler(
	Y(:Pred Formula ABRASION, :Pred Formula MODULUS, :Pred Formula ELONG, :Pred Formula HARDNESS),
	Desirability Functions(1)
);

terms = {"SILICA", "SILANE"};

For Each({term}, terms,
	Eval(Substitute(
		Expr(obj << Term Value(_term_(5, Min(-10), Max(6), Lock(1), Show(1)))),
		Expr(_term_), Name Expr(AsColumn(dt, term));
	));
);
-Jarmo

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Automatically change factor settings of a profiler object using a for loop

Using this method appears to work

dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
obj = dt << Profiler(
	Y(
		:Pred Formula ABRASION, :Pred Formula MODULUS, :Pred Formula ELONG,
		:Pred Formula HARDNESS
	),
	Desirability Functions( 1 )
);

//does not work
FactorList = {"SILICA", "SILANE"};
for(i=1, i<=n items(FactorList), i++,
	Eval( 
		Parse( 
			"obj << Term Value(
				\!""||FactorList[i]|| "\!"( 5, Min( -10 ), Max( 6 ), Lock( 1 ), Show( 1 ) )
			);"
		)
	)
);
Jim
jthi
Super User

Re: Automatically change factor settings of a profiler object using a for loop

To debug your script, you can check what the EvalExpr() part does return

FactorList = {"SILICA", "SILANE"};
i = 1;
term_expr = Eval Expr(obj << Term Value(Expr(FactorList[i])(5, Min(-10), Max(6), Lock(1), Show(1))));
show(term_expr);

it is something like this which is incorrect syntax

term_expr = obj << Term Value("SILICA" << {5, Min(-10), Max(6), Lock(1), Show(1)});

And here is one way of dealing this

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Tiretread.jmp");
obj = dt << Profiler(
	Y(:Pred Formula ABRASION, :Pred Formula MODULUS, :Pred Formula ELONG, :Pred Formula HARDNESS),
	Desirability Functions(1)
);

terms = {"SILICA", "SILANE"};

For Each({term}, terms,
	Eval(Substitute(
		Expr(obj << Term Value(_term_(5, Min(-10), Max(6), Lock(1), Show(1)))),
		Expr(_term_), Name Expr(AsColumn(dt, term));
	));
);
-Jarmo