OptimJ

OptimJ
Paradigmobject-oriented
Designed byAteji
First appeared2006 (2006)
Websitewww.Ateji.com
Influenced by
Java

OptimJ is an extension for Java with language support for writing optimization models and abstractions for bulk data processing. The extensions and the proprietary product implementing the extensions were developed by Ateji which went out of business in September 2011.[1] OptimJ aims at providing a clear and concise algebraic notation for optimization modeling, removing compatibility barriers between optimization modeling and application programming tools, and bringing software engineering techniques such as object-orientation and modern IDE support to optimization experts.

OptimJ models are directly compatible with Java source code, existing Java libraries such as database access, Excel connection or graphical interfaces. OptimJ is compatible with development tools such as Eclipse, CVS, JUnit or JavaDoc. OptimJ is available free with the following solvers: lp_solve, glpk, LP or MPS file formats and also supports the following commercial solvers: MOSEK, IBM ILOG CPLEX Optimization Studio.

Language concepts

OptimJ combines concepts from object-oriented imperative languages with concepts from algebraic modeling languages for optimization problems. Here we will review the optimization concepts added to Java, starting with a concrete example.

The example of map coloring

The goal of a map coloring problem is to color a map so that regions sharing a common border have different colors. It can be expressed in OptimJ as follows.

package examples;

// a simple model for the map-coloring problem
public model SimpleColoring solver lpsolve
{
  // maximum number of colors
  int nbColors = 4;

  // decision variables hold the color of each country
  var int belgium in 1 .. nbColors;
  var int denmark in 1 .. nbColors;
  var int germany in 1 .. nbColors;

  // neighbouring countries must have a different color
  constraints {
    belgium != germany;
    germany != denmark;
  }

  // a main entry point to test our model
  public static void main(String[] args)
  {
    // instantiate the model
    SimpleColoring m = new SimpleColoring();

    // solve it
    m.extract();
    m.solve();

    // print solutions
    System.out.println("Belgium: " + m.value(m.belgium));
    System.out.println("Denmark: " + m.value(m.denmark));
    System.out.println("Germany: " + m.value(m.germany));
  }
}

Readers familiar with Java will notice a strong similarity with this language. Indeed, OptimJ is a conservative extension of Java: every valid Java program is also a valid OptimJ program and has the same behavior.

This map coloring example also shows features specific to optimization that have no direct equivalent in Java, introduced by the keywords model, var, constraints.

OR-specific concepts

Models

A model is an extension of a Java class that can contain not only fields and methods but also constraints and an objective function. It is introduced by the model keyword and follows the same rules as class declarations. A non-abstract model must be linked to a solver, introduced by the keyword solver. The capabilities of the solver will determine what kind of constraints can be expressed in the model, for instance a linear solver such as lp solve will only allow linear constraints.

public model SimpleColoring solver lpsolve

Decision variables

Imperative languages such as Java provide a notion of imperative variables, which basically represent memory locations that can be written to and read from.

OptimJ also introduces the notion of a decision variable, which basically represents an unknown quantity whose value one is searching. A solution to an optimization problem is a set of values for all its decision variables that respects the constraints of the problem—without decision variables, it would not possible to express optimization problems. The term "decision variable" comes from the optimization community, but decision variables in OptimJ are the same concept as logical variables in logical languages such as Prolog.

Decision variables have special types introduced by the keyword var. There is a var type for each possible Java type.

  // a var type for a Java primitive type
  var int x;

  // a var type for a user-defined class
  var MyClass y;

In the map coloring example, decision variables were introduced together with the range of values they may take.

  var int germany in 1 .. nbColors;

This is just a shorthand equivalent to putting a constraint on the variable.

Constraints

Constraints express conditions that must be true in any solution of the problem. A constraint can be any Java boolean expression involving decision variables.

In the map coloring example, this set of constraints states that in any solution to the map coloring problem, the color of Belgium must be different from the color of Germany, and the color of Germany must be different from the color of Denmark.

  constraints {
    belgium != germany;
    germany != denmark;
  }

