Problem Types

OptiX supports three main types of optimization problems with increasing complexity: Constraint Satisfaction Problems (CSP), Linear Programming (LP), and Goal Programming (GP). This guide explains when and how to use each type.

Constraint Satisfaction Problems (CSP)

CSPs focus on finding any solution that satisfies all constraints without optimizing any particular objective. They are the foundation for more complex problem types.

When to Use CSP

  • Finding feasible solutions to complex constraint systems

  • Scheduling problems where any valid schedule is acceptable

  • Configuration problems with multiple requirements

  • Preprocessing to check problem feasibility

Key Characteristics

  • Variables: Decision variables with bounds and types

  • Constraints: Linear and special constraints that must be satisfied

  • No Objective: Focus on feasibility, not optimality

  • Solution: Any point that satisfies all constraints

from problem import OXCSPProblem
from constraints import RelationalOperators

# Create CSP for employee scheduling
csp = OXCSPProblem()

# Variables: work assignments (binary)
days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']
shifts = ['Morning', 'Evening']
employees = ['Alice', 'Bob', 'Carol']

for employee in employees:
    for day in days:
        for shift in shifts:
            csp.create_decision_variable(
                var_name=f"{employee}_{day}_{shift}",
                description=f"{employee} works {shift} on {day}",
                lower_bound=0,
                upper_bound=1,
                variable_type="binary"
            )

# Constraint: Each shift must be covered
for day in days:
    for shift in shifts:
        shift_vars = [
            var.id for var in csp.variables
            if f"{day}_{shift}" in var.name
        ]
        csp.create_constraint(
            variables=shift_vars,
            weights=[1] * len(shift_vars),
            operator=RelationalOperators.GREATER_THAN_EQUAL,
            value=1,
            description=f"Cover {shift} shift on {day}"
        )

# Constraint: No employee works both shifts same day
for employee in employees:
    for day in days:
        morning_var = next(v for v in csp.variables if f"{employee}_{day}_Morning" in v.name)
        evening_var = next(v for v in csp.variables if f"{employee}_{day}_Evening" in v.name)

        csp.create_constraint(
            variables=[morning_var.id, evening_var.id],
            weights=[1, 1],
            operator=RelationalOperators.LESS_THAN_EQUAL,
            value=1,
            description=f"{employee} works at most one shift on {day}"
        )