Re: [ojAlgo-user] Use of Result
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: Nico P. <Nic...@gm...> - 2014-11-21 20:09:14
|
<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div> <div>Alright, thanks again.</div> <div> </div> <div> </div> <div> <div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"> <div style="margin:0 0 10px 0;"><b>Gesendet:</b> Freitag, 21. November 2014 um 19:42 Uhr<br/> <b>Von:</b> "Anders Peterson" <an...@op...><br/> <b>An:</b> "ojAlgo ojAlgo" <oja...@li...><br/> <b>Betreff:</b> Re: [ojAlgo-user] Use of Result</div> <div name="quoted-content">The getValue() method of Optimisation.Result should return the objective function value - is that not the case?<br/> <br/> The fact that you create an Expression and name it "Objective" has no specific meaning. It's just an expression like any other. It's the fact that you give it a weight that makes it part of the objective function, and the weight specifies how much this particular expression (or variable) contributes the objective function.<br/> <br/> > "Objective: 0.0 (1.000000)".<br/> <br/> This expression evaluates to 0.0 and contributes to the objective function with weight 1.0<br/> <br/> As far as I can see you've created 4 expressions (constraint0, constraint1, Normalization and Objective) and each of them has weight 1.0. This means there are 4 equally weighted "things" that together make up the objective function.<br/> <br/> > 0 <= constraint1: 0.0 (1.000000) <= 0<br/> > 1.000000 <= Normalization: 1.0 (1.000000) <= 1.000000<br/> > 0 <= constraint0: 0.0 (1.000000) <= 0<br/> > Objective: 0.0 (1.000000)<br/> <br/> When you call getValue() you should get 0.0*1.000000 + 1.0*1.000000 + 0.0*1.000000 + 0.0*1.000000 that equals 1.0, and that's what you stated is returned.<br/> <br/> I'm guessing you did not intend constraint0, constraint1 or Normalization to be part of the objective function - then you should not give them weights...<br/> <br/> <br/> /Anders<br/> <br/> <br/> > On 21 nov 2014, at 14:10, Nico Potyka <Nic...@gm...> wrote:<br/> ><br/> > Hi Anders,<br/> ><br/> > sorry to bother you again, but I have another problem. I just optimized a problem and the solution seems perfectly fine (I attach the state of the ExpressionBasedModel below).<br/> > The variable assignment (w0 = w16 = 0.5) is indeed a minimal solution and the value of the objective is 0, as I would expect. However, the getValue() method yields 1 for the<br/> > result object and I do not understand why. In fact, the objective state in the ExpressionBasedModel says "Objective: 0.0 (1.000000)". So, I guess, getValue() yields the second<br/> > value. But what do these values actually mean? The only reasonable explanation for me is that I optimize the objective a + c' w where w is my variable vector, c' the transposed<br/> > objective vector and a an offset. So maybe 0 is the solution of the linear part (c' w) and 1 the solution of the complete objective? Then, I guess, I set an offset of 1 by accident.<br/> > I initialize the objective with<br/> ><br/> > Expression tmpExpr = tmpModel.addExpression("Objective");<br/> > tmpExpr.setLinearFactor(noWorlds, BigMath.ONE); //noworlds=32<br/> > tmpExpr.weight(BigMath.ONE);<br/> ><br/> > So maybe weight corresponds to the offset? I tried to set it to zero, but this does not seem to be the solution. Do you see my mistake? Below you find the complete state<br/> > of the ExpressionBasedModel (constraint0 and constraint1 are some linear constraints that are indeed satisfied).<br/> ><br/> > ############################################<br/> > 0 <= w0: 0.500000<br/> > 0 <= w1: 0<br/> > 0 <= w2: 0<br/> > 0 <= w3: 0<br/> > 0 <= w4: 0<br/> > 0 <= w5: 0<br/> > 0 <= w6: 0<br/> > 0 <= w7: 0<br/> > 0 <= w8: 0<br/> > 0 <= w9: 0<br/> > 0 <= w10: 0<br/> > 0 <= w11: 0<br/> > 0 <= w12: 0<br/> > 0 <= w13: 0<br/> > 0 <= w14: 0<br/> > 0 <= w15: 0<br/> > 0 <= w16: 0.500000<br/> > 0 <= w17: 0<br/> > 0 <= w18: 0<br/> > 0 <= w19: 0<br/> > 0 <= w20: 0<br/> > 0 <= w21: 0<br/> > 0 <= w22: 0<br/> > 0 <= w23: 0<br/> > 0 <= w24: 0<br/> > 0 <= w25: 0<br/> > 0 <= w26: 0<br/> > 0 <= w27: 0<br/> > 0 <= w28: 0<br/> > 0 <= w29: 0<br/> > 0 <= w30: 0<br/> > 0 <= w31: 0<br/> > 0 <= w32: 0<br/> > 0 <= constraint1: 0.0 (1.000000) <= 0<br/> > 1.000000 <= Normalization: 1.0 (1.000000) <= 1.000000<br/> > 0 <= constraint0: 0.0 (1.000000) <= 0<br/> > Objective: 0.0 (1.000000)<br/> > ############################################<br/> ><br/> > Best regards<br/> > Nico<br/> > ------------------------------------------------------------------------------<br/> > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server<br/> > from Actuate! Instantly Supercharge Your Business Reports and Dashboards<br/> > with Interactivity, Sharing, Native Excel Exports, App Integration & more<br/> > Get technology previously reserved for billion-dollar corporations, FREE<br/> > <a href="http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk_______________________________________________" target="_blank">http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk_______________________________________________</a><br/> > ojAlgo-user mailing list<br/> > ojA...@li...<br/> > <a href="https://lists.sourceforge.net/lists/listinfo/ojalgo-user" target="_blank">https://lists.sourceforge.net/lists/listinfo/ojalgo-user</a><br/> <br/> <br/> ------------------------------------------------------------------------------<br/> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server<br/> from Actuate! Instantly Supercharge Your Business Reports and Dashboards<br/> with Interactivity, Sharing, Native Excel Exports, App Integration & more<br/> Get technology previously reserved for billion-dollar corporations, FREE<br/> <a href="http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk" target="_blank">http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk</a><br/> _______________________________________________<br/> ojAlgo-user mailing list<br/> ojA...@li...<br/> <a href="https://lists.sourceforge.net/lists/listinfo/ojalgo-user" target="_blank">https://lists.sourceforge.net/lists/listinfo/ojalgo-user</a></div> </div> </div> </div></div></body></html> |