Xpress Mosel Programming help. Watch

cmcb
Badges: 0
Rep:
?
#1
Report Thread starter 4 years ago
#1
Hey, I have constructed a programme to solve a linear programme using Xpress, but do not know how to set limits on the solutions, for example I am only allowed a maximum of 3 of the first product, 4 of the second product etc.

The code at the moment looks like:

model one
uses "mmxprs"

declarations
R = 1..15
TIME, PRICE, UNITS, LIMIT: array(R) of real
x: array(R) of mpvar
end-declarations

TIME :: [8, 6, 6, 6, 7, 4, 3, 3, 5, 7, 9, 8, 8, 9, 9]
PRICE :: [2.67, 2.61, 1.66, 3.66, 2.72, 3.10, 3.00, 3.30, 2.10, 1.85, 2.18, 2.24, 2.18, 3.25, 3.50]
UNITS :: [1.2, 1.0, 1.0, 1.1, 0.9, 1.3, 1.1, 1.2, 1.0, 1.4, 1.0, 1.1, 1.0, 1.2, 1.0]



sum(i in R) TIME(i)*x(i) <= 60
sum(i in R) PRICE(i)*x(i) <= 35
forall(i in R) x(i) is_integer

maximise(sum(i in R) UNITS(i)*x(i))
writeln("Units: ", getobjval)

end-model

Does anybody know how to set restrictions? Thanks in advance
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

University open days

  • Solent University
    Postgraduate and Professional Open Evenings Postgraduate
    Mon, 25 Mar '19
  • Cardiff University
    Undergraduate Open Day Undergraduate
    Wed, 27 Mar '19
  • University of Portsmouth
    Postgraduate and Part-Time Open Evenings Postgraduate
    Wed, 27 Mar '19

Where do you need more help?

Which Uni should I go to? (147)
18.51%
How successful will I become if I take my planned subjects? (78)
9.82%
How happy will I be if I take this career? (135)
17%
How do I achieve my dream Uni placement? (113)
14.23%
What should I study to achieve my dream career? (77)
9.7%
How can I be the best version of myself? (244)
30.73%

Watched Threads

View All