Writing a good English problem statement
The LLM can only encode what you tell it. A short guide to describing a discrete constraint problem so Savanty translates it faithfully the first time.
Savanty’s LLM is a translator, and translators can only render what they are given. A vague description produces a vague encoding; a precise one produces a precise encoding. The good news is that “precise” here does not mean formal — it means complete and unambiguous English.
Name the entities and their counts
State exactly what is being decided and how many of each thing there are. “Schedule some nurses” is under-specified; “Schedule 4 nurses (Alice, Bob, Carol, Dave) across 5 days” gives the generator concrete domains to work with. Every decision variable needs a finite domain, so the counts are load-bearing.
State every requirement as a rule
Each requirement becomes an integrity constraint. Phrase them as hard rules the solution must never violate:
- “Each shift needs exactly one nurse.”
- “No nurse works two shifts on the same day.”
- “Alice cannot work evenings.”
If a requirement is soft (“prefer to balance the workload”), say so — that becomes an optimization directive rather than a hard constraint.
Distinguish “must” from “prefer”
A hard constraint can make a problem UNSAT; a preference cannot. If you mark a genuine preference as a hard rule, Savanty may report faithful infeasibility when a good-enough answer existed. Reserve hard rules for things that are truly non-negotiable.
Let the gap check do its job
Savanty runs a gap-identification pass before generating code. If you leave out a count or an entity, it will ask. Answer through additional_info (Python), a follow-up on the CLI, or the additional_info field over REST. This is cheaper than debugging a wrong encoding later.
Trust the suitability check
If your problem is continuous (“minimize cost as a smooth function of quantity”), statistical, or streaming, the first LLM call will return not_suitable=True with a suggested_tool. That is not a failure — it is Savanty refusing to produce nonsense. Reach for cvxpy, scipy, sklearn, or pandas as suggested.
Once your statement names the entities, their finite domains, and every hard rule, translation usually succeeds on the first pass — and when it does not, the self-repair loop takes over.
Frequently asked questions
What if I leave out a constraint?
Savanty's gap-identification step surfaces missing entities and counts as clarifying questions before generating code. But it cannot invent a policy you never mentioned — if a rule matters, state it.
Should I write any ASP myself?
No. Describe the problem in English. If you already know ASP you can read result.asp_code to verify the encoding, but writing it is not required.