Hi,
I downloaded a 30 days test version of AMPL several days ago and tried to run
a toy example on stochastic linear program.
However, there always exists an error: 'fortmp' solver not found.
I am sure that I install all the components of AMPL, including fortmp and fortsp.
Please help me to see what the problem is?
Thank you so much!
Here is the error feedback and the codes of the toy example:
Error notice:
=====================================================================================================
error: 'fortmp' solver not found
.\test2.sampl:7:1: Error: java.io.FileNotFoundException: .\ampl6643809094688132857.sol (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sampl.lang.SolutionReader.read(SolutionReader.java:79)
at sampl.lang.SMPSConnection.readSolution(SMPSConnection.java:657)
at sampl.lang.SAMPL.solve(SAMPL.java:617)
at Block11.execute(Unknown Source)
at sampl.codegen.Interpreter.runLastBlock(Interpreter.java:44)
at sampl.codegen.Interpreter.onTopLevelStmt(Interpreter.java:106)
at sampl.sema.Sema.onTopLevelStmt(Sema.java:1348)
at sampl.parser.Parser.parse(Parser.java:2394)
at sampl.sema.Sema.onIncludeStmt(Sema.java:1472)
at sampl.parser.Parser.parseIncludeStmt(Parser.java:1778)
at sampl.parser.Parser.parse(Parser.java:2378)
at sampl.lang.Translator.run(Translator.java:160)
at sampl.App.main(App.java:89)
=====================================================================================================
test2.sampl:
# Read the model and data.
model farmer.mod;
data farmer.dat;
# Set options.
option solver fortsp;
# Instantiate and solve the problem.
solve;
# Print the results.
print 'Optimal value =', profit;
print;
print 'First-stage solution:';
print {c in Crops}: 'area[', c, '] =', area[c], '\';
print 'totalArea =', totalArea.body;
farmer.mod:
set Crops;
scenarioset Scenarios;
probability P{Scenarios};
tree Tree := twostage;
param TotalArea; # acre
random param Yield{Crops, Scenarios}; # T/acre
param PlantingCost{Crops}; # $/acre
param SellingPrice{Crops}; # $/T
param ExcessSellingPrice; # $/T
param PurchasePrice{Crops}; # $/T
param MinRequirement{Crops}; # T
param BeetsQuota; # T
# Area in acres devoted to crop c
var area{c in Crops} >= 0;
# Tons of crop c sold (at favourable price in case of beets)
# under scenario s
var sell{c in Crops, s in Scenarios} >= 0, suffix stage 2;
# Tons of sugar beets sold in excess of the quota under
# scenario s
var sellExcess{s in Scenarios} >= 0, suffix stage 2;
# Tons of crop c bought under scenario s
var buy{c in Crops, s in Scenarios} >= 0, suffix stage 2;
maximize profit: sum{s in Scenarios} P[s] * (
ExcessSellingPrice * sellExcess[s] +
sum{c in Crops} (SellingPrice[c] * sell[c, s] - PurchasePrice[c] * buy[c, s]) -
sum{c in Crops} PlantingCost[c] * area[c]);
s.t. totalArea: sum {c in Crops} area[c] <= TotalArea;
s.t. requirement{c in Crops, s in Scenarios}:
Yield[c, s] * area[c] - sell[c, s] + buy[c, s] >= MinRequirement[c];
s.t. quota{s in Scenarios}: sell['beets', s] <= BeetsQuota;
s.t. beetsBalance{s in Scenarios}:
sell['beets', s] + sellExcess[s] <= Yield['beets', s] * area['beets'];
farmer.dat:
data;
set Crops := wheat corn beets;
set Scenarios := below average above;
param TotalArea := 500;
param P :=
below 0.333333
average 0.333334
above 0.333333;
param Yield:
below average above :=
wheat 2.0 2.5 3.0
corn 2.4 3.0 3.6
beets 16.0 20.0 24.0;
param PlantingCost :=
wheat 150
corn 230
beets 260;
param SellingPrice :=
wheat 170
corn 150
beets 36;
param ExcessSellingPrice := 10;
param PurchasePrice :=
wheat 238
corn 210
beets 100; # Set to a high value to simplify the objective
param MinRequirement :=
wheat 200
corn 240
beets 0;
param BeetsQuota := 6000;