0
$\begingroup$

Does Mathematica support in Maximize function to put some variables belong to Integers and others to Reals I tried that but I have an error that this not implemented yet is there any way to do that inside the maximize Function??

I Tried a simple Code to Clarify my question that is

Maximize[{x + y + z, x <= 10, y <= 12.5, 
  z <= 100}, {{x, z} ∈ Integers, {y} ∈ Reals}]

it is ok and gives the output

{122.5, {x -> 10, z -> 100, y -> 12.5}}

I tried in my original problem which is long and tried the same syntax as follows

{{W, H, x1, y1, x2, y2, x3, y3, x4, y4} ∈ 
  Reals, {x12, y12, x13, y13, x14, y14, x23, y23, x24, y24, x34, y34, 
   z1, z2, z3, z4} ∈ Integers }

but it gives this error

Minimize::mixdom: Exact optimization with mixed real and integer variables is not yet implemented

there is no difference? why one is ok and one gives error

$\endgroup$
2
  • $\begingroup$ Please edit your question to add the code you've tried. $\endgroup$
    – creidhne
    Aug 11, 2021 at 22:21
  • $\begingroup$ From Mathematica output (v. 11.3): Maximize::mixdom: Exact optimization with mixed real and integer variables is not yet implemented. $\endgroup$ Aug 12, 2021 at 2:04

2 Answers 2

2
$\begingroup$

If you restrict the ranges of x and y, you can get the desired result with Maximize with conditions x==Floor[x] or x==IntegerPart[x] or .....

Do first Maximize[{x + y + z, x <= 10, y <= 12.5, z <= 100}, {x, y, z}, Reals] for Reals to get an impression how to restrict x and y.

Maximize[{x + y + z, 0 < x <= 10, 0 < y <= 125/10, z <= 100, 
           x==Floor[x] , y==Floor[y] }, {x, y, z}, Reals]

(*   {122, {x -> 10, y -> 12, z -> 100}}   *)

NMaximize[{x + y + z, x <= 10, y <= 12.5, z <= 100, 
    x \[Element] Integers, y \[Element] Integers, 
    z \[Element] Reals}, {x, y, z}]

(*   {122., {x -> 10, y -> 12, z -> 100.}}   *)
$\endgroup$
2
$\begingroup$

With exact input (125/10 instead of 12.5), the first call fails:

Maximize[
{x + y + z, x <= 10, y <= 125/10, z <= 100},
{{x, z} \[Element] Integers, {y} \[Element] Reals}]

Maximize::mixdom: Exact optimization with mixed real and integer variables is not yet implemented.

With inexact input, NMaximize is called (see “Details” in documentation for Maximize):

Trace[
 Maximize[
  {x + y + z, x <= 10, y <= 12.5, z <= 100}, 
  {{x, z} \[Element] Integers, {y} \[Element] Reals}],
 _NMaximize,
 TraceInternal -> True
 ]

Mixed domain are not implemented for Maximize, but they are for NMaximize.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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