Hi, I am new to AMPL and have started the AMPL handbook and just finished the first chapter: Production Models - Maximizing Profits. I was doing the exercises and was stumped when I came to the last one (1-6), i.e. the oil refining process one.
I think itâs probably due to the way I am entering the data for Ujk, i.e. âmaximum allowed units of attribute k per barrel of final product jâ. In sub-section (c) of the exercise, it gives the values for the attribute limits and also says this: âLimits left blank, such as density for gasoline, are irrelevant and may be set to some relatively large number.â. I tried giving Infinity, 99999, etc. for them, but the error persists.
For the limits left blank, a large value like 99999 should work. The error might be somewhere else in the data file â can you reply with the data file attached? (Use the âUploadâ icon.)
All of the blank entries in the max_attrib_per_product_barrel table should be large positive numbers. You should double-check the other data as well, to be sure it all matches whatâs shown in the exercise.
Also youâll need to study the constraints to be sure they are saying what you want. AMPLâs âexpandâ command can be useful for examining the constraints that are being generated. For example, you have the following for constraint Attributes_Intermediates, which does not seem right:
ampl: expand Attributes_Intermediates;
subject to Attributes_Intermediates['PG','vap']:
-12.2*Barrels_Product_Made['PG'] <= -233.61;
subject to Attributes_Intermediates['PG','oct']:
90*Barrels_Product_Made['PG'] <= 303;
subject to Attributes_Intermediates['PG','den']:
-999*Barrels_Product_Made['PG'] <= -1202;
subject to Attributes_Intermediates['PG','sul']:
-999*Barrels_Product_Made['PG'] <= -5.862;
subject to Attributes_Intermediates['RG','vap']:
-12.7*Barrels_Product_Made['RG'] <= -233.61;
subject to Attributes_Intermediates['RG','oct']:
86*Barrels_Product_Made['RG'] <= 303;
.......
It may look strange to have, for example, -12.2*Barrels_Product_Made['PG']<=-233.61, but thatâs just the same as 12.2*Barrels_Product_Made['PG']>=233.61.
Thank you so much for this! I was still in the first chapter and hadnât come across expand yet.
As you rightly pointed out, there was an error in defining the last constraint. It was supposed to be r[i, k] * X[i, j] on the LHS. But I had forgotten to multiply the second part.
I updated the constraint now to this:
# For each product, the total attributes contributed by all intermediates must not exceed the total allowed
subject to Attributes_Intermediates {j in PRODUCT, k in ATTRIBUTE}:
sum {i in INTERMEDIATE} attributes_per_barrel[i, k] * Barrels_Intermediate_For_Product[i, j] <= max_attrib_per_product_barrel[j, k] * Barrels_Product_Made[j];