cmcb
Badges: 0
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#1
Report Thread starter 6 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
Back
to top
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

How would you describe the quality of the digital skills you're taught at school?

Excellent (39)
9.68%
Okay (119)
29.53%
A bit lacking (153)
37.97%
Not good at all (92)
22.83%

Watched Threads

View All