The operator != is the standard Java not-equal operator.

Constraints typically come in batches and can be quantified with the forall operator. For instance, instead of listing all countries and their neighbors explicitly in the source code, one may have an array of countries, an array of decision variables representing the color of each country, and an array boolean[][] neighboring or a predicate (a boolean function) boolean isNeighbor().

constraints {
  forall(Country c1 : countries, Country c2 : countries, :isNeighbor(c1,c2)) {
    color[c1] != color[c2];
  }
}

Country c1 : countries is a generator: it iterates c1 over all the values in the collection countries.

:isNeighbor(c1,c2) is a filter: it keeps only the generated values for which the predicate is true (the symbol : may be read as "if").

Assuming that the array countries contains belgium, germany and denmark, and that the predicate isNeighbor returns true for the couples (Belgium , Germany) and (Germany, Denmark), then this code is equivalent to the constraints block of the original map coloring example.

Objectives

Optionally, when a model describes an optimization problem, an objective function to be minimized or maximized can be stated in the model.

Generalist concepts

Generalist concepts are programming concepts that are not specific to OR problems and would make sense for any kind of application development. The generalist concepts added to Java by OptimJ make the expression of OR models easier or more concise. They are often present in older modeling languages and thus provide OR experts with a familiar way of expressing their models.

Associative arrays

While Java arrays can only be indexed by 0-based integers, OptimJ arrays can be indexed by values of any type. Such arrays are typically called associative arrays or maps. In this example, the array age contains the age of persons, identified by their name:

  int[String] age;

The type int[String] denoting an array of int indexed by String. Accessing OptimJ arrays using the standard Java syntax:

  age["Stephan"] = 37;
  x = age["Lynda"];

Traditionally, associative arrays are heavily used in the expression of optimization problems. OptimJ associative arrays are very handy when associated to their specific initialization syntax. Initial values can be given in intensional definition, as in:

int[String] age = { 
  "Stephan" -> 37,
  "Lynda"   -> 29 
};

or can be given in extensional definition, as in:

  int[String] length[String name : names] = name.length();

Here each of the entries length[i] is initialized with names[i].length().

Extended initialization

Tuples

Tuples are ubiquitous in computing, but absent from most mainstream languages including Java. OptimJ provides a notion of tuple at the language level that can be very useful as indexes in combination with associative arrays.

  (: int, String :) myTuple = new (: 3, "Three" :);
  String s = myTuple#1;

Tuple types and tuple values are both written between (: and :).

Ranges

Comprehensions

Comprehensions, also called aggregates operations or reductions, are OptimJ expressions that extend a given binary operation over a collection of values. A common example is the sum:

  // the sum of all integers from 1 to 10
  int k = sum { i | int i in 1 .. 10};

This construction is very similar to the big-sigma summation notation used in mathematics, with a syntax compatible with the Java language.

Comprehensions can also be used to build collections, such as lists, sets, multisets or maps:

  // the set of all integers from 1 to 10
  HashSet<Integer> s = `hashSet(){ i | int i in 1 .. 10};

Comprehension expressions can have an arbitrary expression as target, as in:

  // the sum of all squares of integers from 1 to 10
  int k = sum { i*i | int i in 1 .. 10};

They can also have an arbitrary number of generators and filters:

  // the sum of all f(i,j), for 0<=i<10, 1<=j<=10 and i!=j 
  int k = sum{ f(i,j) | int i : 10, int j : 1 .. 10, :i!=j }

Comprehension need not apply only to numeric values. Set or multiset-building comprehensions, especially in combination with tuples of strings, make it possible to express queries very similar to SQL database queries:

  // select name from persons where age > 18
  `multiSet(){ p.name | Person p : persons, :p.age > 18 }

In the context of optimization models, comprehension expressions provide a concise and expressive way to pre-process and clean the input data, and format the output data.

Development environment

OptimJ is available as an Eclipse plug-in. The compiler implements a source-to-source translation from OptimJ to standard Java, thus providing immediate compatibility with most development tools of the Java ecosystem.

