Bootstrap Method

55 views
Skip to first unread message

鄭宇竣

unread,
Apr 30, 2023, 10:45:47 AM4/30/23
to AMPL Modeling Language

Dear AMPL teams,


I am currently conducting an experiment that requires the use of the "Bootstrap Method" technique. Despite consulting the instruction manual and various online forums, I have not been able to find any information or methodology related to its application. I have attached some of the code that I have written, and I would greatly appreciate your assistance in guiding me and offering suggestions on this matter.

截圖 2023-04-30 下午12.31.25.png

Thank you very much for your time and consideration.


Best regards,

Alan

AMPL Google Group

unread,
May 1, 2023, 12:40:09 PM5/1/23
to AMPL Modeling Language
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.


--
Robert Fourer

We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
{#HS:2228473453-116539#}
On Sun, Apr 30, 2023 at 3:47 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
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,
Alan

AMPL Google Group

unread,
May 1, 2023, 6:52:56 PM5/1/23
to AMPL Modeling Language
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;
```

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



--
Marcos Domínguez Velad


We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
{#HS:2228473453-116539#}
On Mon, May 1, 2023 at 4:39 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
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.


--
Robert Fourer

We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.

Mark Stone

unread,
Jun 27, 2023, 2:42:54 PM6/27/23
to AMPL Modeling Language
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.
Reply all
Reply to author
Forward
0 new messages