# \#modeling

**URL:** https://discuss.ampl.com/tag/modeling/53.md

[Latest](https://discuss.ampl.com/latest.md) · [Categories](https://discuss.ampl.com/categories.md) · [Tags](https://discuss.ampl.com/tags.md)

---

## [FINAL CALL for Optimization Modeling & Deployment Sessions at 2026 INFORMS Annual Meeting](https://discuss.ampl.com/t/final-call-for-optimization-modeling-deployment-sessions-at-2026-informs-annual-meeting/2234)

<div class="topic-metadata">

**Author:** [@4er](https://discuss.ampl.com/u/4er)\
**Replies:** 0\
**Last updated:** [April 26, 2026, 4:22pm UTC](https://discuss.ampl.com/t/final-call-for-optimization-modeling-deployment-sessions-at-2026-informs-annual-meeting/2234 "2026-04-26T16:22:35Z")

</div>

There’s still time to join our Community Sessions in the area of “Optimization Modeling & Deployment Software” at the 2026 INFORMS Annual Meeting, to be held November 1-4, 2026 in San Francisco (meetings.informs.org/word…

---

## [Fixing and unfixing a series of variables before a second solve](https://discuss.ampl.com/t/fixing-and-unfixing-a-series-of-variables-before-a-second-solve/2233)

<div class="topic-metadata">

**Author:** [@marnie2k](https://discuss.ampl.com/u/marnie2k)\
**Replies:** 1\
**Last updated:** [April 13, 2026, 12:57am UTC](https://discuss.ampl.com/t/fixing-and-unfixing-a-series-of-variables-before-a-second-solve/2233 "2026-04-13T00:57:06Z")

</div>

Good afternoon, Lately I have been working on a model that requires me to, after a first optimization, fix a series of variables and unfix some according to a certain condition and after that, perform a second solve. D…

---

## [Performance difference between defined variables and s.t. or syntatic sugar?](https://discuss.ampl.com/t/performance-difference-between-defined-variables-and-s-t-or-syntatic-sugar/2228)

<div class="topic-metadata">

**Author:** [@\_nr](https://discuss.ampl.com/u/_nr)\
**Replies:** 3\
**Last updated:** [March 14, 2026, 4:43am UTC](https://discuss.ampl.com/t/performance-difference-between-defined-variables-and-s-t-or-syntatic-sugar/2228 "2026-03-14T04:43:27Z")

</div>

I appreciate how defined variables, e.g., var x {...} = ...; helps keep my AMPL code maintainable. However, for performance reasons, should I prefer something like var x {...}; s.t. X {...} : x\[...\] = ...; instead? How…

---

## [Implementation continuous p-median problem](https://discuss.ampl.com/t/implementation-continuous-p-median-problem/2213)

<div class="topic-metadata">

**Author:** [@nickgessner\_9](https://discuss.ampl.com/u/nickgessner_9)\
**Replies:** 4\
**Last updated:** [December 26, 2025, 1:47pm UTC](https://discuss.ampl.com/t/implementation-continuous-p-median-problem/2213 "2025-12-26T13:47:28Z")

</div>

Good day, I’m using amplpy and planning to solve the attached continuous problem in 3D. Could someone give me some hints as to the modelling? I’m planning to solve this using SNOPT and randomly generated starting points…

---

## [How can i solve this error?](https://discuss.ampl.com/t/how-can-i-solve-this-error/2108)

<div class="topic-metadata">

**Author:** [@edy\_munguambe](https://discuss.ampl.com/u/edy_munguambe)\
**Replies:** 1\
**Last updated:** [April 2, 2025, 1:18am UTC](https://discuss.ampl.com/t/how-can-i-solve-this-error/2108 "2025-04-02T01:18:58Z")

</div>

Trabalho.mod, line 36 (offset 1790): syntax error context: var \>\>\> z1:sum{ \<\<\< i in I} E\[i\] \* Z\[i\] + sum{l in L} F\[l\] \* W\[l\] + sum{i in I,k in K,j in J} (A\[j\] + B\[j\] \* t\_ik\[i,k\]) \* X\[i,k,j\] + sum{k in K,l in L,j in J}…

---

## [Relaxing integrality on specific index values of a variable](https://discuss.ampl.com/t/relaxing-integrality-on-specific-index-values-of-a-variable/1959)

<div class="topic-metadata">

**Author:** [@jkilb](https://discuss.ampl.com/u/jkilb)\
**Replies:** 6\
**Last updated:** [February 13, 2025, 11:31pm UTC](https://discuss.ampl.com/t/relaxing-integrality-on-specific-index-values-of-a-variable/1959 "2025-02-13T23:31:02Z")

</div>

Hi, I have the following variable in my .mod: var X {CKLLT} \>= 0; Which is defined in the .dat file as: set CKLLT := (commodity1, vehicle, location1, location2, time) (commodity2, vehicle, location1, location2, ti…

---

## [Setting up piecewise linear variables reading excel data](https://discuss.ampl.com/t/setting-up-piecewise-linear-variables-reading-excel-data/2047)

<div class="topic-metadata">

**Author:** [@Lothar\_Lower](https://discuss.ampl.com/u/Lothar_Lower)\
**Replies:** 2\
**Last updated:** [February 10, 2025, 9:16pm UTC](https://discuss.ampl.com/t/setting-up-piecewise-linear-variables-reading-excel-data/2047 "2025-02-10T21:16:51Z")

</div>

Hello, I am reading excel data using “amplxl.dll” and want to use it to setup several piecewise linear functions in AMPL. Is there a common procedure (best practice) to do this? My excel data contains data like: |id|t…

---

## [How to set "variable hints" for Gurobi](https://discuss.ampl.com/t/how-to-set-variable-hints-for-gurobi/2045)

<div class="topic-metadata">

**Author:** [@jkisse](https://discuss.ampl.com/u/jkisse)\
**Replies:** 1\
**Last updated:** [January 30, 2025, 5:48pm UTC](https://discuss.ampl.com/t/how-to-set-variable-hints-for-gurobi/2045 "2025-01-30T17:48:07Z")

</div>

Hi, I have a MIQCP-Problem that I want to solve with Gurobi 12. It is a pipeflow problem with a binary variable indicating the flow direction. I already know the likely direction of the flow, therefore I’d like to prov…

---

## [Warmstarting an LP with an added equality constraint](https://discuss.ampl.com/t/warmstarting-an-lp-with-an-added-equality-constraint/2007)

<div class="topic-metadata">

**Author:** [@eturan](https://discuss.ampl.com/u/eturan)\
**Replies:** 6\
**Last updated:** [January 12, 2025, 7:59pm UTC](https://discuss.ampl.com/t/warmstarting-an-lp-with-an-added-equality-constraint/2007 "2025-01-12T19:59:25Z")

</div>

Hi, I am solving a large LP with AMPL and Gurobi. As part of exploring the optimal solution I find one solution, add a constraint to fix (some) design variables to their optimal values, and then resolve the system using…

---

## [Using information from the presolve phase to improve the model](https://discuss.ampl.com/t/using-information-from-the-presolve-phase-to-improve-the-model/2024)

<div class="topic-metadata">

**Author:** [@Rafa1](https://discuss.ampl.com/u/Rafa1)\
**Replies:** 1\
**Last updated:** [January 12, 2025, 5:14pm UTC](https://discuss.ampl.com/t/using-information-from-the-presolve-phase-to-improve-the-model/2024 "2025-01-12T17:14:26Z")

</div>

Greetings everyone. Could someone direct me to some documentation where I can learn how to use information from the presolve phase (both from Cplex and Gurobi) to improve model execution? I am particularly interested i…

---

## [Ensuring Independent Paths in Multi-Line Network Optimization with "Unique Father Only" Constraints](https://discuss.ampl.com/t/ensuring-independent-paths-in-multi-line-network-optimization-with-unique-father-only-constraints/1973)

<div class="topic-metadata">

**Author:** [@tiago\_duarte](https://discuss.ampl.com/u/tiago_duarte)\
**Replies:** 3\
**Last updated:** [November 10, 2024, 1:11am UTC](https://discuss.ampl.com/t/ensuring-independent-paths-in-multi-line-network-optimization-with-unique-father-only-constraints/1973 "2024-11-10T01:11:39Z")

</div>

Brief Description: This discussion focuses on optimizing two subway lines to cover stations independently, but the model’s “unique\_father\_only” constraints are unintentionally forcing both lines to cover all stations, e…

---

## [Help Needed for Linearizing a Conditional Expression in Optimization Model](https://discuss.ampl.com/t/help-needed-for-linearizing-a-conditional-expression-in-optimization-model/1976)

<div class="topic-metadata">

**Author:** [@zhihans652](https://discuss.ampl.com/u/zhihans652)\
**Replies:** 1\
**Last updated:** [November 10, 2024, 12:33am UTC](https://discuss.ampl.com/t/help-needed-for-linearizing-a-conditional-expression-in-optimization-model/1976 "2024-11-10T00:33:36Z")

</div>

Hello everyone, I’m currently working on an optimization model and need some assistance with linearizing a specific conditional expression. The expression is defined as follows: z\_i=x\_i-y\_i, if x\_i-y\_i\>0, else z\_i=+\\in…

---

## [Is it necessary to apply normalization to unknown parameters with different scales?](https://discuss.ampl.com/t/is-it-necessary-to-apply-normalization-to-unknown-parameters-with-different-scales/1947)

<div class="topic-metadata">

**Author:** [@ae.naderi](https://discuss.ampl.com/u/ae.naderi)\
**Replies:** 3\
**Last updated:** [October 22, 2024, 11:52pm UTC](https://discuss.ampl.com/t/is-it-necessary-to-apply-normalization-to-unknown-parameters-with-different-scales/1947 "2024-10-22T23:52:33Z")

</div>

Hello everybody! I have a model built in AMPL. The scales of my unknown values are different. Two of them are coordinates, for the another; one has a scale between 2 and 9, and the other is between -150 and 50. I want …

---

## [AMPL PLF (piecewise linear function) as a CC (convex combination) modelling!](https://discuss.ampl.com/t/ampl-plf-piecewise-linear-function-as-a-cc-convex-combination-modelling/1949)

<div class="topic-metadata">

**Author:** [@Fateh](https://discuss.ampl.com/u/Fateh)\
**Replies:** 3\
**Last updated:** [October 18, 2024, 2:03am UTC](https://discuss.ampl.com/t/ampl-plf-piecewise-linear-function-as-a-cc-convex-combination-modelling/1949 "2024-10-18T02:03:40Z")

</div>

Hi, I am trying the following constraints to build in AMPL for Convex combination modelling of a piecewise linear function: # Parameters param K; # Number of k values param Z; …

---

## [Error in defining a symbolic link](https://discuss.ampl.com/t/error-in-defining-a-symbolic-link/1170)

<div class="topic-metadata">

**Author:** [@Steve](https://discuss.ampl.com/u/Steve)\
**Replies:** 1\
**Last updated:** [July 30, 2024, 12:40am UTC](https://discuss.ampl.com/t/error-in-defining-a-symbolic-link/1170 "2024-07-30T00:40:35Z")

</div>

I passed my code through chat-gpt and was told the code should work, but when I try to load my model, I get an error: line 1 (offset 9): syntax error context: set grid \>\>\> symbolic; \<\<\< I explained the error …

---

## [Object value is zero](https://discuss.ampl.com/t/object-value-is-zero/1159)

<div class="topic-metadata">

**Author:** [@ae.naderi](https://discuss.ampl.com/u/ae.naderi)\
**Replies:** 1\
**Last updated:** [July 22, 2024, 4:24pm UTC](https://discuss.ampl.com/t/object-value-is-zero/1159 "2024-07-22T16:24:40Z")

</div>

Hi everyone! I changed the initial values of my object. However, I still get zero as the output for the object values from the solver. How can I solve this problem? The following code contains pieces of my code: void s…

---

## [Location of Service Facilities for the Elderly - A utilization-maximizing](https://discuss.ampl.com/t/location-of-service-facilities-for-the-elderly-a-utilization-maximizing/1149)

<div class="topic-metadata">

**Author:** [@francesca\_lorenzi](https://discuss.ampl.com/u/francesca_lorenzi)\
**Replies:** 1\
**Last updated:** [July 8, 2024, 2:17pm UTC](https://discuss.ampl.com/t/location-of-service-facilities-for-the-elderly-a-utilization-maximizing/1149 "2024-07-08T14:17:51Z")

</div>

hi, How do I insert an external script generated on Python into my model, with random data? In particular: lambda\_data.dat (6.1 KB) project\_maximization-1.txt (3.4 KB) thank you

---

## [Defining constraints on specific indices of a set](https://discuss.ampl.com/t/defining-constraints-on-specific-indices-of-a-set/1061)

<div class="topic-metadata">

**Author:** [@johhat](https://discuss.ampl.com/u/johhat)\
**Replies:** 3\
**Last updated:** [April 25, 2024, 10:25pm UTC](https://discuss.ampl.com/t/defining-constraints-on-specific-indices-of-a-set/1061 "2024-04-25T22:25:48Z")

</div>

Hey, I would like to write a constraint like subject to constraint {i in jobs, j in jobs: j\<\>i, k in machines}: x\[i,k\] + x\[j,k\] = 0; which does not work due to an syntax error. Surprisingly subject to constraint …

---

## [Sparse matrix in objective function](https://discuss.ampl.com/t/sparse-matrix-in-objective-function/1059)

<div class="topic-metadata">

**Author:** [@juan.carlos](https://discuss.ampl.com/u/juan.carlos)\
**Replies:** 1\
**Last updated:** [April 20, 2024, 11:42pm UTC](https://discuss.ampl.com/t/sparse-matrix-in-objective-function/1059 "2024-04-20T23:42:56Z")

</div>

Hi, I have the following issues with a model I’m working on. This is my of: minimize obj: sum {i in I, j in J} x\[i,j\] \* sqrt((C2\[j\] - C2\[i\])^2 + (C1\[j\] - C1\[i\])^2) \* (M1\[i,j\]\*L1/2 + M2\[i,j\]\*L2); First of all, I …

---

## [Obtain reduced model after AMPL presolve](https://discuss.ampl.com/t/obtain-reduced-model-after-ampl-presolve/1050)

<div class="topic-metadata">

**Author:** [@Shuxue\_Jiaoshou](https://discuss.ampl.com/u/Shuxue_Jiaoshou)\
**Replies:** 2\
**Last updated:** [April 16, 2024, 4:09pm UTC](https://discuss.ampl.com/t/obtain-reduced-model-after-ampl-presolve/1050 "2024-04-16T16:09:36Z")

</div>

How can I obtain the reduced model — that is, the model after presolve has been applied by AMPL? It seems that I should use the solexpand command… Is this correct? Thanks. EDIT: I applied solexpand - but this appears…

---

## [Speeding up running time](https://discuss.ampl.com/t/speeding-up-running-time/1028)

<div class="topic-metadata">

**Author:** [@Sara\_Ghaboulian\_Zare](https://discuss.ampl.com/u/Sara_Ghaboulian_Zare)\
**Replies:** 5\
**Last updated:** [April 10, 2024, 4:16pm UTC](https://discuss.ampl.com/t/speeding-up-running-time/1028 "2024-04-10T16:16:20Z")

</div>

Hello, I’m working on a large-scale LP problem in AMPL, structured as follows: reset; model ETEM.mod; data \_EtemData.txt; data SAS\_modification.txt; option solver amplcplex; option cplex\_options 'display=1 clocktype=2 …

---

## [Right hand side of constraints](https://discuss.ampl.com/t/right-hand-side-of-constraints/325)

<div class="topic-metadata">

**Author:** [@sadeghia](https://discuss.ampl.com/u/sadeghia)\
**Replies:** 7\
**Last updated:** [April 8, 2024, 6:56pm UTC](https://discuss.ampl.com/t/right-hand-side-of-constraints/325 "2024-04-08T18:56:19Z")

</div>

Hello, In an optimization model that I coded in AMPL, I need to export right hand side of the constraints to excel. This is required for optimization App in Matlab that I use. Is there any command to do that? Here is t…

---

## [Suggestions on model](https://discuss.ampl.com/t/suggestions-on-model/1004)

<div class="topic-metadata">

**Author:** [@acs2222](https://discuss.ampl.com/u/acs2222)\
**Replies:** 6\
**Last updated:** [March 27, 2024, 8:49pm UTC](https://discuss.ampl.com/t/suggestions-on-model/1004 "2024-03-27T20:49:53Z")

</div>

hi, i am trying to make an automated class scheduling . Can you suggest how can i constraint the assignment of rooms only to their predefined buildings only. Also how to avoid assigning time in between lunchbreak update…

---

## [Bilevel Optimization, DEA, argmax](https://discuss.ampl.com/t/bilevel-optimization-dea-argmax/1018)

<div class="topic-metadata">

**Author:** [@ad1406](https://discuss.ampl.com/u/ad1406)\
**Replies:** 1\
**Last updated:** [March 27, 2024, 8:03pm UTC](https://discuss.ampl.com/t/bilevel-optimization-dea-argmax/1018 "2024-03-27T20:03:44Z")

</div>

Hello I am new here. Can anyone provide me an example of coding a bilevel program? Do I need to specify any solver for bilevel optimization? Also how to write a DEA model for a small no. of DMUs to find efficiency scores…

---

## [Error in Couenne in amplpy](https://discuss.ampl.com/t/error-in-couenne-in-amplpy/1022)

<div class="topic-metadata">

**Author:** [@Monish\_Kumar](https://discuss.ampl.com/u/Monish_Kumar)\
**Replies:** 1\
**Last updated:** [March 27, 2024, 5:37am UTC](https://discuss.ampl.com/t/error-in-couenne-in-amplpy/1022 "2024-03-27T05:37:39Z")

</div>

I am getting the following message when I run the solver with couenne using amplpy Couenne 0.5.8 – an Open-Source solver for Mixed Integer Nonlinear Optimization Mailing list: couenne@list.coin-or.org Instructions: Co…

---

## [Syntax error in ampl](https://discuss.ampl.com/t/syntax-error-in-ampl/1012)

<div class="topic-metadata">

**Author:** [@CE93](https://discuss.ampl.com/u/CE93)\
**Replies:** 2\
**Last updated:** [March 25, 2024, 6:20pm UTC](https://discuss.ampl.com/t/syntax-error-in-ampl/1012 "2024-03-25T18:20:46Z")

</div>

Hi. I’m new in AMPL. I have a quick question. set YEARS; # Set representing the years set UNITS; # Set representing the types of units param demand{YEAR in YEARS}; # Demand data for each year param capacity{UNIT in UNI…

---

## [Python: use results of a solution](https://discuss.ampl.com/t/python-use-results-of-a-solution/945)

<div class="topic-metadata">

**Author:** [@juan.carlos](https://discuss.ampl.com/u/juan.carlos)\
**Replies:** 15\
**Last updated:** [March 24, 2024, 2:13am UTC](https://discuss.ampl.com/t/python-use-results-of-a-solution/945 "2024-03-24T02:13:34Z")

</div>

I’m using amplpy. The picture above is the results of variable X of a model1 solved. How can I set in model2 this restriction: x\[1,1,1\]=0 ? I’m trying to use the result of model1 as restriction of a model2. Thanks …

---

## [If then Else throwing syntax error](https://discuss.ampl.com/t/if-then-else-throwing-syntax-error/1001)

<div class="topic-metadata">

**Author:** [@jantoun](https://discuss.ampl.com/u/jantoun)\
**Replies:** 2\
**Last updated:** [March 19, 2024, 2:12am UTC](https://discuss.ampl.com/t/if-then-else-throwing-syntax-error/1001 "2024-03-19T02:12:02Z")

</div>

Hello, I am trying to use if-ten-else in AMPL modeling in python. I am getting the following error: line 53 offset 1806 syntax error context: \>\>\> else \<\<\< The constraint looks like: subject to battery\_level\_const…

---

## [Syntax error AMPL var](https://discuss.ampl.com/t/syntax-error-ampl-var/985)

<div class="topic-metadata">

**Author:** [@shajida\_rahman](https://discuss.ampl.com/u/shajida_rahman)\
**Replies:** 5\
**Last updated:** [March 11, 2024, 4:35pm UTC](https://discuss.ampl.com/t/syntax-error-ampl-var/985 "2024-03-11T16:35:52Z")

</div>

Hi, I am a beginner in using AMPL along with CPLEXto make a MILP model where I am trying to minimise energy consumption. I am testing my model but have run into these errors. I would appreciate any tips or he…

---

## [Summation Syntax Question](https://discuss.ampl.com/t/summation-syntax-question/988)

<div class="topic-metadata">

**Author:** [@N\_P](https://discuss.ampl.com/u/N_P)\
**Replies:** 1\
**Last updated:** [March 8, 2024, 5:26pm UTC](https://discuss.ampl.com/t/summation-syntax-question/988 "2024-03-08T17:26:40Z")

</div>

Hello, I am trying to use a double summation in my Objective function - first sum over i from 1 to n, second sum over j from 1 to n ; where j is not i. Not sure how to write this in AMPL, so what I got is (sum{i in 1.…

[Next page](https://discuss.ampl.com/tag/modeling/53.md?match_all_tags=true&page=1&tags%5B%5D=modeling)
