0
$\begingroup$

I'm attempting to utilize the ArgMax function, but am receiving the error "ArgMax::vdom: Variable domain ... should be either Reals or Integers."

ArgMax[{objective, cons == 1}, assign, {assign} ∈ {0, 1}]

As a quick overview, we have edges denoted $e_{i,j}$ in $\mathbb{R}^3$, and we want to assign an integer value of 0 or 1 to each such that their sum is at most 1 for each set of edges. So, objective is defined as a set of sets as summations with constant coefficients $objective = \{\{3e_{\{4, 2, -2\}, \{1, 3, 1\}\}} + 2e_{\{4, 2, -2\}, \{2, 1, 1\}\}}\}, \{7e_{\{5, 3, -1\}, \{-2, 6, -1\}\}} + 6e_{\{5, 3, -1\}, \{-1, 4, -2\}\}}\}\}$

We also have a set of sets for constraints defined as $cons = \{\{e_{\{\{4, 2, -2\}, \{1, 3, 1\}\}} + e_{\{\{4, 2, -2\}, \{2, 1, 1\}\}}\}, \{e_{\{\{5, 3, -1\}, \{-2, 6, -1\}\}} + e_{\{\{5, 3, -1\}, \{-1, 4, -2\}\}}\}\}$.

Lastly, we have the variables defined in $assign = \{e_{\{\{4, 2, -2\}, \{1, 3, 1\}\}}, e_{\{\{4, 2, -2\}, \{2, 1, 1\}\}}, e_{\{\{5, 3, -1\}, \{-2, 6, -1\}\}}, e_{\{5, 3, -1\}, \{-1, 4, -2\}\}}\}$.

I'm new to Mathematica, so this may be a trivial fix, but if anyone can point out my error, I would greatly appreciate it.

$\endgroup$
4
  • 1
    $\begingroup$ Please include expressions for objective in Mathematica format. Is assign a variable? {assign} ∈ {0, 1} is not a legitimate domain for ArgMax Please read the documentation for this function. $\endgroup$
    – bbgodfrey
    Jun 9 at 15:27
  • $\begingroup$ Apologies, I'm not sure how you want me to alter the format. Also, assign is a set containing the variables. $\endgroup$ Jun 9 at 15:44
  • 2
    $\begingroup$ You'll generally get better answers on this site if you provide all of the code that you are using, rather than describing what the variables are. Can you include the actual code you're using to define objective, cons, and assign? $\endgroup$ Jun 9 at 15:47
  • $\begingroup$ There is a large amount of code before this (300-500 lines). I tried to include a snippet of what these sets look like. $\endgroup$ Jun 9 at 16:10
3
$\begingroup$

The error means what it says: the domain of restriction must be either Reals or Integers. But you can also add additional inequalities in your constraints to ensure that the variables are either 0 or 1. Here's an example of how to do this:

ArgMax[{3 x + 5 y + z, 
       (x + y + z == 1 && 0 <= x <= 1 && 0 <= y <= 1 && 0 <= z <= 1)},
       {x, y, z}, Integers]

(* {0, 1, 0} *)
$\endgroup$
4
  • $\begingroup$ Thank you, this was helpful. Is there notation that would allow me to define these restrictions over each element in a set, or must this be done individually? $\endgroup$ Jun 9 at 15:42
  • $\begingroup$ No problem! I hope you stick around the site and ask & answer more questions as time goes on. You can "accept" an answer to your question by clicking the check mark to the right of it. (I would wait 24–48 hours before accepting an answer, to give time for more thorough, better answers to be written and posted..) $\endgroup$ Jun 9 at 15:45
  • $\begingroup$ @AStrugglingProgrammer - And @@ Thread[0 <= varList <= 1] where varList can have as many variables as you need. $\endgroup$
    – Bob Hanlon
    Jun 9 at 22:10
  • $\begingroup$ Tremendous. Thank you for your help. $\endgroup$ Jun 10 at 14:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.