[AMPL 24625] Bootstrap Method

Hi AMPL teams,

I am conducting an experiment that requires the technique of “Bootstrap Method.” I have consulted the instruction manual and various online forums, but have not found any information or methodology related to its application. I have attached some of the code that I have written and would like to inquire where I can receive guidance or suggestions. Could you please advise me on this matter? Thank you very much.

Best Regards,


hospital.run (761 Bytes)

AMPL is a language and system for solving optimization problems. But did you define an optimization problem in hospital.mod? In hospital.run, you set “option solver cplex;”, but you do not have a “solve” anywhere. The bootstrap method is “a statistical technique for estimating quantities about a population” so it’s not clear how it would involve optimization.

In any case, you will need to correct “set S := {rand(1,n) | i in 1…726};” so that it is a proper statement in the AMPL language. Do you want S to be a set of 726 random values in the range 1…n? Then you can write

set S = setof {i in 1…726} Uniform(1,n);

You will need to put this before “for {b in 1…B}” however, so that set S is defined only once and not every time through the loop.

Hi Alan,

As Robert said, you might be solving an optimization problem at some point, right? You can access data in AMPL through one of the APIs and process the data more easily in another programming language. If you just want to use ampl, you will need to adjust your script…

Not sure how you want to implement bootstrap, but some possible corrections to your script:

  1. Is count a variable? It looks like a parameter, so you can define it as
param count default 0;
  1. You can sample integers with the Irand224() builtin function. You can also use Uniform(a,b) to sample real numbers and the floor function. You may want to generate a new random set S for each batch.
# load model...
set S;
param B := 2000;
param count default 0;
param count_b default 0;
for {b in 1..B} {

# New S set each iteration with 726 random integer elements between 1 and n-1
let S := setof{i in 1..726} (floor(Uniform(1,n)));
let count_b := card{i in S : sum{c in C} Total_Time_PSC[c,i] * X[c] + sum{h in H} Total_Time_CSC[h,i] * X[h] < Threshold};
let count := count + count_b;

You could also store all the count_b’s to do further analysis param count_b{1..B} default 0;, and let count_b{b} := card....

There is an option to control AMPL’s random seed called randseed option.

There are many different variations of Bootstrap an d ways to use it in conjunction with optimization.

Presumably, you would generate M bootstrap samples of input data, and would solve an optimization problem for each bootstrap sample. Exactly which input data is bootstrapped and how depends on what specifically you are trying to do.