OptimJ GUI and Rapid Prototyping

Since the OptimJ compiler knows about the structure of all data used in models, it is able to generate a structured graphical view of this data at compile-time. This is especially relevant in the case of associative arrays where the compiler knows the collections used for indexing the various dimensions.

The basic graphical view generated by the compiler is reminiscent of an OLAP cube. It can then be customized in many different ways, from simple coloring up to providing new widgets for displaying data elements.

The compiler-generated OptimJ GUI saves the OR expert from writing all the glue code required when mapping graphical libraries to data. It enables rapid prototyping, by providing immediate visual hints about the structure of data.

Another part of the OptimJ GUI reports in real time performance statistics from the solver. This information can be used for understanding performance problems and improving solving time. At this time, it is available only for lp_solve.

Supported solvers

OptimJ is available for free with the following solvers lp_solve, glpk, LP or MPS file formats and also supports the following commercial solvers: Mosek, IBM ILOG CPLEX Optimization Studio.

References

  1. ^ "Ateji is closed". Retrieved 2012-01-11.


Read other articles:

Artikel ini bukan mengenai Sohun. Bihun Sehelai bihun Nama Tionghoa Hanzi: 米粉 Alih aksara Mandarin - Hanyu Pinyin: mífěn Min Nan - Romanisasi POJ: bí-hún Wu - RomanisasiBahasa Shanghai: mi3 fen1 Yue (Kantonis) - Jyutping: mai3 fen2 Nama Filipina Tagalog: bihon atau bijon Nama Melayu Melayu: bihun Nama Vietnam Vietnam: bún Nama Tamil Tamil: சேவை (sevai) Nama Thai Thai: เส้นหมี่ (sen mee) Bihun (Hokkien:米粉; dialek Xiamen bí hún) adalah nama salah satu jeni...

 

