ampl

if condition in ampl

你说的曾经没有我的故事 提交于 2019-11-29 18:00:28
I am new in ampl and I want to use if condition in ampl with the following information: I have a binary variable X[p,r], where {p in P, r in R}. Now I want to make a new constraint such that the variable R[p,r] is used where X[p,r]=0. I do not know how I can write it or even if the ampl can handle it or not, I tried the following constraint but they did not work: s.t. a1{r in R, p in P and X[p,r]=0}: s.t. a2{r in R p in P and X[p,r]=0}; s.t. a2{r in R ,p in P, and X[p,r]=0}; s.t. a2{r in R, p in P: and X[p,r]=0}; You cannot include a decision variable in the "for all" part of the constraint

if condition in ampl

断了今生、忘了曾经 提交于 2019-11-28 11:39:54
问题 I am new in ampl and I want to use if condition in ampl with the following information: I have a binary variable X[p,r], where {p in P, r in R}. Now I want to make a new constraint such that the variable R[p,r] is used where X[p,r]=0. I do not know how I can write it or even if the ampl can handle it or not, I tried the following constraint but they did not work: s.t. a1{r in R, p in P and X[p,r]=0}: s.t. a2{r in R p in P and X[p,r]=0}; s.t. a2{r in R ,p in P, and X[p,r]=0}; s.t. a2{r in R, p