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
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

University open days

  • University of Surrey
    Postgraduate Open Afternoon Postgraduate
    Wed, 23 Oct '19
  • University of Bristol
    Undergraduate Open Afternoon Undergraduate
    Wed, 23 Oct '19
  • University of Exeter
    Undergraduate Open Day - Penryn Campus Undergraduate
    Wed, 23 Oct '19

Would you turn to a teacher if you were being bullied?

Yes (11)
23.4%
No (36)
76.6%

Watched Threads

View All