Brain WorksPoster promosiHangul두뇌공조 Alih Aksara yang DisempurnakanDunoegongjo GenreKomedi[1]Ditulis olehPark Kyung-seon[2]SutradaraLee Jin-seo[2]Gu Seong-jun[2]PemeranJung Yong-hwaCha Tae-hyunKwak Sun-youngYe Ji-wonNegara asalKorea SelatanBahasa asliKoreaJmlh. episode16ProduksiDurasi75 menitRumah produksiSamhwa Networks[1]DistributorKBSRilis asliJaringanKBS2Rilis2 Januari (2023-01-02) –28 Februari 2023 (2023-2-28) Brain Works (...

 

The following is a timeline of the history of the city of Helsinki, Finland. This is a dynamic list and may never be able to satisfy particular standards for completeness. You can help by adding missing items with reliable sources. Prior to 19th century Part of a series onScandinavia Countries Denmark Finland Iceland Norway Sweden HistoryHistory by country Åland Denmark Faroe Islands Finland Greenland Iceland Norway Scotland Sweden Chronological history Prehistory Stone Age Bronze Age Iron ...

Planet CintaAlbum studio karya NaifDirilis2 Maret 2011Direkam2011GenrePopLabelCatz RecordsProduserNaifKronologi Naif A Night At Schouwburg (2008)A Night At Schouwburg2008 Planet Cinta (2011) 7 Bidadari (2017)7 Bidadari2017 Planet Cinta adalah album musik karya Naif yang dirilis pada tahun 2011. Album ini berisi 12 buah lagu dengan lagu utama Karena Kamu Cuma Satu. Daftar lagu Cuek Apa Adanya Karena Kamu Cuma Satu Buta Hati Planet Cinta Cinta Untuknya Hidup Penuh Cinta Tanpaku Berjalan Di ...

 

Disambiguazione – Talk Show rimanda qui. Se stai cercando altri significati, vedi Talk Show (disambigua). David Letterman intervista l'ospite Teri Garr in Late Night with David Letterman nel 1982 Il talk show o salotto televisivo è un comune genere di programmi televisivi e radiofonici che vedono protagoniste le parole e la conversazione.[1] I talk show possono essere costituiti da interviste, monologhi e/o discussioni di varia forma e natura generalmente sviluppate seguen...

 

Telkom beralih ke halaman ini. Untuk kegunaan lain, lihat Telkom (disambiguasi). PT Telkom Indonesia (Persero) TbkTelkom Landmark Tower di JakartaNama dagangTelkom IndonesiaSebelumnya Perusahaan Negara Telekomunikasi (1965–1974) Perusahaan Umum Telekomunikasi (Perumtel) (1974–1991) PT Telekomunikasi Indonesia (Persero) Tbk (nama pendek 1991–2020) JenisPerusahaan perseroan (Persero) terbukaPerusahaan negara/Perusahaan umum antara 1965 hingga 1991Kode emitenIDX: TLKMNYSE: TLKIndustriTekno...

Diagram of the proposed Beagle 3 Beagle 3[1][2] (also called Beagle 2: Evolution) was a proposed Mars lander mission to search for life on Mars, past or present. Beagle 3 was the proposed successor to the failed British Beagle 2 Mars lander, with which communication was lost. Beagle 3 was promoted by Professor Colin Pillinger, lead scientist on the Beagle 2. EADS Astrium also played a part in funding and early development of the project. Pillinger dreamed of launching up to t...

 

كورنيش جدة تقسيم إداري البلد  السعودية جدة تعديل مصدري - تعديل   كورنيش جدة يقع على الجزء الغربي من مدينة جدة المطل على ساحل البحر الأحمر ويبلغ طوله 110 كيلو متر، ويتميز بكثرة الفنادق العالمية والمراكز التجارية والملاهي والمنتزهات وتزينه نافورة جدة، وهو عبارة عن حيد من...

 

Lafasah Periode Late Miocene - present[1] Salvelinus Arctic char, Salvelinus alpinus alpinusTaksonomiKerajaanAnimaliaFilumChordataKelasActinopteriOrdoSalmoniformesFamiliSalmonidaeGenusSalvelinus Richardson, 1836 Subgenera Baione DeKay, 1842 Cristovomer Walbaum, 1792 Salvelinus J. Richardson, 1836 lbs Salvelinus adalah genus ikan salmon yang sering disebut lafasah atau ikan sar. Salvelinus adalah anggota subfamili Salmoninae dalam keluarga Salmonidae . Genus ini mempunyai distribusi si...

يفتقر محتوى هذه المقالة إلى الاستشهاد بمصادر. فضلاً، ساهم في تطوير هذه المقالة من خلال إضافة مصادر موثوق بها. أي معلومات غير موثقة يمكن التشكيك بها وإزالتها. (نوفمبر 2019) الدوري الأوروغواياني لكرة القدم 2014–15 تفاصيل الموسم الدوري الأوروغواياني الممتاز  النسخة 111  البلد ...

 

Painting by Gilbert Stuart Lansdowne portraitArtistGilbert StuartYear1796MediumOil on canvasDimensions247.6 cm × 158.7 cm (97.5 in × 62.5 in)LocationNational Portrait Gallery, Washington, D.C. The Lansdowne portrait is an iconic life-size portrait of George Washington painted by Gilbert Stuart in 1796. It depicts the 64-year-old president of the United States during his final year in office. The portrait was a gift to former British Prime Minister W...

 

Questa voce sull'argomento charadriiformes è solo un abbozzo. Contribuisci a migliorarla secondo le convenzioni di Wikipedia. Come leggere il tassoboxGabbiano glauco del PacificoLarus glaucescensStato di conservazioneRischio minimo Classificazione scientificaDominioEukaryota RegnoAnimalia PhylumChordata ClasseAves OrdineCharadriiformes FamigliaLaridae GenereLarus SpecieL. glaucescens Nomenclatura binomialeLarus glaucescensNaumann, 1840 Il gabbiano glauco del Pacifico (Larus glaucescens...

1985 single by Mental As AnythingYou're So Strong7-inch single UK coverSingle by Mental As Anythingfrom the album Fundamental B-sideThree Steps To Your Place (Aus) Bus Ride (Uk) SplashingReleasedMarch 1985[1]GenreRockLength3:25 5:29 (Extended version)LabelRegular Records, CBS Records, WEA Records, Epic RecordsSongwriter(s)Greedy SmithProducer(s)Richard GottehrerMental As Anything singles chronology Apocalypso (Wiping the Smile Off Santa's Face) (1984) You're So Strong (1985) Live It U...

 

