[all packages] [package ] [class hierarchy] [index]

public class Solution

(source file: Solution.java)
java.lang.Object
   |
   +----Solution

The pure class interface.
public class Solution

A class which solves a set of constraints.

The algorithm is a simple 2-pass dynamic program.

In the first pass, we minimize all of the variables, and find the maximum horizontal and maximum vertical variables.

In the second pass, we maximize all of the variables, using the previously found maxima as upper bounds.

This gives two values for each variable: a minimum and a maximum. We just average the two to give a result.

This algorithm sometimes produces sub-optimal results (sometimes it can result in pretty extreme diagonals) but most times it produces reasonable graphs. It runs in linear time in the number of variables.

Author:
Alan Jeffrey
Version: v1.0 1998/06/02
See also:
Constraints

Constuctor Index

O Solution(Constraints)
Build a solution to a constraint set.

Variables Index

O C
The constraints solved.
O hMax
The largest value of any horizontal variable.
O vMax
The largest value of any horizontal variable.

Methods

O maximal(int)
Find the maximum value associated with a variable.
O minimal(int)
Find the minimum value associated with a variable.
O value(int)
Find the average value associated with a variable.

Constructors

O Solution
public Solution(Constraints C);
Build a solution to a constraint set.

Variables

O C
public Constraints C;
The constraints solved.

O hMax

public int hMax;
The largest value of any horizontal variable.

O vMax

public int vMax;
The largest value of any horizontal variable.

Methods

O minimal
public int minimal(int x);
Find the minimum value associated with a variable.

Parameters:
x - the variable number to look up.
Returns:
the value of the variable.
Throws:
ArrayIndexOutOfBoundsException -if the variable number is not a valid index.

O maximal

public int maximal(int x);
Find the maximum value associated with a variable.

Parameters:
x - the variable number to look up.
Returns:
the value of the variable.
Throws:
ArrayIndexOutOfBoundsException -if the variable number is not a valid index.

O value

public int value(int x);
Find the average value associated with a variable.

Parameters:
x - the variable number to look up.
Returns:
the value of the variable.
Throws:
ArrayIndexOutOfBoundsException -if the variable number is not a valid index.


[all packages] [package ] [class hierarchy] [index]
Solution.html