Problems
In Mosel terms, a problem is a container holding various attributes and entities. The nature of the information stored is characterised by a problem type. The core system of Mosel provides the mpproblem problem type for the representation of mathematical programming problems with linear constraints. Other types may be published by modules either as entirely new problem types or as problem type extensions. An extension adds extra functionality or properties to an existing type; for instance, mpproblem.xprs provided by the module mmxprs adds support for solving mpproblem problems while the type mpproblem.nl of mmnl makes it possible to include non-linear constraints in an mpproblem.
When the execution of the model starts, an instance of each of the available problem types is created: this main problem constitutes the default problem context. As a consequence, all problem related operations (e.g., add constraints, solve...) refer to this context. Further problem instances may be declared just like any other symbol using a declarations section. The specification of a problem type (that is used as an elementary type in a declaration) has two forms:
problem_type or problem_type1 and problem_type2 [and problem_typen ...] |
where problem_type* are problem type names. The second syntax allows to define a problem instance that refers to several problem types: this can be useful if a particular problem consists in the combination of several problem types. Note also that the main problem can be seen as an instance of the combination of all available problem types.
The with construct can be used to switch to a different problem context for the duration of a block of instructions. The general form of this construct is:
with prob do Statement [ Statement ...] end-do |
where prob is a problem reference or a problem type specification. In the first case the referenced problem is selected, in the second case, a new problem instance is created for the duration of the block (i.e., it is released after the block has been processed). Both statements and declaration blocks as well as other with constructs may be included in this section: they are all executed in the context of the selected problem.
declarations p1,p2:mpproblem p3:mpproblem and mypb ! assuming 'mypb' is a problem type PT=mpproblem and mypb ! user defined problem type a:array(1..10) of PT x,y:mpvar end-declarations with p1 do x+y>=0 end-do with p2 do x-y=1 end-do
Some problem types support assignment (operator :=) and additive assignment (operator +=). These operators can be used between objects of same type but also when the right parameter of the operator is a component of the assigned object. For instance, assuming the declarations of the previous example we could state p3:=p2 meaning that the mpproblem part of p3 must be replaced by a copy of p2, the mypb part of p3 remaining unchanged. From the same context, the assignment p2:=p3 produces a compilation error.
The mpproblem type
An mpproblem instance basically consists in a set of linear constraints (the decision variables defined anywhere in a model are shared by all problems). A constraint is incorporated into a problem when it is expressed, so having the declaration of a linctr identifier in the context of a problem is not sufficient to attach it to this problem. The association will occur when the symbol is assigned its first value. Afterwards, the constraint will remain part of the same problem even if it is altered from within the context of another problem (a constraint cannot belong to several problems at the same time).
with p1 do C1:=x+y+z>=0 x is_integer end-do with p2 do 2*x-3*z=0 ! here we state constraints of p2 ... minimize(z) C1+= x.sol*z.sol end-do
In the example above, the constraint C1 is part of problem p1. From the context of a second problem p2 the constraint C1 is modified using solution information of p2: this change affects only the first problem since the constraint does not belong to the current context. Note that since is_integer is a (unary) constraint, the decision variable x is integer for problem p1 but it is a continuous variable in p2.
When a problem is released or reset (see reset), all its constraints are detached. Constraints which are not referenced (anonymous constraints) are released at the same time, named constraints however are not freed, they become available to be associated to some other problem.
with mpproblem do C1:=x+y+z>=0 ! (1) x-2*y=10 ! (2) x is_integer ! (3) end-do with p1 do C1 end-do
In this example, at the end of the first with block, the local problem is released. As a consequence the constraint C1 is detached from this problem (but remains unchanged) and the 2 other constraints are freed. The following statements add C1 to the problem p1.
The type mpproblem supports both assignment (operator :=) and additive assignment (operator +=).
© 2001-2022 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.