12.07.2015 Views

ILOG OPL Development Studio Language Reference Manual

ILOG OPL Development Studio Language Reference Manual

ILOG OPL Development Studio Language Reference Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Assertions<strong>OPL</strong> provides assertions to verify the consistency of the model data. This functionality enablesyou to avoid wrong results due to incorrect input data. In their simplest form, assertions aresimply Boolean expressions that must be true; otherwise, they raise an execution error. Forinstance, it is common in some transportation problems to require that the demand matchesthe supply. The declarationint demand[Customers] = ...;int supply[Suppliers] = ...;assert sum(s in Suppliers) supply[s] == sum(c in Customers) demand[c];makes sure that the total supply by the suppliers meets the total demand from the customers.This assertion can be generalized to the case of multiple products, as inint demand[Customers] [Products] = ...;int supply[Suppliers] [Products] = ...;assertforall(p in Products)sum(s in Suppliers) supply[s][p] == sum(c in Customers) demand[c][p];This assertion verifies that the total supply meets the total demand for each product. The useof assertions is highly recommended, since they make it possible to detect errors in the datainput early, avoiding tedious inspection of the model data and results.Assertions can be labeled. See Labeled assert statements.I L O G O P L D E V E L O P M E N T S T U D I O L A N G U A G ER E F E R E N C E M A N U A L75

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!