有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Amazon EC2中的java Spot实例竞价策略

我的项目是关于确定亚马逊EC2现货实例的最佳投标策略。我已经有一份文件,实际上是一篇关于这个主题的研究论文,它通过一个递归方程表达了最优投标策略

到目前为止,我的任务是实现这个递归算法,之后我必须对其进行改进,以获得更优的投标价格,从而在满足截止日期的同时最小化平均计算成本

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.

我在实现这个递归方程时遇到了问题。我正在为我的项目使用核心Java

我已经为此编写了一个代码,但不确定F()的主体;G() 这就是我到目前为止所做的

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);
    }

}

请建议我可能的修改可以做什么对这个代码


共 (1) 个答案

  1. # 1 楼答案

    与aws、ec2相比,这更像是一个java问题。但我想你想要的是:

    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;
        }
    }