The OPTMODEL Procedure

Model Update

The PROC OPTMODEL modeling language provides several means of modifying a model after it is first specified. You can change the parameter values of the model. You can add new model components. The FIX and UNFIX statements can fix variables to specified values or rescind previously fixed values. The DROP and RESTORE statements can deactivate and reactivate constraints. See also the section Multiple Subproblems for information on how to maintain multiple models.

To illustrate how these statements work, reconsider the following example from the section Constraints:

proc optmodel;
   var x, y;
   min r = x**2 + y**2;
   con c: x+y >= 1;
   solve;
   print x y;

As described previously, the solver finds the optimal point x = y = 0.5 with r = 0.5. You can see the effect of the constraint c on the solution by temporarily removing it. You can add the following statements:

   drop c;
   solve;
   print x y;

This change produces the output in Figure 78.

Figure 78: Solution with Dropped Constraint

Problem Summary
Objective SenseMinimization
Objective Functionr
Objective TypeLinear Least Squares
  
Number of Variables2
Bounded Above0
Bounded Below0
Bounded Below and Above0
Free2
Fixed0
  
Number of Constraints0
  
Constraint Coefficients0
  
Least Squares Matrix Rows2

Solution Summary
SolverQP
AlgorithmInterior Point
Objective Functionr
Solution StatusOptimal
Objective Value0
  
Primal Infeasibility0
Dual Infeasibility0
Bound Infeasibility0
Duality Gap0
Complementarity0
  
Iterations0
Presolve Time0.00
Solution Time0.00

xy
00


The optimal point is x equals y equals 0, as expected.

You can restore the constraint c with the RESTORE statement, and you can also investigate the effect of forcing the value of variable x to 0.3. This requires the following statements:

   restore c;
   fix x=0.3;
   solve;
   print x y c.dual;

This produces the output in Figure 79.

Figure 79: Solution with Fixed Variable

Problem Summary
Objective SenseMinimization
Objective Functionr
Objective TypeLinear Least Squares
  
Number of Variables2
Bounded Above0
Bounded Below0
Bounded Below and Above0
Free1
Fixed1
  
Number of Constraints1
Linear LE (<=)0
Linear EQ (=)0
Linear GE (>=)1
Linear Range0
  
Constraint Coefficients2
  
Least Squares Matrix Rows1

Solution Summary
SolverQP
AlgorithmInterior Point
Objective Functionr
Solution StatusOptimal
Objective Value0.58
  
Primal Infeasibility0
Dual Infeasibility0
Bound Infeasibility0
Duality Gap0
Complementarity0
  
Iterations0
Presolve Time0.00
Solution Time0.00

xyc.DUAL
0.30.71.4


The variable x still has the value that was defined in the FIX statement. The objective value has increased by 0.08 from its constrained optimum 0.5 (see Figure 55). The constraint c is active, as confirmed by the positive dual value.

You can return to the original optimization problem by allowing the solver to vary variable x with the UNFIX statement, as follows:

   unfix x;
   solve;
   print x y c.dual;

This produces the output in Figure 80. The model was returned to its original conditions.

Figure 80: Solution with Original Model

Problem Summary
Objective SenseMinimization
Objective Functionr
Objective TypeLinear Least Squares
  
Number of Variables2
Bounded Above0
Bounded Below0
Bounded Below and Above0
Free2
Fixed0
  
Number of Constraints1
Linear LE (<=)0
Linear EQ (=)0
Linear GE (>=)1
Linear Range0
  
Constraint Coefficients2
  
Least Squares Matrix Rows2

Solution Summary
SolverQP
AlgorithmInterior Point
Objective Functionr
Solution StatusOptimal
Objective Value0.5000000365
  
Primal Infeasibility0
Dual Infeasibility2.3570225E-9
Bound Infeasibility0
Duality Gap2.5463909E-8
Complementarity0
  
Iterations5
Presolve Time0.00
Solution Time0.00

xyc.DUAL
0.50.51


Last updated: March 04, 2026