我的项目是为Amazon 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);
}
}
请建议我对此代码进行可能的修改。
答案 0 :(得分: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;
}
}