classmethod Constraint.getValues()
用法
df = c.getValues()
df = c.getValues(suffixes)
說明
這些函數返回一個數據幀,其中包含約束的所有指定值,與底層 AMPL 分離。要訪問數據,請參閱
。DataFrame
c.getValues()
獲取 AMPL 值(相當於後綴 dual
)
c.getValues(suffixes)
允許用戶指定要獲取的後綴
輸入參數
suffixes
指定要獲取的約束後綴的字符串(請參閱AMPL 內置 suffixes)。
**輸出參數**
df
包含約束的所有指定值及其索引的 DataFrame
示例
在 AMPL 中創建一個代數變量,然後獲取數據幀中所有實例的主體以及下限和上限。
ampl.eval('var x{1..5} <= 10;');
ampl.eval('maximize z : sum{i in 1..5} x[i];');
ampl.eval('c{i in 1..5}: -i <= x[i] <= i;');
c = ampl.getConstraint('c');
ampl.solve;
df = c.getValues('body', 'lb', 'ub')
給出:
i in 1 .. 5 | body lb ub
1.0 | 1.0 -1.0 1.0
2.0 | 2.0 -2.0 2.0
3.0 | 3.0 -3.0 3.0
4.0 | 4.0 -4.0 4.0
5.0 | 5.0 -5.0 5.0
相關用法
- Matlab AMPL Constraint.get用法及代碼示例
- Matlab AMPL Constraint.body用法及代碼示例
- Matlab AMPL Constraint.lb用法及代碼示例
- Matlab AMPL Constraint.setDual用法及代碼示例
- Matlab AMPL Constraint.drop用法及代碼示例
- Matlab AMPL Constraint.restore用法及代碼示例
- Matlab AMPL Constraint.ub用法及代碼示例
- Matlab AMPL Constraint.dual用法及代碼示例
- Matlab AMPL ConstraintInstance.lb用法及代碼示例
- Matlab AMPL ConstraintInstance.ub用法及代碼示例
- Matlab AMPL ConstraintInstance.body用法及代碼示例
- Matlab AMPL ConstraintInstance.restore用法及代碼示例
- Matlab AMPL ConstraintInstance.setDual用法及代碼示例
- Matlab AMPL ConstraintInstance.drop用法及代碼示例
- Matlab AMPL ConstraintInstance.dual用法及代碼示例
- Matlab AMPL VariableInstance.ub用法及代碼示例
- Matlab AMPL Parameter.hasDefault用法及代碼示例
- Matlab AMPL SetInstance.contains用法及代碼示例
- Matlab AMPL Variable.getIntegrality用法及代碼示例
- Matlab AMPL DataFrame.setMatrix用法及代碼示例
注:本文由純淨天空篩選整理自ampl.com大神的英文原創作品 getValues。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。