<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>Using "symbolic" variable names.</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">Hi,</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">I am developing a toy problem in order to figure out how FlopC++ has to be used. I consulted the example problems in the examples section to get started but have a couple of questions:</FONT></P>
<P><FONT SIZE=2 FACE="Arial">1) Use of symbolic names and LP file output: I would like to use the setName method on MP_variable, lets say, such as</FONT>
</P>
<P> <FONT SIZE=2 FACE="Arial">MP_model lp(new OsiCbcSolverInterface) ;</FONT>
<BR> <FONT SIZE=2 FACE="Arial">MP_set T(123);</FONT>
<BR> <FONT SIZE=2 FACE="Arial">MP_variable dispatch_period_volume(T);</FONT>
<BR> <FONT SIZE=2 FACE="Arial">x.setName("dp_volume_");</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Once the model has been set up, I write the problem to a file, such as</FONT>
</P>
<P> <FONT SIZE=2 FACE="Arial">lp.attach(); </FONT>
<BR> <FONT SIZE=2 FACE="Arial">lp.Solver->writeLp("c:\\temp\\bmt);</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">What I expect to see in the file bmt.lp is that the variable names are printed like dp_volume_1, dp_volume_2, …, dp_volume_124, but what I get is only x1, …, x124. Am I doing something wrong or is this feature not supported (in this case what is the MP_variable::setNames() method for?).</FONT></P>
<P><FONT SIZE=2 FACE="Arial">2) In the objective function in question some of the decision variables x are modelled by abs(x) (the absolute value of x). Obviously this is not a linear construct, but can be modelled as:</FONT></P>
<P> <FONT SIZE=2 FACE="Arial">x <= abs_x</FONT>
<BR> <FONT SIZE=2 FACE="Arial">-1.0*x <= abs_x</FONT>
<BR> <FONT SIZE=2 FACE="Arial">0 <= abs_x</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Because I require various variables to be modelled as abs(.) I would like to implement a function that;</FONT>
<BR><FONT SIZE=2 FACE="Arial">A) creates the auxiliary variable(s) abs_x for each such x,</FONT>
<BR><FONT SIZE=2 FACE="Arial">B) adds above constraints/bounds to the model, and</FONT>
<BR><FONT SIZE=2 FACE="Arial">C) returns a MP_expression that can be added to the objective function expression in terms of the abs_x variables.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">I.e., I would like to delegate/encapsulate all issues to model the absolute value of a decision variable to a function.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">My initial approach, listed below, failed miserably because of the issue of automatic variables and copy constructors, etc., I guess boiling down to that FlopC++ elements are not "shallow" copied and reference counted on the one had and that MP_variables are not added to the model implicitly but only through their use in constraints and objective function. What is the proper way to accomplish this?</FONT></P>
<BR>
<P><FONT SIZE=2 FACE="Arial">static MP_expression</FONT>
<BR><FONT SIZE=2 FACE="Arial">lp_objective_absolute(</FONT>
<BR> <FONT SIZE=2 FACE="Arial">MP_variable& x,</FONT>
<BR> <FONT SIZE=2 FACE="Arial">MP_data& weight,</FONT>
<BR> <FONT SIZE=2 FACE="Arial">MP_model& lp/*=MP_model::getDefaultModel()*/,</FONT>
<BR> <FONT SIZE=2 FACE="Arial">const string& prefix/*="abs_"*/) {</FONT>
<BR> <FONT SIZE=2 FACE="Arial">if (x.size() > 0) {</FONT>
<BR> <FONT SIZE=2 FACE="Arial">if (x.getName().empty()) {</FONT>
<BR> <FONT SIZE=2 FACE="Arial">string message;</FONT>
<BR> <FONT SIZE=2 FACE="Arial">message += "decision variable(s) or affine expression(s) is/are not named";</FONT>
<BR> <FONT SIZE=2 FACE="Arial">throw BmtException(message.c_str());</FONT>
<BR> <FONT SIZE=2 FACE="Arial">}</FONT>
<BR> <FONT SIZE=2 FACE="Arial">MP_set D(x.size());</FONT>
<BR> <FONT SIZE=2 FACE="Arial">MP_variable abs_x(D);</FONT>
<BR> <FONT SIZE=2 FACE="Arial">abs_x.setName(prefix + x.getName());</FONT>
<BR> <FONT SIZE=2 FACE="Arial">abs_x.lowerLimit(D) = 0.0;</FONT>
<BR> <FONT SIZE=2 FACE="Arial">MP_constraint abs_x_linctr_a(D);</FONT>
<BR> <FONT SIZE=2 FACE="Arial">MP_constraint abs_x_linctr_b(D);</FONT>
<BR> <FONT SIZE=2 FACE="Arial">abs_x_linctr_a(D) = x(D) <= abs_x(D);</FONT>
<BR> <FONT SIZE=2 FACE="Arial">abs_x_linctr_b(D) = -1.0*x(D) <= abs_x(D);</FONT>
</P>
<P> <FONT SIZE=2 FACE="Arial">lp.add(abs_x_linctr_a);</FONT>
<BR> <FONT SIZE=2 FACE="Arial">lp.add(abs_x_linctr_b);</FONT>
</P>
<P> <FONT SIZE=2 FACE="Arial">return sum(D, weight(D)*abs_x(D));</FONT>
<BR> <FONT SIZE=2 FACE="Arial">} else {</FONT>
<BR> <FONT SIZE=2 FACE="Arial">return MP_expression();</FONT>
<BR> <FONT SIZE=2 FACE="Arial">}</FONT>
<BR><FONT SIZE=2 FACE="Arial">}</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">And would be used such as</FONT>
</P>
<P> <FONT SIZE=2 FACE="Arial">MP_expression objective;</FONT>
<BR> <FONT SIZE=2 FACE="Arial">MP_data UNIT_WEIGHT_X(T);</FONT>
<BR> <FONT SIZE=2 FACE="Arial">UNIT_WEIGHT_X(T) = 1.0;</FONT>
<BR> <FONT SIZE=2 FACE="Arial">objective = lp_objective_absolute(dispatch_period_volume, UNIT_WEIGHT_X, lp);</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Best Regards/Mit freundlichen Grüßen</FONT>
<BR><B><FONT SIZE=2 FACE="Arial">Marc Roth</FONT></B><BR>
<FONT SIZE=2 FACE="Arial">External Consultant,<BR>
Structuring & Valuation<BR>
Tel.: +41 55 534 44 82<BR>
Mob: +44 7795 276 136<BR>
Fax: +41 55 534 44 82<BR>
</FONT><A HREF="mailto:marc.roth@rwe.com"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">mailto:marc.roth@rwe.com</FONT></U></A><BR>
<FONT SIZE=2 FACE="Arial">yahoo:nerdyanorak</FONT>
<BR><FONT SIZE=1 FACE="Arial">RWE Supply & Trading GmbH<BR>
London Branch<BR>
130 Wood Street<BR>
London EC2V 6DL<BR>
United Kingdom<BR>
<BR>
Advisory Board:<BR>
Dr. Ulrich Jobs (Chairman)</FONT>
</P>
<P><FONT SIZE=1 FACE="Arial">Board of Directors:<BR>
Stefan Judisch (CEO)<BR>
Dr. Bernhard Günther<BR>
Dr. Peter Kreuzberg<BR>
Richard Lewis</FONT>
<BR><FONT SIZE=1 FACE="Arial">Alan Robinson</FONT>
</P>
<P><FONT SIZE=1 FACE="Arial">Head Office: Essen, Germany </FONT>
<BR><FONT SIZE=1 FACE="Arial">Registered at the County Court of Essen<BR>
Commercial Registry No.: HRB 14327<BR>
Sales Tax Identification No. DE 8130 22 070</FONT>
</P>
</BODY>
</HTML>
<p>
<br>
</p>