TypeScript API Reference
This is the auto-generated API reference for the OptalCP TypeScript/JavaScript library.
New to OptalCP? Start with the Tutorial for a hands-on introduction, or Quick Start for installation.
Key Classes
| Class | Description |
|---|---|
| Model | Central class for building optimization models. Creates variables, constraints, and objectives. |
| IntervalVar | Interval (task) variable for scheduling. Has start, end, length, and optional presence. |
| IntVar | Integer decision variable with a domain. |
| SequenceVar | Ordered sequence of intervals for routing and sequencing problems. |
| Solver | Advanced solving with callbacks for solutions, bounds, and logs. |
| Solution | Access to variable values after solving. |
Common Entry Points
Creating a Model
import * as CP from "@scheduleopt/optalcp";
const model = new CP.Model();
See Model for all factory methods: intVar, intervalVar, sequenceVar.
Solving
- Simple: Model.solve(params) - returns SolveResult
- Advanced: Solver class with onSolution, onLog callbacks
Constraints
Most constraints are methods on Model:
- Scheduling: noOverlap, alternative, span
- Precedence: endBeforeStart, startAtEnd, etc.
- Resources: pulse, stepAtStart, le
- Forbid: forbidStart, forbidEnd, forbidExtent
Expressions
Expressions use a fluent API. See IntExpr for arithmetic methods (.plus(), .times(), .le()) and BoolExpr for boolean logic (.and(), .or(), .not()).
Interval expressions: start(), end(), length(), presence().
Parameters
Parameters controls solver behavior: timeLimit, nbWorkers, searchType, logLevel, etc.
Parse from command line: parseParameters, parseKnownParameters.
Solution Access
Solution methods: getStart, getEnd, getValue, isAbsent.
Model Export
- toJSON / fromJSON - JSON serialization
- toText - Human-readable format
- toJS - JavaScript code generation
Benchmarking
benchmark function with BenchmarkParameters.
Learn More
- Tutorial - Step-by-step guide building a complete scheduling model
- Modeling Reference - Detailed concept explanations
- Solving Guide - Understanding solve results and parameters
- Examples - Complete benchmark implementations