如何在CPLEX中运行功能? [英] How can I do functions in CPLEX?
本文介绍了如何在CPLEX中运行功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试查找有关带有功能的CPLEX的小型示例.错误的示例此处怎么不做.如何在CPLEX中定义功能?
I am trying to find small-working-example about CPLEX with functions. Bad example here how not do things. How are functions defined in CPLEX?
P.s.我正在为线性优化课程2.3140做过提交的工作,此处 ,在阿尔托大学.
P.s. I am doing already submitted work for the linear-optimization -course 2.3140 here, in Aalto University.
推荐答案
您将其编写为数学问题,但索引越界出错.
You write it like a mathematical problem, you had an error with index-out-of-bound.
// Decision variables
dvar float+ z[0..4];
dvar float a[0..4];
dvar float+ x[0..5];
dvar float+ v[0..5];
minimize sum(myZ in 0..4) z[myZ];
subject to {
startX: x[0]==0;
startV: v[0]==0;
endX: x[4]==1;
x[5]==1;
endV: v[4]==0;
v[5]==0;
forall(t in 0..4){
a[t]<=z[t];
-a[t]<=z[t];
x[t+1]==x[t]+v[t];
v[t+1]==v[t]+a[t];
}
}
这是解决方案:
// solution (optimal) with objective 0.666666666666667
// Quality There are no bound infeasibilities.
// There are no reduced-cost infeasibilities.
// Maximum Ax-b residual = 1.11022e-016
// Maximum c-B'pi residual = 1.11022e-016
// Maximum |x| = 1
// Maximum |slack| = 0.666667
// Maximum |pi| = 1.66667
// Maximum |red-cost| = 1
// Condition number of unscaled basis = 2.1e+001
//
z = [0.33333
0 0 0.33333 0];
x = [0 0 0.33333 0.66667 1 1];
v = [0 0.33333 0.33333 0.33333 0 0];
a = [0.33333 0 0 -0.33333 0];
相关
IBM有一些帮助 查看全文