复合体中的非线性约束
power Nonlinear constraint in cplex
我正在尝试在我的 cplex 代码中实现非线性约束:
forall (j in agent)
pu[j] == pow(W[j],K)*pow(u[j],-K);
其中 pu 和 u 是 float+ 决策向量变量,W 是参数向量,K 是常量。
如何将约束转换为线性约束?
这是代码的其余部分:
int N =3;
range task = 1..N;
range agent = 1..N;
dvar boolean x[task][agent];
dvar float+ u[agent];
dvar float+ pu[agent];
int B[agent] = [9,7,4];
int W[agent] = [2,5,4];
int V[agent] = [1,6,4];
int P[task] = [5,2,1];
int K = 3;
float UV = 10;
dexpr float z = sum(i in task, j in agent) (P[i]*(B[j]+ pu[j]) )*x[i,j];
minimize z;
subject to {
forall (j in agent)
pu[j] == pow(W[j],K)*pow(u[j],-K);
forall (i in task)
sum(j in agent) x[i,j]==1;
forall ( j in agent)
sum(i in task) x[i,j]==1;
sum(j in agent) V[j]*u[j]<= UV;
}
您可以在 CPLEX 中使用 CPOptimizer 并编写
using CP;
int N =3;
range task = 1..N;
range agent = 1..N;
dvar boolean x[task][agent];
int scale=100000;
dvar int+ scaleu[agent];
dexpr float u[j in agent]=scaleu[j]/scale;
int B[agent] = [9,7,4];
int W[agent] = [2,5,4];
int V[agent] = [1,6,4];
int P[task] = [5,2,1];
int K = 3;
float UV = 10;
dexpr float pu[j in agent]=pow(W[j],K)*pow(u[j],-K);;
dexpr float z = sum(i in task, j in agent) (P[i]*(B[j]+ pu[j]) )*x[i,j];
minimize z;
subject to {
//forall (j in agent) pu[j] == pow(W[j],K)*pow(u[j],-K);
forall (i in task) sum(j in agent) x[i,j]==1;
forall ( j in agent) sum(i in task) x[i,j]==1;
sum(j in agent) V[j]*u[j]<= UV;
}
效果很好
我正在尝试在我的 cplex 代码中实现非线性约束:
forall (j in agent)
pu[j] == pow(W[j],K)*pow(u[j],-K);
其中 pu 和 u 是 float+ 决策向量变量,W 是参数向量,K 是常量。 如何将约束转换为线性约束?
这是代码的其余部分:
int N =3;
range task = 1..N;
range agent = 1..N;
dvar boolean x[task][agent];
dvar float+ u[agent];
dvar float+ pu[agent];
int B[agent] = [9,7,4];
int W[agent] = [2,5,4];
int V[agent] = [1,6,4];
int P[task] = [5,2,1];
int K = 3;
float UV = 10;
dexpr float z = sum(i in task, j in agent) (P[i]*(B[j]+ pu[j]) )*x[i,j];
minimize z;
subject to {
forall (j in agent)
pu[j] == pow(W[j],K)*pow(u[j],-K);
forall (i in task)
sum(j in agent) x[i,j]==1;
forall ( j in agent)
sum(i in task) x[i,j]==1;
sum(j in agent) V[j]*u[j]<= UV;
}
您可以在 CPLEX 中使用 CPOptimizer 并编写
using CP;
int N =3;
range task = 1..N;
range agent = 1..N;
dvar boolean x[task][agent];
int scale=100000;
dvar int+ scaleu[agent];
dexpr float u[j in agent]=scaleu[j]/scale;
int B[agent] = [9,7,4];
int W[agent] = [2,5,4];
int V[agent] = [1,6,4];
int P[task] = [5,2,1];
int K = 3;
float UV = 10;
dexpr float pu[j in agent]=pow(W[j],K)*pow(u[j],-K);;
dexpr float z = sum(i in task, j in agent) (P[i]*(B[j]+ pu[j]) )*x[i,j];
minimize z;
subject to {
//forall (j in agent) pu[j] == pow(W[j],K)*pow(u[j],-K);
forall (i in task) sum(j in agent) x[i,j]==1;
forall ( j in agent) sum(i in task) x[i,j]==1;
sum(j in agent) V[j]*u[j]<= UV;
}
效果很好