Forum Discussion

FICO's avatar
FICO
Community Manager
6 years ago

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 can stop spamming this community with a new question every day, but I've encountered a new one and can't think around it no matter how hard I try. I must be missing something very simple.

In the attached problem, I simply want to minimize the SUM of the SQUARE of my DECISION_VARIABLE * LARGE_CONSTANT. The reason for SQUARE is to incentivize the solver to spread the decision variable around equally. I express this as:

"Min_Panicking:= sum(s in SITE) ((c_min_panic(s) * MIN_PANIC_PENALTY)*SQUARE*2)"

"Max_Panicking:= sum(s in SITE) ((c_max_panic(s) * MAX_PANIC_PENALTY)*SQUARE*2)"

However, this gives error: Mosel: E-101...Incompatible types for operator (`mpvar' *SQUARE* `integer' not defined).

Removing the square makes the problem work fine.

I am shocked why I can't square this? In fact, I see examples in the documentation that look like successful attempts to square the objective function. For example, Page 186 of the User Guide seems to do it:

"! Objective: minimise the total squared distance between all points

TotDist:= sum(i,j in RN | i<j)...*omitted since special characters not allowed*

What am I missing!! Tearing my hair out  Thank you...

3 Replies

  • FICO's avatar
    FICO
    Community Manager

    The example in the Mosel User Guide that your are referring to shows how to formulate a quadratic programming problem with Mosel: you need to load the module 'mmnl' in addition to the solver module 'mmxprs' in order to extend the constraint handling capability of the Mosel language to include quadratic expressions, so

    uses "mmxprs", "mmnl"

    as shown in the example. Alternatively, you can use the Xpress Nonlinear module:

    uses "mmxnlp"

    that will automatically select the solver that is best suited for the problem that your are formulating.

  • FICO's avatar
    FICO
    Community Manager

    Ah, yes, makes sense! I will look into this thank you.