我正在尝试使用AMPL来优化某些返回数据上的日志实用程序功能。程序正确读取数据但是吐出错误
LOQO 6.07:LOQO ERROR(50):无法在初始解决方案中评估obj和/或约束
我的代码非常简单:
set ASSETS; # asset names
set TIME; # dates
param R {TIME, ASSETS}; # return of asset A in month T
param w0:= 100; # initial wealth
var x{ASSETS} >=0; # amt of capital in each asset
maximize expected_utility:
sum {i in TIME} (1/card(TIME)) * log(sum {j in ASSETS} x[j]*(1+R[i,j])); # x*(1+r) = w
subject to tot_mass:
sum{j in ASSETS} x[j] <= w0; # amount in each asset must total to w0
data;
set ASSETS := VT SPY TLT EEM EFA GSG DBC DBV TIP;
set TIME := January-07 February-07 March-07 April-07 May-07 June-07 July-07 August-07 September-07 October-07 November-07 December-07 January-08 February-08 March-08 April-08 May-08 June-08;
param R: VT SPY TLT EEM EFA GSG DBC DBV TIP :=
January-07 0.01248713 0.015065017 -0.009943182 0.001149425 0.013974909 -0.025455453 -0.023718763 0.007237636 0.002407806
February-07 -0.013271444 -0.019606312 0.034002869 -0.032433984 -0.001252937 0.037131882 0.050759219 0.008383234 0.019721871
March-07 0.025685366 0.011552864 -0.017066741 0.053396618 0.029010507 0.024691358 0.006606111 0.023357086 0.003347384
April-07 0.040152115 0.044265911 0.009034444 0.037172627 0.037488571 0.004578313 0.007383101 0.021276596 0.006548869
May-07 0.031768575 0.033941771 -0.02308338 0.050773826 0.023501763 -0.011753418 -0.002035831 0.023863636 -0.013012521
June-07 -0.001752913 -0.01459002 -0.01016755 0.036692506 -0.00315729 0.03131068 0.007343941 0.027376989 -0.002238806
July-07 -0.021742556 -0.031314776 0.033130787 0.007228315 -0.022890872 0.047775947 0.019036047 -0.007922218 0.023061581
August-07 0.003843633 0.012839129 0.01792466 0.010393467 -0.006335642 -0.031895777 -0.019077901 -0.039564428 0.008163763
September-07 0.056778104 0.038708217 0.002338699 0.115601274 0.053232503 0.094431555 0.094003241 0.030234316 0.012811216
October-07 0.042289615 0.013511550 0.018116937 0.118770582 0.042376461 0.05999576 0.085185185 0.029713866 0.011694511
November-07 -0.043249736 -0.038704128 0.053518469 -0.076530612 -0.03619665 -0.00460000 -0.006143345 -0.034912718 0.041165369
December-07 -0.020039022 -0.011258574 -0.006269994 -0.014024649 -0.029848655 0.059674503 0.066964286 0.00036914 0.000566444
January-08 -0.07287025 -0.060478094 0.020988926 -0.089224138 -0.078434205 -0.004550626 0.029288703 -0.016605166 0.035665761
February-08 -0.011941005 -0.025844771 -0.004540295 0.019876952 -0.010188088 0.112571429 0.111319575 -0.007129456 0.01421231
March-08 -0.007344683 -0.00889841 0.021284683 -0.037587007 0.004117181 -0.009416196 -0.009285312 -0.041950113 -0.001401315
April-08 0.057279035 0.047634882 -0.024810818 0.091610415 0.054407822 0.08192188 0.060494178 0.038658777 -0.019753886
May-08 0.016184106 0.015156324 -0.026841369 0.031581272 0.011965301 0.084664537 0.069094804 0.017850361 0.0011012
June-08 -0.096123568 -0.08363949 0.026535948 -0.102975808 -0.104936447 0.103240059 0.104208417 -0.005597015 0.017929821
;
#display(ASSETS);
#display(TIME);
#display R;
solve;
display {i in ASSETS} x[i];
有什么想法吗?
再次感谢stackoverflow
答案 0 :(得分:2)
由于您没有为变量x [j]指定初始值,因此默认情况下它们都被赋予初始值0.因此,您的目标函数涉及0的日志,LOQO无法评估。尝试设置显式初始值,例如
var x{ASSETS} >=0, := w0 / card(ASSETS);
这里所有变量都以相等的总资产份额进行初始化,这可能是一个合理的开始。