Skip to content
Felix Dobslaw edited this page Jun 30, 2013 · 6 revisions

Tutorial 3:

Relative Constraints

Now that we learned how entire designs can be created by a single line of code, we will take a closer look into how intra-parameter constraints within designs can be defined. We use the Examples project as a starting point and play with the code in here.

Say, parameter "param2" has to be guaranteed to lay below "param1". We simply write:

<NParam id ="param1" type="integer"/>
<NParam id ="param2" type="integer" exclMax="param1"/>

Defining inclMax="param1-1" instead of exclMax="param1" would result in the same constraint. Now, constraints can be composed of arbitrary combinations of binary operators - + / * among the different parameters. Here is an example, assuming that another parameter "param3" is always larger than the quotient of "param1" and "param2":

<NParam id ="param3" type="integer" exclMin="param1/param2"/>

However, make sure that the relative constraints contain no cyclic references!

Javascript support

By default expression evaluation is done by the Javascript engine that ships with Java 6 and above. Therefore, other mathematical expressions such as sine, cosine, log, square can easily be integrated

<NParam id ="param4" type="integer" exclMin="Math.cos(Math.pow(param2, 3))"/>

The default engine can be changed in the configuration file, given that you have an alternative implementation of the InputEvaluator Interface. An implementation using the JEval engine gets shipped with the InPUT Extras module.

Multiple Valid Constraints (from version 0.3.1)

From InPUT version 0.3.1 onwards multiple min and max ranges can be defined for a single value. E.g. if you want to make sure that the value is either in [0.1,0.4], [0.2,0.7] or [0.8,0.9] you can write:

<NParam id ="param5" type="integer" inclMin="0.1,0.2,0.8" inclMax="0.4,0.7,0.9"/>

Randomly drawn values are guaranteed to satisfy (at least) one of the constraints.

Use Cases

Fine, but where does all that make sense? There are a couple of use cases for this, I would like to point out two of them:

Problem Instance Generators: At times, you might want to create datasets containing multiple constraints, and you do not want to create specific programs each time. An example for a problem instance generator is the dataset generation engine for clustering problems which uses InPUT.

Algorithm Configuration: Optimization, prediction, simulation, or search algorithms of all kinds require the user to set parameter values. If not then they use default settings which are usually not optimized for the problem you are looking at. With InPUT you could run a so called Monte Carlo simulation, creating a hundred or thousands of parameter combinations and testing the algorithm on your problem utilizing them. If the executions are fast and the parameters are not that many, you will soon receive a (near-)optimal setting for your problem. If executions are time consuming or if you have many parameters, a Monte Carlo simulation might not be effective. InPUT can even help with experimental design for these cases, as will be discussed in a later tutorial.

Summary

In this tutorial we learned how to define relative parameter constraints and where this could come in handy. In the next lessons we learn how to use the simplified injection-based user interface API for the import and export of designs and design spaces.

Clone this wiki locally