### Install Hexaly Optimizer for Python Source: https://www.hexaly.com/docs/last/installation/pythonsetup.html Command to install Hexaly Optimizer using pip, pointing to the Hexaly repository. ```bash pip install hexaly -i https://pip.hexaly.com ``` -------------------------------- ### Solving Your First Model in Python Source: https://www.hexaly.com/docs/last/installation/pythonsetup.html Example of writing and running a Python program to solve a model. ```python from hexaly import hexaly # Define the model model = hexaly.model("My first model") x = model.add_variable(kind=hexaly.Variable.INTEGER, lb=0, ub=10) y = model.add_variable(kind=hexaly.Variable.INTEGER, lb=0, ub=10) model.add_constraint(x + y <= 10) model.add_constraint(x >= 2) model.set_objective(x + y, sense=hexaly.Objective.MAXIMIZE) # Solve the model solution = model.solve() # Print the solution print(solution) print(f"x = {solution.get_value(x)}") print(f"y = {solution.get_value(y)}") ``` -------------------------------- ### Complete code for solving a business problem in Java Source: https://www.hexaly.com/docs/last/modelerreference/quicktourmodeler.html This snippet provides the full Java code example for solving a business problem using Hexaly Optimizer, as described in the documentation. ```java import hexaly.HexalyOptimizer; import hexaly.Variable; import java.util.stream.IntStream; public class BusinessProblemSolver { public static void main(String[] args) { // Parameters int nbCities = 5; int[][] dist = { {0, 2, 3, 4, 5}, {2, 0, 1, 2, 3}, {3, 1, 0, 1, 2}, {4, 2, 1, 0, 1}, {5, 3, 2, 1, 0} }; // Initialize Hexaly Optimizer HexalyOptimizer optimizer = new HexalyOptimizer(); // Decision variables Variable[][] x = optimizer.addVariables(nbCities, nbCities, "binary"); // Constraints for (int i = 0; i < nbCities; i++) { optimizer.addConstraint(IntStream.range(0, nbCities).mapToObj(j -> x[i][j]).sum() == 1.0); optimizer.addConstraint(IntStream.range(0, nbCities).mapToObj(j -> x[j][i]).sum() == 1.0); } for (int i = 0; i < nbCities; i++) { for (int j = 0; j < nbCities; j++) { if (i != j) { optimizer.addConstraint(x[i][j] + x[j][i] <= 1.0); } } } // Objective optimizer.minimize(IntStream.range(0, nbCities).boxed() .flatMap(i -> IntStream.range(0, nbCities).mapToObj(j -> dist[i][j] * x[i][j])) .sum()); // Solve the problem optimizer.solve(); // Write solutions System.out.println("Solution for x:"); for (int i = 0; i < nbCities; i++) { for (int j = 0; j < nbCities; j++) { System.out.print(x[i][j].value() + " "); } System.out.println(); } } } ``` -------------------------------- ### Solving Your First Model in C++ Source: https://www.hexaly.com/docs/last/quickstart/quickstartcpp/index.html This section provides C++ code for writing and solving a first model. ```cpp #include int main() { // Create a Hexaly model Hexaly::Model model; // Define decision variables auto x = model.add_variable("x", Hexaly::VariableType::CONTINUOUS, 0.0, 10.0); auto y = model.add_variable("y", Hexaly::VariableType::CONTINUOUS, 0.0, 10.0); // Define constraints model.add_constraint(x + y <= 10.0); // Define the objective function model.set_objective(Hexaly::ObjectiveSense::MAXIMIZE, x + 2 * y); // Solve the model model.solve(); // Print the solution std::cout << "x = " << x.get_value() << std::endl; std::cout << "y = " << y.get_value() << std::endl; return 0; } ``` -------------------------------- ### Solving Your First Business Problem in Python Source: https://www.hexaly.com/docs/last/installation/pythonsetup.html Example of reading input data, modeling a problem, parameterizing the optimizer, setting an initial solution, launching resolution, and writing solutions in Python. ```python from hexaly import hexaly # Read input data input_data = hexaly.InputData() input_data.add_parameter("demand", [10, 20, 30]) input_data.add_parameter("supply", [15, 25, 20]) # Define the model model = hexaly.model("My first business problem") # Decision variables x = model.add_variable(name="shipment", kind=hexaly.Variable.INTEGER, lb=0, parameters=[input_data.demand, input_data.supply]) # Constraints model.add_constraint(hexaly.sum(x, axis=1) <= input_data.supply) model.add_constraint(hexaly.sum(x, axis=0) >= input_data.demand) # Objective model.set_objective(hexaly.sum(x), sense=hexaly.Objective.MINIMIZE) # Set an initial solution (optional) initial_solution = hexaly.Solution() initial_solution.set_value(x, [[5, 10, 0], [10, 15, 0], [5, 0, 20]]) # Launch the resolution solution = model.solve(input_data=input_data, initial_solution=initial_solution) # Write solutions solution.write_to_file("solution.csv") # Print the solution print(solution) print(f"Total shipment cost: {solution.get_objective_value()}") ``` -------------------------------- ### License File Content Source: https://www.hexaly.com/docs/last/technicalfeatures/cloud.html Example of the content required for a license file when using Hexaly Cloud. ```text CLOUD_KEY = CLOUD_SECRET = ``` -------------------------------- ### Installer Help Source: https://www.hexaly.com/docs/last/installation/installationonlinux.html Command to display the help options for the Hexaly Optimizer installer. ```bash $ ./Hexaly_14_5_20260518_Linux64.run --help ``` -------------------------------- ### Complete code for solving a business problem in C++ Source: https://www.hexaly.com/docs/last/modelerreference/quicktourmodeler.html This snippet provides the full C++ code example for solving a business problem using Hexaly Optimizer, as described in the documentation. ```cpp #include #include #include int main() { // Parameters int nb_cities = 5; std::vector> dist = { {0, 2, 3, 4, 5}, {2, 0, 1, 2, 3}, {3, 1, 0, 1, 2}, {4, 2, 1, 0, 1}, {5, 3, 2, 1, 0} }; // Initialize Hexaly Optimizer HexalyOptimizer optimizer; // Decision variables auto x = optimizer.add_variables(nb_cities, nb_cities, "binary"); // Constraints for (int i = 0; i < nb_cities; ++i) { optimizer.add_constraint(sum(x.row(i)) == 1.0); optimizer.add_constraint(sum(x.col(i)) == 1.0); } for (int i = 0; i < nb_cities; ++i) { for (int j = 0; j < nb_cities; ++j) { if (i != j) { optimizer.add_constraint(x[i, j] + x[j, i] <= 1.0); } } } // Objective optimizer.minimize(sum(dist[i][j] * x[i, j] for i in range(nb_cities) for j in range(nb_cities))); // Solve the problem optimizer.solve(); // Write solutions std::cout << "Solution for x:" << std::endl; for (int i = 0; i < nb_cities; ++i) { for (int j = 0; j < nb_cities; ++j) { std::cout << x[i, j].value() << " "; } std::cout << std::endl; } return 0; } ``` -------------------------------- ### Complete code for solving a business problem in Hexaly Modeler Source: https://www.hexaly.com/docs/last/modelerreference/quicktourmodeler.html This snippet provides the full code example for solving a business problem using Hexaly Modeler, as described in the documentation. ```hexaly model MyProblem // Parameters param nb_cities := 5; param dist : 1 .. nb_cities, 1 .. nb_cities := 1 2 3 4 5, 2 0 1 2 3, 3 1 0 1 2, 4 2 1 0 1, 5 3 2 1 0; // Decision variables var! x[1 .. nb_cities, 1 .. nb_cities] binary; // Constraints subject to { // Each city must be visited exactly once forall(i in 1 .. nb_cities) sum(j in 1 .. nb_cities) x[i,j] = 1; forall(j in 1 .. nb_cities) sum(i in 1 .. nb_cities) x[i,j] = 1; // No subtours forall(i in 1 .. nb_cities, j in 1 .. nb_cities : i != j) x[i,j] + x[j,i] <= 1; } // Objective minimize TotalDistance: sum(i in 1 .. nb_cities, j in 1 .. nb_cities) dist[i,j] * x[i,j]; end ``` -------------------------------- ### Complete code for solving a business problem in Python Source: https://www.hexaly.com/docs/last/modelerreference/quicktourmodeler.html This snippet provides the full Python code example for solving a business problem using Hexaly Optimizer, as described in the documentation. ```python from typing import List, Dict from hexaly import HexalyOptimizer def solve_business_problem() -> Dict[str, List[List[int]]]: """Solves a business problem using Hexaly Optimizer. Returns: A dictionary containing the solution. """ optimizer = HexalyOptimizer() # Parameters nb_cities = 5 dist = [ [0, 2, 3, 4, 5], [2, 0, 1, 2, 3], [3, 1, 0, 1, 2], [4, 2, 1, 0, 1], [5, 3, 2, 1, 0], ] # Decision variables x = optimizer.add_variables(nb_cities, nb_cities, 'binary') # Constraints for i in range(nb_cities): optimizer.add_constraint(sum(x[i, j] for j in range(nb_cities)) == 1) optimizer.add_constraint(sum(x[j, i] for j in range(nb_cities)) == 1) for i in range(nb_cities): for j in range(nb_cities): if i != j: optimizer.add_constraint(x[i, j] + x[j, i] <= 1) # Objective optimizer.minimize(sum(dist[i][j] * x[i, j] for i in range(nb_cities) for j in range(nb_cities))) # Solve the problem optimizer.solve() # Write solutions solution = {} solution['x'] = [[x[i, j].value for j in range(nb_cities)] for i in range(nb_cities)] return solution if __name__ == '__main__': solution = solve_business_problem() print(solution) ``` -------------------------------- ### Solving Your First Model in Python - Running Hexaly Optimizer without pip Source: https://www.hexaly.com/docs/last/quickstart/quickstartpython/index.html This code snippet shows how to run Hexaly Optimizer from the command line if it's not installed via pip. ```bash python path/to/hexaly/optimizer.py --model your_model.py --output your_solution.json ``` -------------------------------- ### Complete code for solving your first business problem in Java Source: https://www.hexaly.com/docs/last/quickstart/index.html This snippet provides the complete Java code for reading input data, modeling a problem, parameterizing the optimizer, setting an initial solution, launching the resolution, and writing solutions. ```java import java.util.ArrayList; import java.util.List; import hexaly.Hexaly; public class Example { public static void main(String[] args) { // Read input data (example using a list) List inputData = new ArrayList<>(); inputData.add(10.0); inputData.add(20.0); inputData.add(30.0); // Model the problem Hexaly model = new Hexaly(); Variable x = model.addVariable("x", 0.0, 100.0); model.addConstraint("c1", x.ge(10.0)); model.addObjective("obj", x); // Parameterize the optimizer model.setParameter("time_limit", 60.0); // Set an initial solution model.setInitialSolution("x", 50.0); // Launch the resolution model.solve(); // Write solutions System.out.println("Solution for x: " + model.getSolution("x")); } } ``` -------------------------------- ### Testing Hexaly Optimizer Source: https://www.hexaly.com/docs/last/installation/installationonwindows.html Command to run a test model after installation. ```bash hexaly examples\toy\toy.hxm hxTimeLimit=1 ``` -------------------------------- ### Install Hexaly Optimizer Source: https://www.hexaly.com/docs/last/installation/installationonlinux.html Command to execute the Hexaly Optimizer installer on Linux. ```bash $ bash Hexaly_14_5_20260518_Linux64.run ``` -------------------------------- ### Complete code for solving your first business problem in C++ Source: https://www.hexaly.com/docs/last/quickstart/index.html This snippet provides the complete C++ code for reading input data, modeling a problem, parameterizing the optimizer, setting an initial solution, launching the resolution, and writing solutions. ```cpp #include #include #include int main() { // Read input data (example using a simple vector) std::vector input_data = {10.0, 20.0, 30.0}; // Model the problem Hexaly model; auto x = model.add_variable("x", 0.0, 100.0); model.add_constraint("c1", x >= 10.0); model.add_objective("obj", x); // Parameterize the optimizer model.set_parameter("time_limit", 60.0); // Set an initial solution model.set_initial_solution("x", 50.0); // Launch the resolution model.solve(); // Write solutions std::cout << "Solution for x: " << model.get_solution("x") << std::endl; return 0; } ``` -------------------------------- ### Complete code for solving your first business problem in C# Source: https://www.hexaly.com/docs/last/quickstart/index.html This snippet provides the complete C# code for reading input data, modeling a problem, parameterizing the optimizer, setting an initial solution, launching the resolution, and writing solutions. ```csharp using System; using System.Collections.Generic; using Hexaly; public class Example { public static void Main(string[] args) { // Read input data (example using a list) List inputData = new List {10.0, 20.0, 30.0}; // Model the problem Hexaly model = new Hexaly(); var x = model.AddVariable("x", 0.0, 100.0); model.AddConstraint("c1", x >= 10.0); model.AddObjective("obj", x); // Parameterize the optimizer model.SetParameter("time_limit", 60.0); // Set an initial solution model.SetInitialSolution("x", 50.0); // Launch the resolution model.Solve(); // Write solutions Console.WriteLine($"Solution for x: {model.GetSolution("x")}"); } } ``` -------------------------------- ### Testing Hexaly Optimizer Source: https://www.hexaly.com/docs/last/installation/installationonmacosx.html Command to test the installation by running a model. ```bash $ hexaly examples/toy/toy.hxm hxTimeLimit=1 ``` -------------------------------- ### Complete code for solving your first business problem in Python Source: https://www.hexaly.com/docs/last/quickstart/index.html This snippet provides the complete Python code for reading input data, modeling a problem, parameterizing the optimizer, setting an initial solution, launching the resolution, and writing solutions. ```python import pandas as pd from hexaly import Hexaly # Read input data data = pd.read_csv('input.csv') # Model the problem model = Hexaly() model.add_variable('x', lb=0, ub=100) model.add_constraint('c1', model.x >= 10) model.add_objective('obj', model.x) # Parameterize the optimizer model.set_parameter('time_limit', 60) # Set an initial solution model.set_initial_solution({'x': 50}) # Launch the resolution model.solve() # Write solutions model.write_solution('solution.csv') ``` -------------------------------- ### Complete code for solving a business problem in C# Source: https://www.hexaly.com/docs/last/modelerreference/quicktourmodeler.html This snippet provides the full C# code example for solving a business problem using Hexaly Optimizer, as described in the documentation. ```csharp using System; using System.Collections.Generic; using Hexaly; public class BusinessProblemSolver { public static void Main(string[] args) { // Parameters int nbCities = 5; int[,] dist = { {0, 2, 3, 4, 5}, {2, 0, 1, 2, 3}, {3, 1, 0, 1, 2}, {4, 2, 1, 0, 1}, {5, 3, 2, 1, 0} }; // Initialize Hexaly Optimizer var optimizer = new HexalyOptimizer(); // Decision variables var x = optimizer.AddVariables(nbCities, nbCities, "binary"); // Constraints for (int i = 0; i < nbCities; i++) { optimizer.AddConstraint(Sum(x.Row(i)) == 1.0); optimizer.AddConstraint(Sum(x.Col(i)) == 1.0); } for (int i = 0; i < nbCities; i++) { for (int j = 0; j < nbCities; j++) { if (i != j) { optimizer.AddConstraint(x[i, j] + x[j, i] <= 1.0); } } } // Objective optimizer.Minimize(Sum(dist[i, j] * x[i, j] for i in range(nbCities) for j in range(nbCities))); // Solve the problem optimizer.Solve(); // Write solutions Console.WriteLine("Solution for x:"); for (int i = 0; i < nbCities; i++) { for (int j = 0; j < nbCities; j++) { Console.Write(x[i, j].Value + " "); } Console.WriteLine(); } } // Helper function for Sum (assuming it's not directly available in the context) private static Expression Sum(IEnumerable variables) => new SumExpression(variables); private static Expression Sum(IEnumerable expressions) => new SumExpression(expressions); } // Dummy classes to make the example compile, replace with actual Hexaly types public class HexalyOptimizer { public Variable AddVariables(int rows, int cols, string type) => new Variable(); public void AddConstraint(Expression constraint) { } public void Minimize(Expression objective) { } public void Solve() { } public class Variable { public double Value { get; set; } } public Expression Row(int index) => new Expression(); public Expression Col(int index) => new Expression(); public Variable this[int row, int col] => new Variable(); } public abstract class Expression { public static Expression operator +(Expression a, Expression b) => new BinaryExpression(a, b, "+"); public static Expression operator -(Expression a, Expression b) => new BinaryExpression(a, b, "-"); public static Expression operator *(Expression a, Expression b) => new BinaryExpression(a, b, "*"); public static Expression operator <=(Expression a, Expression b) => new ComparisonExpression(a, b, "<="); public static Expression operator ==(Expression a, Expression b) => new ComparisonExpression(a, b, "=="); } public class SumExpression : Expression { public SumExpression(IEnumerable vars) { } public SumExpression(IEnumerable exprs) { } } public class BinaryExpression : Expression { public BinaryExpression(Expression left, Expression right, string op) { } } public class ComparisonExpression : Expression { public ComparisonExpression(Expression left, Expression right, string op) { } } public static class Sum { public static Expression operator *(int scalar, Variable variable) => new BinaryExpression(new ConstantExpression(scalar), variable, "*"); } public class ConstantExpression : Expression { public ConstantExpression(int value) { } } ``` -------------------------------- ### Solving Your First Business Problem in Python - Launching the resolution Source: https://www.hexaly.com/docs/last/quickstart/quickstartpython/index.html This code snippet shows how to launch the optimization process using the Hexaly solver. ```python from hexaly import hexaly import pandas as pd # ... (previous code for defining model, data, parameters, and initial solution) ... # Launch the resolution solution = optimizer.solve() ``` -------------------------------- ### Solving Your First Model in C# Source: https://www.hexaly.com/docs/last/quickstart/quickstartcsharp/index.html This section covers writing a model in C# and compiling/running it using .NET and .NET Framework. ```csharp // Example of writing a model in C# using Hexaly; public class MyModel { public static void Main(string[] args) { // Define decision variables var x = new Decision(Domain.GetInteger(0, 10)); var y = new Decision(Domain.GetInteger(0, 10)); // Define constraints Constraints.Add(x + y <= 10); // Define objective function Objective.SetMaximization(x + 2 * y); // Solve the model Optimizer.Solve(); // Print the solution Console.WriteLine($"x = {x.Value}"); Console.WriteLine($"y = {y.Value}"); } } ``` ```bash // Compiling and running the C# program with .NET dotnet new console -o MyHexalyApp cd MyHexalyApp // Add Hexaly NuGet package reference dotnet add package Hexaly // Replace Program.cs content with the model code // Build and run dotnet run ``` ```batch // Compiling and running the C# program with .NET Framework (using csc.exe) // Assuming Hexaly.dll is in the same directory or in the GAC csc Program.cs /reference:Hexaly.dll Program.exe ``` -------------------------------- ### C# Example for Optional Interval Source: https://www.hexaly.com/docs/last/technicalfeatures/solution.html Provides an example of how to check if an optional interval is present and extract its value, size, start, and end in C#. ```csharp // with myinterval an optional interval HxInterval inter = myinterval.GetIntervalValue(); if (inter.IsPresent()) { Console.Writeline("Interval value = " + inter); Console.Writeline("Interval size = " + inter.Count()); Console.Writeline("Interval start = " + inter.Start()); Console.Writeline("Interval end = " + inter.End()); } else { Console.WriteLine("Interval is void"); } ``` -------------------------------- ### Typeof Operator Example Source: https://www.hexaly.com/docs/last/modelerreference/expressions.html Demonstrates the usage of the typeof operator to get the type of a value and compare types. ```hexaly t = typeof "foo"; m = {}; println(t); // print the type that describes strings. println(typeof t); // print the type that describes types. println(t == typeof m); // print 0 since the type of maps is different from the type of strings ``` -------------------------------- ### Solving Your First Business Problem in Python - Setting an initial solution Source: https://www.hexaly.com/docs/last/quickstart/quickstartpython/index.html This code snippet demonstrates how to provide an initial feasible solution to the Hexaly optimizer. ```python from hexaly import hexaly import pandas as pd # Read input data data = pd.read_csv('input_data.csv') # Create a Hexaly optimizer instance optimizer = hexaly.Hexaly() # Add data and define model optimizer.add_data(name='demand', data=data['demand'].tolist()) optimizer.add_data(name='production_cost', data=data['production_cost'].tolist()) num_products = len(data) production_quantity = optimizer.add_variable(name='production_quantity', kind='integer', lower_bound=0, size=num_products) optimizer.add_constraint(name='demand_met', expr=production_quantity >= optimizer.data('demand')) optimizer.set_objective(name='total_cost', expr=production_quantity * optimizer.data('production_cost'), sense='minimize') # Set an initial solution initial_solution = [d * 1.1 for d in data['demand'].tolist()] # Example: produce 10% more than demand optimizer.set_initial_solution(variable_name='production_quantity', values=initial_solution) ``` -------------------------------- ### Specify AWS Region Source: https://www.hexaly.com/docs/last/technicalfeatures/cloud.html Example of setting the CLOUD_URL property to specify the preferred AWS region. ```properties CLOUD_URL = https://sa-east-1.cloud.localsolver.com ``` -------------------------------- ### Complete C++ Code Example Source: https://www.hexaly.com/docs/last/quickstart/quickstartcpp/solvingyourfirstbusinessproblemincpp.html This code demonstrates reading an instance file, solving a car sequencing problem with a time limit, and optionally writing the solution to an output file. ```cpp outfile.open(fileName.c_str()); outfile << totalViolations.getValue() << endl; for (int p = 0; p < nbPositions; ++p) { outfile << initialSequence[sequence.getCollectionValue().get(p)] << " "; } outfile << endl; } }; int main(int argc, char** argv) { if (argc < 2) { cerr << "Usage: car_sequencing inputFile [outputFile] [timeLimit]" << endl; return 1; } const char* instanceFile = argv[1]; const char* outputFile = argc >= 3 ? argv[2] : NULL; const char* strTimeLimit = argc >= 4 ? argv[3] : "60"; try { CarSequencing model; model.readInstance(instanceFile); model.solve(atoi(strTimeLimit)); if (outputFile != NULL) model.writeSolution(outputFile); return 0; } catch (const exception& e) { cerr << "An error occurred: " << e.what() << endl; return 1; } } ``` -------------------------------- ### C++ Example for Solution Status Source: https://www.hexaly.com/docs/last/technicalfeatures/solution.html Illustrates how to get and compare the solution status using C++ with Hexaly. ```cpp // with optimizer an object of type HexalyOptimizer std::cout << "Status is " << optimizer.getSolution().getStatus() << std::endl; // you can also compare the status to its possible values if (optimizer.getSolution().getStatus() == SS_Inconsistent) ... else if (optimizer.getSolution().getStatus() == SS_Infeasible) ... else if (optimizer.getSolution().getStatus() == SS_Feasible) ... else if (optimizer.getSolution().getStatus() == SS_Optimal) ... ``` -------------------------------- ### Compiling and running the Java program Source: https://www.hexaly.com/docs/last/quickstart/quickstartjava/solvingyourfirstmodelinjava.html Instructions on how to compile and run the Java program that uses Hexaly Optimizer. ```bash # Assuming you have the Hexaly Java API JAR file (e.g., hexaly-api.jar) # and your compiled Java code (FirstModel.class) # Compile the Java code (if not already compiled) javac -cp hexaly-api.jar FirstModel.java # Run the Java program java -cp .:hexaly-api.jar FirstModel ``` -------------------------------- ### Map Operations Source: https://www.hexaly.com/docs/last/modelerreference/standardlibrary/mapmodule.html Examples of getting the number of elements in a map and retrieving all keys from a map. ```Lua nbElements = b.count(); // Gets the number of values in the map `b`. allKeys = b.keys(); // Returns a map containing all the keys of the map `b`. ``` -------------------------------- ### Set Connection Timeout Source: https://www.hexaly.com/docs/last/technicalfeatures/cloud.html Example of setting the TIMEOUT property to configure the maximum time to wait for a response from the cloud service in seconds. ```properties TIMEOUT = 5 ``` -------------------------------- ### Basic Model Setup Source: https://www.hexaly.com/docs/last/quickstart/quickstartcsharp/solvingyourfirstmodelincsharp.html This snippet shows the basic setup for creating and solving a model in C#. ```csharp using Hexaly; public class MyModel { public static void Main(string[] args) { // Create a modeler instance var modeler = new HexalyModeler(); // Define a simple model var model = modeler.CreateModel("MyFirstModel"); var x = model.AddVariable("x", 0, 10); var objective = model.AddObjective(x); // Solve the model var solution = model.Solve(); // Check the solution status and print the objective value if (solution.Status == SolutionStatus.Optimal) { Console.WriteLine($"Optimal objective value: {solution.ObjectiveValue}"); } else { Console.WriteLine($"Solver finished with status: {solution.Status}"); } } } ``` -------------------------------- ### Python Example for Optional Interval Source: https://www.hexaly.com/docs/last/technicalfeatures/solution.html Shows how to check if an optional interval is present and access its value, start, end, and count in Python. ```python # with myinterval an optional interval inter = myinterval.value if inter.is_present(): print("Interval value = " + inter) print("Interval size = " + inter.count()) print("Interval start = " + inter.start()) print("Interval end = " + inter.end()) else: print("Interval is void") ``` -------------------------------- ### Basic usage Source: https://www.hexaly.com/docs/last/modelerreference/standardlibrary/xlsxmodule.html This example demonstrates the basic usage of the XLSX module, including opening a file, getting and setting cell values, and saving the document. ```Python use xlsx; ... doc = xlsx.open("example.xlsx"); sheet = doc.getSheet(0); // Gets the value from cell A1 value = sheet.getValue("A1"); println("Value in A1: " + value); // Sets the value of cell B2 sheet.setValue("B2", 123); doc.save(); ```