Forum Discussion
FICO
9 years agoCommunity Manager
MPVAR mod integer
Hi all,
I'm wondering is it possible to modulo an mpvar. I have a set of mpvars Xs which are binary and I want to have Sum(i in set) Xi mod 2 = 0 (in other words), the sum of the binary variabl...
FICO
9 years agoCommunity Manager
Enclosed you find a full example (just for the sake of completeness):
model Modulo options noimplicit, keepassert uses "mmxprs"; declarations I = 1..3 x: array (I) of mpvar y: mpvar obj: linctr end-declarations procedure createModel ! all x variables are binary forall (i in I) do x(i) is_binary end-do ! y is an auxiliary integer variable y is_integer ! (sum (i in I) x(i)) mod 2 = 0 sum(i in I) x(i) = 2 * y ! objective: maximize sum of x(i) obj := sum(i in I) x(i) end-procedure procedure showSolution writeln("(sum(i in I) x(i)) mod 2 = ", (sum(i in I) x(i).sol) mod 2) forall (i in I) do writeln("x(",i,") = ", x(i).sol) end-do end-procedure procedure main createModel maximize(obj) showSolution end-procedure main end-modelRelated Content
Related Content
Mosel: E-101: Incompatible types for operator (`mpvar' *SQUARE* `integer' not defined).
Please note syntax is weird in this post because this forum prohibits special characters. I've thus replaced the arrow/hat/square operator with *SQUARE* throughout my post... Hi Again! I am hoping I...6 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum3 unread comments3 unread0Views0likes3CommentsError 101 Incompatible types for operator ('set of integer' * 'mpvar' not defined)
I'm trying to solve a VRP-model and I receive "Error 101 Incompatible types for operator ('set of integer' * 'mpvar' not defined)" when I try to run, and I have no idea how to solve this. The error is...8 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum5 unread comments5 unread0Views0likes5Commentsmpvar variables and identifiers
Hi, Is it possible to sum a mpvar and an integer variable into an index of another mpvar ? Example: declarations x: array(1..10,1..5) of mpvar y: mpvar end-declarations y is_integer y <= 2 fo...5 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum5 unread comments5 unread0Views0likes5Comments