ArgentinaCuartos de final Asociación UAR Confederación Sudamérica Rugby Participación 4ta Mejor resultado Fase de grupos1987, 1991 y 1995 Entrenador Alex Wyllie Capitán Lisandro Arbizu Indumentaria Adidas Máximo anotador Gonzalo Quesada (102) Más tries Diego AlbaneseAgustín Pichot 2 La Selección de rugby de Argentina fue una de los 20 países participantes de la Copa Mundial de Rugby de 1999 que tuvo como sede principal a Gales. En su cuarta participación los Pumas hicieron su mejo...

 

German film producer Alfred ZeislerBorn(1892-09-26)26 September 1892Chicago, Illinois, U.S.Died1 March 1985(1985-03-01) (aged 92)Camano Island, Washington, U.S.Occupation(s)Film producerFilm directorYears active1922–53SpouseLien Deyers (m.1934-div.1939) Alfred Zeisler (September 26, 1892 – March 1, 1985) was an American-born German film producer, director, actor and screenwriter. He produced 29 films between 1927 and 1936. He also directed 16 films between 1924 and 1949.[...

Men's association football team For the women's team, see Turkey women's national football team. TurkeyNickname(s)Ay-Yıldızlılar(The Crescent-Stars)[1]Bizim Çocuklar(Our Boys)AssociationTurkish Football Federation (TFF)ConfederationUEFA (Europe)Head coachVincenzo MontellaCaptainHakan ÇalhanoğluMost capsRüştü Reçber (120)Top scorerHakan Şükür (51)Home stadiumVariousFIFA codeTUR[2] First colours Second colours FIFA rankingCurrent 42 2 (20 June 2024)[3]Highes...

 

Last monarch of the Kingdom of Vientiane This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Anouvong – news · newspapers · books · scholar · JSTOR (March 2018) (Learn how and when to remove this message) For the district, see Anouvong district. Chao Anouvongເຈົ້າອານຸວົງສ໌เจ้า...

 

Octomotor OctomotorAsa voadora Northrop YB-49. Descrição Octomotor é a aeronave dotada de oito propulsores. Pode empregar tanto motores a pistão (como o Kalinin K-7 e o Hughes H-4 Hercules) quanto motores a jato (como o B-52 Stratofortress). Galeria Tupolev ANT-20 Convair YB-60 [1] B-52 Stratofortress Asa voadora Northrop YB-49 Hughes H-4 Hercules Ver também Monomotor Bimotor Trimotor Quadrimotor Hexamotor Referências ↑ U.S. Bombers de Lloyd S. Jones, Aero Publishers, 1974, ISBN 9780...

American activist (born 1932) Bill BairdBaird picketing National Right to Life Convention in June 2012Born (1932-06-20) June 20, 1932 (age 92)Brooklyn, New YorkOccupation(s)Reproductive rights advocate, speaker, social reformerAwardsHumanist Pioneer Award Bill Baird (born June 20, 1932) is a reproductive rights pioneer, called by some media the father of the birth control and abortion-rights movement.[1][2][3] He was jailed eight times in five states in the 1960s ...

 

French aristocrat This article relies largely or entirely on a single source. Relevant discussion may be found on the talk page. Please help improve this article by introducing citations to additional sources.Find sources: Amand-Marie-Jacques de Chastenet, Marquis of Puységur – news · newspapers · books · scholar · JSTOR (July 2014) Amand-Marie-Jacques de Chastenet, Marquis of PuységurAmand Marie Jacques de Chastenet, marquis de Puységur, pastel por...