The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

How to set Parameter on a Filter Example Operator

imanol_bidegainimanol_bidegain Member Posts: 1 Learner III
edited November 2018 in Help
Hi,

I'm trying to change the filter parameters of a Filter Example operator , I'm not sure how have to be written

Operator op = process.getOperator("Filter Examples (8)");
op.setParameter("ExampleFilter.PARAMETER_PARAMETER_STRING",??); // Here is where i don't know what to write.


I hope someone could help me, i'll be very greatful
Tagged:

Answers

  • LostSummerLostSummer Member Posts: 2 Contributor I

    Hello there,

     

    Here is how Operator.setParameter(String key, String value) works.

     

    The first argument is the key, or the name of the parameter. The type is String, and usually, we refere these keys in the way

    ClassName.KEY_NAME

    e.g.

    ImprovedNeuralNetLearner.PARAMETER_HIDDEN_LAYERS

    RandomGenerator.PARAMETER_USE_LOCAL_RANDOM_SEED

    In this way, you may code quicker, avoid type mistake, and keep your program stable.

     

    The second argument is also a String, for the value of this parameter. This means even for numerics or booleans, you should cast them in to String.

    e.g. "true", "0".

     

    Here is an example that may help you know how to set and retrieve parameters:

     

     // here we set the parameter using the method setParameter(String key, String value);
    // ""+int is just a quick way to convert single int into a string
    opt.setParameter(AttributeSubsetSelector.PARAMETER_FILTER_TYPE,
    ""+(AttributeSubsetSelector.CONDITION_ALL));

    // now lets test whether the value is set
    String s = opt.getParameterAsString(AttributeSubsetSelector.PARAMETER_FILTER_TYPE);
    System.out.println(s);

    // actually you can also get the parameter as an integer or other applicable data type
    int i = opt.getParameterAsInt(AttributeSubsetSelector.PARAMETER_FILTER_TYPE);
    System.out.println(i);

     

Sign In or Register to comment.