[Cmpl] Piece-Wise Linearization Syntax Question

Ogden, Bhrett A. ogdenba at cdmsmith.com
Mon Nov 27 14:22:18 EST 2017


Hi Mike,

Thanks for your correction here. I have a few more syntax-related questions from the attached file.


1. What does unexpected symbol var mean in the instance below? Normally I find that I’ve used an undefined variable, but I don’t see any issue with that here:


# Force x_(i+1) = 0 whenever x_i < u_i (pg 574)

special_condition$1${

e in export_ports,

i in import_ports,

r in route_types,

s in seasons,

g in grains,

n in approximation_intervals:

{ n < len(approximation_intervals) && #Syntax error unexpected SYMBOL_VAR

x_val_interval[e,i,r,s,g,n] < tonnage_intervals[s,g,n]:

x_val_interval[e,i,r,s,g,n+1] = 0;

}
}

2. What does “product of variable has too much indexes” error message mean?

transport_cost$1$ {
e in export_ports,
i in import_ports,
r in route_types,
s in seasons,
g in grains:
transport_cost[e,i,r,s,g] = sum{
n in approximation_intervals:
x_val_interval[e,i,r,s,g,n] * m[e,i,s,g,n] * route_nmiles[e,i,r] * transport_cost_per_mton_nmile #Syntax issue: Product of variable has too much indexes
};
}

3. How can I properly format this stamen involving a power? I’m not having any luck with this.

#Get cost for the tonnage intervals
solve_fx$1$ {
e in export_ports,
i in import_ports,
s in seasons,
g in grains,
n in approximation_intervals:
fx[e,i,s,g,n] = exp(a[e,i]) * (n*tonnage_intervals[s,g])^b[e,i]; # Syntax issue with power
}

4. What is proper format for this statement? I’m having an issue getting the operators and parenthesis in a format that CMPL accepts.

#Get slope for piece-wise approximation
solve_m$1$ {
e in export_ports,
i in import_ports,
s in seasons,
g in grains,
n in approximation_intervals:
{
n = 1:
m[e,i,s,g,n] = fx[e,i,s,g,n] * (1/tonnage_intervals[s,g]); # Arithmetic syntax issue
| n > 1:
m[e,i,s,g,n] = (fx[e,i,s,g,n] - fx[e,i,s,g,n-1])/(n*tonnage_intervals[s,g] - (n-1)*tonnage_intervals[s,g,]); # Arithmetic syntax issue
}
}

Thank you for any advice or clarification.

Best,

Bhrett Ogden
Information Management Software Developer
CDM Smith
1050 N Reed Station Rd Suite D
Carbondale, IL 62902
T: 312.780.7869
ogdenba at cdmsmith.com<mailto:ogdenba at cdmsmith.com>
cdmsmith.com

From: Mike Steglich [mailto:mike.steglich at th-wildau.de]
Sent: Monday, November 20, 2017 6:24 AM
To: Ogden, Bhrett A. <ogdenba at cdmsmith.com>
Cc: cmpl at list.coin-or.org
Subject: Re: [Cmpl] Piece-Wise Linearization Syntax Question

Hi Bhrett,

Hmm I am actually scatty because I forgotten to answer your second question:

This expression works:

tonnage_intervals$1$ {
s in seasons,
g in grains,
i in approximation_intervals:
tonnage_intervals[i,s,g] = worldwide_demand[s,g] * i * 1/len(approximation_intervals); # Division won't work. I'm having to hardcode 0.25 for now.
}

if you imbed 1/len(approximation_intervals in brackets:
tonnage_intervals$1$ {
s in seasons,
g in grains,
i in approximation_intervals:
tonnage_intervals[i,s,g] = worldwide_demand[s,g] * i * (1/len(approximation_intervals));
}

Mike




Am 15.11.2017 um 20:52 schrieb Ogden, Bhrett A. <ogdenba at cdmsmith.com<mailto:ogdenba at cdmsmith.com>>:
Thank you for your prompt answer to my last question.

I have another question regarding syntax of CMPL. I have a power function that represents a route cost that I would like to linearize. I am using linear approximation to consider the range of options and break the non-linear equation into a four-part piece-wise equation, f(x) ~= f(n) + f’(n)(x-n), where n is the mean route tonnage in the interval. The power function is C = e^a * x^b where a and b are constants that depend on the route origin/destination and x is the route tonnage. One element that I am trying to minimize is the sum of the transport costs.

I have approximated the cost to f(x) = e^a * n^b * (1 + b * n^-1 * x – b), where n is the mean route tonnage in the interval and a and b are constants with respect to the route. Assuming that all tonnages lie within the first interval for now (to avoid complicating this question with piece-wise syntax), how can I represent this in CMPL? I was having issues with using parenthesis so I have done all of the distributions. Now I am receiving syntax errors about ^. What is the proper way to represent this?

transport_cost$1$ {
e in export_ports,
i in import_ports,
s in seasons,
g in grains,
r in route_type:
transport_cost[e,i,r,s,g] = exp(a[e,i]) * mean_tonnage_for_interval[1,s,g] ^ b[e,i] + b[e,i] * exp(a[e,i]) * route_tonnage[e,i,r,s,g] * mean_tonnage_for_interval[1,s,g] ^ b[e,i] * mean_tonnage_for_interval[1,s,g] ^ -1 - exp(a[e,i])* b * mean_tonnage_for_interval[1,s,g] ^ b[e,i];
}

Would you also be able to explain why I get a syntax error if I divide in the following situation?:

tonnage_intervals$1$ {
s in seasons,
g in grains,
i in approximation_intervals:
tonnage_intervals[i,s,g] = worldwide_demand[s,g] * i * 1/len(approximation_intervals); # Division won't work. I'm having to hardcode 0.25 for now.
}

Thank you for your assistance.

Best,
Bhrett Ogden
_______________________________________________
Cmpl mailing list
Cmpl at list.coin-or.org<mailto:Cmpl at list.coin-or.org>
https://list.coin-or.org/mailman/listinfo/cmpl<https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_cmpl&d=DwMFaQ&c=NpiPIT1KNSO0vXgGk6ogJQ&r=lti1h6i9rU5mEC99NvhtD9QtmLoHcyEs5V5LTq78EsM&m=iakxlbWQOSKuVBjy57i_AAXrPmasU7QkeNtxBBAYFNY&s=Xzgr46f-5U3RODSHpP9XNrS1zNErazUh_atWM2K16HM&e=>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cmpl/attachments/20171127/4d238b8d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Seasonal.cmpl
Type: application/octet-stream
Size: 11215 bytes
Desc: Seasonal.cmpl
URL: <http://list.coin-or.org/pipermail/cmpl/attachments/20171127/4d238b8d/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Seasonal.cdat
Type: application/octet-stream
Size: 3549 bytes
Desc: Seasonal.cdat
URL: <http://list.coin-or.org/pipermail/cmpl/attachments/20171127/4d238b8d/attachment-0001.obj>


More information about the Cmpl mailing list