简体   繁体   中英

Spot instance bidding strategy in Amazon EC2

My project is about determining an optimal bidding strategy for Amazon EC2 spot instances. I already have a document which is actually a research paper on this topic, it expresses the optimal bidding strategy via a recursive equation.

As of now my task is to implement this recursive algorithm, after that I have got to improve it to achieve more optimal bid price in order to minimize the average cost of computation while meeting the deadline at the same time.

B∗t = B∗t+1 − (1 − p)F(B∗t+1)[B∗t+1 − G(B∗t+1)],
where, t = 0, • • • , T − 3 and B∗T−2 = Sod.

here B*t (read as B star t) means bidding price at time instant t
     B*t+1(read as B star (t+1)th instant),similarly for B*T-2...

T is deadline of a job. Sod= on-demand instance price. F(.) & G(.) are distribution functions.

I am having problem in implementing this recursive equation. I am using core Java for my project.

I have written a code for that but not sure about the bodies of F() & G() this is what I have done so far

import java.util.Date;

class Job{
    int computationTime;
    int deadline;
public Job(int c,int T){
    computationTime=c;
    deadline=T;
}
}

public class SpotVm {

    int c;
    int T;
    int Sod;   //On-demand VM price

    public SpotVm(Job j){
     c=j.computationTime;
     T=j.deadline;
    }

    public static int G(int t) {

    }

    public static int F(int t) {

    }   



    public  int bid(int t){
        if(t<=T-3)  
         return (bid(t+1)-(1-p)F(bid(t+1))[bid(t+1)-G(bid(t+1))]);
        else
         return Sod;
        }
    public static void main(String[] args) {
        Job j1=new Job(20,75);
        SpotVm s1=new SpotVm(j1); 
        int bidvalue=s1.bid(10);
    }

}

Please suggest me possible modifications what could be done on this code.

is more a java question than aws, ec2. but i guess you want something like:

public double B(int t) {
    if (t > (bigT - 2)) throw new Error("illegal value for t");
    if (t < 0) throw new Error("illegal value for t");
    if (t == (bigT - 2)) return Sod;
    try {
        return B(t + 1) - (1 - p) * F(B(t + 1)) * (B(t + 1) - G(t + 1));
    } catch (Error e) {
        throw e;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM