當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Matlab AMPL ConstraintInstance.restore用法及代碼示例

classmethod ConstraintInstance.restore()

用法

restore

說明

restore 恢複這個約束實例

示例

創建一個約束 c,獲取一個實例 (c2),刪除它並恢複它,求解並顯示相關變量的值。

ampl.eval('var x{1..3}<=4;');
ampl.eval('maximize z: sum{i in 1..3} x[i];');
ampl.eval('c {i in 1..3} : x[i] <= i;');
c2 = ampl.getConstraint('c').get(2);
x = ampl.getVariable('x');

c2.drop;
ampl.solve;
x.display

c2.restore;
ampl.solve;
x.display

給出:

x [*] :=
1  1
2  4
3  3
;


ans =

x [*] :=
1  1
2  2
3  3
;

相關用法


注:本文由純淨天空篩選整理自ampl.com大神的英文原創作品 restore。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。