Re: [ojAlgo-user] Use of Result
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: Anders P. <an...@op...> - 2014-11-21 18:42:40
|
The getValue() method of Optimisation.Result should return the objective function value - is that not the case? 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. > "Objective: 0.0 (1.000000)". This expression evaluates to 0.0 and contributes to the objective function with weight 1.0 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. > 0 <= constraint1: 0.0 (1.000000) <= 0 > 1.000000 <= Normalization: 1.0 (1.000000) <= 1.000000 > 0 <= constraint0: 0.0 (1.000000) <= 0 > Objective: 0.0 (1.000000) 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. 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... /Anders > On 21 nov 2014, at 14:10, Nico Potyka <Nic...@gm...> wrote: > > Hi Anders, > > 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). > 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 > 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 > 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 > 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. > I initialize the objective with > > Expression tmpExpr = tmpModel.addExpression("Objective"); > tmpExpr.setLinearFactor(noWorlds, BigMath.ONE); //noworlds=32 > tmpExpr.weight(BigMath.ONE); > > 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 > of the ExpressionBasedModel (constraint0 and constraint1 are some linear constraints that are indeed satisfied). > > ############################################ > 0 <= w0: 0.500000 > 0 <= w1: 0 > 0 <= w2: 0 > 0 <= w3: 0 > 0 <= w4: 0 > 0 <= w5: 0 > 0 <= w6: 0 > 0 <= w7: 0 > 0 <= w8: 0 > 0 <= w9: 0 > 0 <= w10: 0 > 0 <= w11: 0 > 0 <= w12: 0 > 0 <= w13: 0 > 0 <= w14: 0 > 0 <= w15: 0 > 0 <= w16: 0.500000 > 0 <= w17: 0 > 0 <= w18: 0 > 0 <= w19: 0 > 0 <= w20: 0 > 0 <= w21: 0 > 0 <= w22: 0 > 0 <= w23: 0 > 0 <= w24: 0 > 0 <= w25: 0 > 0 <= w26: 0 > 0 <= w27: 0 > 0 <= w28: 0 > 0 <= w29: 0 > 0 <= w30: 0 > 0 <= w31: 0 > 0 <= w32: 0 > 0 <= constraint1: 0.0 (1.000000) <= 0 > 1.000000 <= Normalization: 1.0 (1.000000) <= 1.000000 > 0 <= constraint0: 0.0 (1.000000) <= 0 > Objective: 0.0 (1.000000) > ############################################ > > Best regards > Nico > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |