Difference: VariablesInAMPL (7 vs. 8)

Revision 82011-09-16 - MichaelOSullivan

Line: 1 to 1
 
META TOPICPARENT name="AMPLSyntax"
<-- Ready to Review -->

Variables in AMPL

Line: 63 to 63
  Note There are many attributes that may follow a variable declaration. They can be placed in any order and must be separated by either whitespace or commas.
var Percentage {INGREDIENTS} <= 0, >= 100;
var Production {SURFBOARDS} integer >= 0; 
Added:
>
>

Parameters as Bounds

To use parameters as bounds you first need to define the parameters, then use them when defining the variable, By using defaults you only need to define bounds when necessary:

param lb {FEEDS} default 0; # Could use -Infinity here
param ub {FEEDS} default Infinity;

var Amount {f in FEEDS} >= lb[f] <= ub[f]; # Amount[f] >= 0 for all f by default

data;

param lb :=
  GRAIN 1
;

param ub :=
  GRAIN 10
  PASTURE 6
;

# The amount of grain is between 1 and 10, the amoun tof pasture is <= 6, all amounts are >= 0
 Return to top

Initial Values

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback