# New to AMPL

**URL:** https://discuss.ampl.com/c/new-to-ampl/41.md

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

---

## [About the New to AMPL category](https://discuss.ampl.com/t/about-the-new-to-ampl-category/150)

<div class="topic-metadata">

**Author:** [@fdabrandao](https://discuss.ampl.com/u/fdabrandao)\
**Replies:** 0\
**Last updated:** [November 28, 2022, 12:50pm UTC](https://discuss.ampl.com/t/about-the-new-to-ampl-category/150 "2022-11-28T12:50:13Z")

</div>

Are you new to AMPL and not sure how to get started? Ask here any questions you may have.

---

## [Activation unsuccessful](https://discuss.ampl.com/t/activation-unsuccessful/2281)

<div class="topic-metadata">

**Author:** [@Robert\_Lin](https://discuss.ampl.com/u/Robert_Lin)\
**Replies:** 1\
**Last updated:** [September 9, 2026, 1:00pm UTC](https://discuss.ampl.com/t/activation-unsuccessful/2281 "2026-09-09T13:00:14Z")

</div>

When I type in the UUID, for activating my installation, it doesn’t work, but it works for other students.

---

## [Common subexpressions](https://discuss.ampl.com/t/common-subexpressions/2232)

<div class="topic-metadata">

**Author:** [@\_nr](https://discuss.ampl.com/u/_nr)\
**Replies:** 1\
**Last updated:** [April 8, 2026, 6:52pm UTC](https://discuss.ampl.com/t/common-subexpressions/2232 "2026-04-08T18:52:46Z")

</div>

Does AMPL internally do any common subexpression elimination (CSE) with the algebraic expressions? The expressions in my AMPL model can become quite large. However, the model will have many common subexpressions. If AMPL…

---

## [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…

---

## [Error in VS Code but runs fine in Google Colab notebook](https://discuss.ampl.com/t/error-in-vs-code-but-runs-fine-in-google-colab-notebook/2223)

<div class="topic-metadata">

**Author:** [@teclipse3](https://discuss.ampl.com/u/teclipse3)\
**Replies:** 0\
**Last updated:** [January 31, 2026, 3:35pm UTC](https://discuss.ampl.com/t/error-in-vs-code-but-runs-fine-in-google-colab-notebook/2223 "2026-01-31T15:35:58Z")

</div>

Here is the code that I run in VS Code (which runs fine in a Google Colab notebook) and the error message that I get when running in VS Code. I included my import statement that was run in a previous cell. from amplpy …

---

## [Interpreting presolve output](https://discuss.ampl.com/t/interpreting-presolve-output/2215)

<div class="topic-metadata">

**Author:** [@\_nr](https://discuss.ampl.com/u/_nr)\
**Replies:** 4\
**Last updated:** [January 19, 2026, 2:16am UTC](https://discuss.ampl.com/t/interpreting-presolve-output/2215 "2026-01-19T02:16:57Z")

</div>

How should I interpret the output of show\_stats with respect to the original model (the one prior to the presolve step)? I’m trying to understand the meaning behind the number of eliminated variables and constraints rep…

---

## [Size limits even with the free open-source solvers](https://discuss.ampl.com/t/size-limits-even-with-the-free-open-source-solvers/2211)

<div class="topic-metadata">

**Author:** [@ibuh](https://discuss.ampl.com/u/ibuh)\
**Replies:** 1\
**Last updated:** [November 17, 2025, 8:58pm UTC](https://discuss.ampl.com/t/size-limits-even-with-the-free-open-source-solvers/2211 "2025-11-17T20:58:48Z")

</div>

Hi, I’m trying to run a MILP problem and I receive the error message: Sorry, a demo license is limited to 300 variables and 300 constraints and objectives. You have 340 variables, 128 constraints, and 1 objective. e…

---

## [Open source complementarity solver?](https://discuss.ampl.com/t/open-source-complementarity-solver/2205)

<div class="topic-metadata">

**Author:** [@jsm5712](https://discuss.ampl.com/u/jsm5712)\
**Replies:** 4\
**Last updated:** [November 6, 2025, 7:19pm UTC](https://discuss.ampl.com/t/open-source-complementarity-solver/2205 "2025-11-06T19:19:14Z")

</div>

I am interested in using the open-source solvers in AMPL for a nonlinear complementarity problem. I have it working in a paid version of GAMS using PATH; I just want to try it out in AMPL. It’s not an optimization proble…

---

## [My uuid is not being recognized by AMPL.exe](https://discuss.ampl.com/t/my-uuid-is-not-being-recognized-by-ampl-exe/2206)

<div class="topic-metadata">

**Author:** [@Ian\_Kong](https://discuss.ampl.com/u/Ian_Kong)\
**Replies:** 1\
**Last updated:** [November 4, 2025, 8:01pm UTC](https://discuss.ampl.com/t/my-uuid-is-not-being-recognized-by-ampl-exe/2206 "2025-11-04T20:01:14Z")

</div>

When I type the command: ampl: shell “amplkey activate --uuid ”; Ampl reads back: ‘amplkey’ is not recognized as an internal or external command, operable program or batch file. exit value 1 I may have activated th…

---

## [Issue With Syntax For BARON Solver](https://discuss.ampl.com/t/issue-with-syntax-for-baron-solver/2202)

<div class="topic-metadata">

**Author:** [@DeGoodma5](https://discuss.ampl.com/u/DeGoodma5)\
**Replies:** 1\
**Last updated:** [November 4, 2025, 3:30pm UTC](https://discuss.ampl.com/t/issue-with-syntax-for-baron-solver/2202 "2025-11-04T15:30:04Z")

</div>

Hello I am having issues with using BARON to solve an optimization problem. Right now I am receiving errors about syntax errors concerning the use of scientific notation. Below is the error I am receiving: \[ERROR\] lin…

---

## [Question About Setting Up BARON Solver](https://discuss.ampl.com/t/question-about-setting-up-baron-solver/2200)

<div class="topic-metadata">

**Author:** [@DeGoodma5](https://discuss.ampl.com/u/DeGoodma5)\
**Replies:** 14\
**Last updated:** [October 22, 2025, 5:50pm UTC](https://discuss.ampl.com/t/question-about-setting-up-baron-solver/2200 "2025-10-22T17:50:58Z")

</div>

I am confused on why my code in VS code that uses python says that BARON does not have a license. I set up everything but the terminal seems to not see the license since it is cloud based.

---

## [Finding AMPL Book Solution](https://discuss.ampl.com/t/finding-ampl-book-solution/407)

<div class="topic-metadata">

**Author:** [@Alan\_Chase](https://discuss.ampl.com/u/Alan_Chase)\
**Replies:** 14\
**Last updated:** [September 11, 2025, 4:50pm UTC](https://discuss.ampl.com/t/finding-ampl-book-solution/407 "2025-09-11T16:50:39Z")

</div>

Hi to everyone. Where can I find the solution to the AMPL Book? Thanks in advance.

---

## [I'm working on a MINLP model where small changes in input constants (e.g., 1e-1 vs 1e-2) are leading to inconsistent results, suggesting possible model sensitivity](https://discuss.ampl.com/t/im-working-on-a-minlp-model-where-small-changes-in-input-constants-e-g-1e-1-vs-1e-2-are-leading-to-inconsistent-results-suggesting-possible-model-sensitivity/2139)

<div class="topic-metadata">

**Author:** [@Sarishma\_Bhandari](https://discuss.ampl.com/u/Sarishma_Bhandari)\
**Replies:** 1\
**Last updated:** [May 27, 2025, 3:57pm UTC](https://discuss.ampl.com/t/im-working-on-a-minlp-model-where-small-changes-in-input-constants-e-g-1e-1-vs-1e-2-are-leading-to-inconsistent-results-suggesting-possible-model-sensitivity/2139 "2025-05-27T15:57:07Z")

</div>

I’m working on a MINLP optimization model and noticing unexpected results when I change a constant input by some factor. For example, adjusting the input by 1e-1 gives incorrect results, but a smaller change like 1e-2 yi…

---

## [Straw that broke the camel’s back](https://discuss.ampl.com/t/straw-that-broke-the-camel-s-back/2080)

<div class="topic-metadata">

**Author:** [@Rafa1](https://discuss.ampl.com/u/Rafa1)\
**Replies:** 1\
**Last updated:** [March 20, 2025, 7:07pm UTC](https://discuss.ampl.com/t/straw-that-broke-the-camel-s-back/2080 "2025-03-20T19:07:08Z")

</div>

After many attempts, I stopped using AMPL. The cabalistic nature of the language, the very poor documentation and the lack of artificial intelligence to help in code development make the effort overwhelming and hours ar…

---

## [Decimal display](https://discuss.ampl.com/t/decimal-display/2067)

<div class="topic-metadata">

**Author:** [@dmorill](https://discuss.ampl.com/u/dmorill)\
**Replies:** 1\
**Last updated:** [February 24, 2025, 3:38pm UTC](https://discuss.ampl.com/t/decimal-display/2067 "2025-02-24T15:38:36Z")

</div>

Hello community, I have an issue displaying the results, and I hope you can help me. I have a MILP model with two binary variables (y, w) and one continuous variable (x). Despite using the command: option cplex\_options…

---

## [Gsl\_ran\_gaussian](https://discuss.ampl.com/t/gsl-ran-gaussian/2052)

<div class="topic-metadata">

**Author:** [@Laura\_Rodriguez](https://discuss.ampl.com/u/Laura_Rodriguez)\
**Replies:** 1\
**Last updated:** [February 11, 2025, 5:07pm UTC](https://discuss.ampl.com/t/gsl-ran-gaussian/2052 "2025-02-11T17:07:21Z")

</div>

Greetings everyone! Im trying to implement the gsl\_ran\_gaussian function to my dataset. I need random numbers with a 3% variation from my data but I’m getting the following message: gauss.mod, line 6 (offset 130): Fun…

---

## [Grouping houly data into days to find max parameter values](https://discuss.ampl.com/t/grouping-houly-data-into-days-to-find-max-parameter-values/2042)

<div class="topic-metadata">

**Author:** [@mcaballero305](https://discuss.ampl.com/u/mcaballero305)\
**Replies:** 1\
**Last updated:** [January 27, 2025, 12:24am UTC](https://discuss.ampl.com/t/grouping-houly-data-into-days-to-find-max-parameter-values/2042 "2025-01-27T00:24:28Z")

</div>

Hi, I am trying to upload data from a csv file to define sets and parameters. I have a.mod and .run file that works to return max parameter volume when I have just one index column (Hour). But when I try to add another …

---

## [Downloading info to excel](https://discuss.ampl.com/t/downloading-info-to-excel/2029)

<div class="topic-metadata">

**Author:** [@Laura\_Rodriguez](https://discuss.ampl.com/u/Laura_Rodriguez)\
**Replies:** 1\
**Last updated:** [January 14, 2025, 6:57pm UTC](https://discuss.ampl.com/t/downloading-info-to-excel/2029 "2025-01-14T18:57:24Z")

</div>

Hello eveybody. I would like to automatically download my results from the AMPL console to and excel spreadsheet or a .csv but im not familiar with the way i can do it. If someone can provide further info I’d appreciate…

---

## [Do I really need Microsoft Visual Studio C++ 14.0 to run AMPL with Python?](https://discuss.ampl.com/t/do-i-really-need-microsoft-visual-studio-c-14-0-to-run-ampl-with-python/2011)

<div class="topic-metadata">

**Author:** [@Hugo](https://discuss.ampl.com/u/Hugo)\
**Replies:** 1\
**Last updated:** [December 17, 2024, 4:08pm UTC](https://discuss.ampl.com/t/do-i-really-need-microsoft-visual-studio-c-14-0-to-run-ampl-with-python/2011 "2024-12-17T16:08:24Z")

</div>

After installing AMPL using the .exe file, I tried following the instructions to run AMPL and the solvers as variables in Python. The first line of code I ran was python -m pip install amplpy --upgrade Here’s the error…

---

## [Error running data mod (d is not a param (or var or constraint or objective))](https://discuss.ampl.com/t/error-running-data-mod-d-is-not-a-param-or-var-or-constraint-or-objective/1962)

<div class="topic-metadata">

**Author:** [@Linh\_Tran](https://discuss.ampl.com/u/Linh_Tran)\
**Replies:** 1\
**Last updated:** [October 27, 2024, 2:21am UTC](https://discuss.ampl.com/t/error-running-data-mod-d-is-not-a-param-or-var-or-constraint-or-objective/1962 "2024-10-27T02:21:29Z")

</div>

Hi Im running AMPL on a mac and Im trying to solve an LP model using AMPL. I keep running to this error constantly where it says: "d is not a param (or var or constraint or objective) context: param \>\>\> d \<\<\< := " My…

---

## [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; …

---

## [Problem with my sum command](https://discuss.ampl.com/t/problem-with-my-sum-command/1953)

<div class="topic-metadata">

**Author:** [@Anwar\_M](https://discuss.ampl.com/u/Anwar_M)\
**Replies:** 0\
**Last updated:** [October 16, 2024, 9:49pm UTC](https://discuss.ampl.com/t/problem-with-my-sum-command/1953 "2024-10-16T21:49:31Z")

</div>

Hello everyone I had mistakes in my mod, which I already corrected due to communication with my prof. but I still have two issues: Once it says that the tern I is already defined, because I have “var I” , but also “para…

---

## [SOS I have a test tomorrow](https://discuss.ampl.com/t/sos-i-have-a-test-tomorrow/1220)

<div class="topic-metadata">

**Author:** [@Bui\_Hoang\_Linh](https://discuss.ampl.com/u/Bui_Hoang_Linh)\
**Replies:** 1\
**Last updated:** [September 28, 2024, 12:46am UTC](https://discuss.ampl.com/t/sos-i-have-a-test-tomorrow/1220 "2024-09-28T00:46:13Z")

</div>

I get the syntax error code for the total code as follow. and I couldn’t figure it out. Please help reset; option solver cplex; param N\>=0; set NODES; # Define parameters param supply{NODES}; param profit{NODES}; par…

---

## [How to autofill while coding in AMPL](https://discuss.ampl.com/t/how-to-autofill-while-coding-in-ampl/1187)

<div class="topic-metadata">

**Author:** [@buitrunghiep](https://discuss.ampl.com/u/buitrunghiep)\
**Replies:** 1\
**Last updated:** [August 29, 2024, 6:51pm UTC](https://discuss.ampl.com/t/how-to-autofill-while-coding-in-ampl/1187 "2024-08-29T18:51:40Z")

</div>

Dear friends, Would you please tell me how to autofill the code while typing in AMPL? Thank you.

---

## [Ampl erorr in phase I ITERATION](https://discuss.ampl.com/t/ampl-erorr-in-phase-i-iteration/1180)

<div class="topic-metadata">

**Author:** [@ibronuhu3434](https://discuss.ampl.com/u/ibronuhu3434)\
**Replies:** 1\
**Last updated:** [August 19, 2024, 7:16pm UTC](https://discuss.ampl.com/t/ampl-erorr-in-phase-i-iteration/1180 "2024-08-19T19:16:33Z")

</div>

hello, am having problems with my phase I iteration if someone could help me,here are my model, data and run ### SUBPROBLEM ### set COLL; # collecton points set DIS; # disposal sites set CON; # conveyance param supp…

---

## [Cubic term linearization](https://discuss.ampl.com/t/cubic-term-linearization/1172)

<div class="topic-metadata">

**Author:** [@Sarah\_O](https://discuss.ampl.com/u/Sarah_O)\
**Replies:** 1\
**Last updated:** [August 7, 2024, 2:24pm UTC](https://discuss.ampl.com/t/cubic-term-linearization/1172 "2024-08-07T14:24:20Z")

</div>

Hi, If I have a cubic term as x.y.v, where x and y are binary variables and v is a continuous variable. Can I linearize it by introducing an auxillary variable w = y.v and then introduce another auxillary variable z = x…

---

## [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 …

---

## [Constraint that verify binary variable get the same value for at least 4 consecutive points. not sure what approach should i take](https://discuss.ampl.com/t/constraint-that-verify-binary-variable-get-the-same-value-for-at-least-4-consecutive-points-not-sure-what-approach-should-i-take/1168)

<div class="topic-metadata">

**Author:** [@Kobi\_Zohar](https://discuss.ampl.com/u/Kobi_Zohar)\
**Replies:** 1\
**Last updated:** [July 26, 2024, 12:59am UTC](https://discuss.ampl.com/t/constraint-that-verify-binary-variable-get-the-same-value-for-at-least-4-consecutive-points-not-sure-what-approach-should-i-take/1168 "2024-07-26T00:59:52Z")

</div>

set T := 1…card(I); #I is timestamp, so i converted to number param idx\_to\_time {T} symbolic := ord(I, I); subject to 4\_consecutive\_points {t in T: t \>=1,\<= card(I) - 4}: y\_ind\[t\] != y\_ind\[t-1\] ==\> y\_ind\[t\] + y…

---

## [Problems fixing values and re-optimizing (AMPL/CPLEX/GUROBI)](https://discuss.ampl.com/t/problems-fixing-values-and-re-optimizing-ampl-cplex-gurobi/1140)

<div class="topic-metadata">

**Author:** [@Rafa1](https://discuss.ampl.com/u/Rafa1)\
**Replies:** 4\
**Last updated:** [July 5, 2024, 8:33pm UTC](https://discuss.ampl.com/t/problems-fixing-values-and-re-optimizing-ampl-cplex-gurobi/1140 "2024-07-05T20:33:44Z")

</div>

I have a problem that takes place over a finite time horizon. I solve and get a satisfactory solution. Then, I want to analyze the impact of an event not previously contemplated, of which I know its “form” and its (dis…

---

## [An error occurs when the.run file is written in matlab](https://discuss.ampl.com/t/an-error-occurs-when-the-run-file-is-written-in-matlab/494)

<div class="topic-metadata">

**Author:** [@Yuanmin](https://discuss.ampl.com/u/Yuanmin)\
**Replies:** 5\
**Last updated:** [April 25, 2024, 10:32pm UTC](https://discuss.ampl.com/t/an-error-occurs-when-the-run-file-is-written-in-matlab/494 "2024-04-25T22:32:51Z")

</div>

I am a new user of ampl and recently tried to make calls in matlab. This is the.run file I wrote. reset; model model.mod; include data.INIVAL; #option solver path “E:/AMPL/amplbundle.mswin64/ampl.mswin64”; #option so…

[Next page](https://discuss.ampl.com/c/new-to-ampl/41.md?page=1)
