Skip to content

Commit

Permalink
Merge branch 'develop' into feature/max-hydro-gen-pump-per-h-cr23
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaredstork committed Aug 31, 2023
2 parents 867aa5b + dcf91f9 commit 81850af
Show file tree
Hide file tree
Showing 45 changed files with 263 additions and 628 deletions.
47 changes: 47 additions & 0 deletions docs/reference-guide/16-xpress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Usage with FICO® Xpress Optimization

## Introduction
The FICO Xpress optimizer is a commercial optimization solver for linear programming (LP), mixed integer linear programming (MILP), convex quadratic programming (QP), convex quadratically constrained quadratic programming (QCQP), second-order cone programming (SOCP) and their mixed integer counterparts.

Antares Solver only uses LP, with plans to use MILP at some point in the future. Various benchmarks have revealed that Xpress allows faster simulations than Sirius on large studies.

## Using Xpress in the command-line
```
antares-x.y-solver --use-ortools --ortools-solver xpress [options] <study>
```

## Setup
The `XPRESSDIR` env variable must point to the Xpress install directory. The author strongly suggest placing this in your .bashrc if you use Bash
```
export XPRESSDIR=path/to/xpress/install/dir
```

An Xpress install directory looks like this. Actually, only these files are required, the rest are unnecessary
```
xpress814 <= XPRESSDIR
└── lib
├── libxprs.so -> libxprs.so.40
├── libxprs.so.40 <= The Xpress shared library
└── xpauth.xpr <= A valid licence
```

## Checking that Xpress works
After setting up Xpress, the following command line should display a line if Xpress is installed and a valid licence is found.
```
antares-x.y-solver --list-solvers | grep xpress
```

## Compatibility
Antares Simulator 8.x has been shown to work with Xpress 8.13.0. Trying to use other versions may work, but can lead to crashes.

## Known issues
### Performance issues with Xpress 9.x
The following Xpress versions suffer a performance regression that makes them unsuitable for use with Antares Simulator
- 9.0.x
- 9.1.x
- 9.2.x

As of Q3 2023, it is best to stick to Xpress 8.13.0 for best performance

### Community license is very restrictive
FICO offers a Community License for testing purposes. It should be noted however that it is extremely restrictive. You may experience issues when trying to run Antares Solver with this license, even on small test-cases.
7 changes: 5 additions & 2 deletions src/libs/antares/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ set(SRC_XCAST
source_group("study\\xcast" FILES ${SRC_XCAST})

add_subdirectory(benchmarking)
add_subdirectory(InfoCollection)
add_subdirectory(io)
add_subdirectory(exception)

Expand Down Expand Up @@ -508,7 +509,6 @@ target_link_libraries(libantares-core
yuni-static-uuid
Boost::boost
Antares::memory
date
logs
exception
checks
Expand All @@ -517,9 +517,12 @@ target_link_libraries(libantares-core
inifile
io
array
correlation
object
benchmarking
Antares::date

PRIVATE
Antares::correlation
)

import_std_libs(libantares-core)
35 changes: 35 additions & 0 deletions src/libs/antares/InfoCollection/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
set(PROJ infoCollection)
set(HEADERS
include/antares/${PROJ}/StudyInfoCollector.h
)
set(SRC_PROJ
${HEADERS}
StudyInfoCollector.cpp
)
source_group("misc\\${PROJ}" FILES ${SRC_PROJ})

add_library(${PROJ} ${SRC_PROJ})
add_library(Antares::${PROJ} ALIAS ${PROJ})

target_link_libraries(${PROJ}
PRIVATE
yuni-static-core
PUBLIC
Antares::benchmarking
)

target_include_directories(${PROJ}
PUBLIC
${CMAKE_SOURCE_DIR}/libs #study
${CMAKE_SOURCE_DIR}/libs/antares/date #parameters -> date
${CMAKE_SOURCE_DIR}/libs/antares/array #links
${CMAKE_SOURCE_DIR}/libs/antares/logs #study -> binding constraint -> matrix -> jit
${CMAKE_SOURCE_DIR}/libs/antares/io #study -> binding constraint -> matrix
${CMAKE_SOURCE_DIR}/libs/antares/writer #study
${CMAKE_SOURCE_DIR}/libs/antares/exception #enum -> exception
${CMAKE_SOURCE_DIR}/libs/antares/jit # something,something -> jit
${CMAKE_SOURCE_DIR}/libs/antares/memory/include #study -> BC -> link -> memory
${CMAKE_SOURCE_DIR}/libs/antares/inifile #study -> inifile
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#include <numeric>
#include <antares/benchmarking/info_collectors.h>
#include <antares/config.h>
#include <antares/Enum.hpp>
#include <antares/study/area.h>
//
// Created by marechaljas on 22/08/23.
//

#include "antares/infoCollection/StudyInfoCollector.h"
#include "antares/benchmarking/DurationCollector.h"
#include "antares/benchmarking/file_content.h"
#include "../../../config.h"

using namespace Antares::Data;
namespace Benchmarking {

namespace Benchmarking
{
// Collecting data study
// ---------------------------
void StudyInfoCollector::toFileContent(FileContent& file_content)
Expand Down Expand Up @@ -82,17 +84,17 @@ void StudyInfoCollector::enabledBindingConstraintsCountToFileContent(FileContent
{
switch (activeContraints[i]->type())
{
case BindingConstraint::Type::typeHourly:
nbEnabledHourlyBC++;
break;
case BindingConstraint::Type::typeDaily:
nbEnabledDailyBC++;
break;
case BindingConstraint::Type::typeWeekly:
nbEnabledWeeklyBC++;
break;
default:
break;
case BindingConstraint::Type::typeHourly:
nbEnabledHourlyBC++;
break;
case BindingConstraint::Type::typeDaily:
nbEnabledDailyBC++;
break;
case BindingConstraint::Type::typeWeekly:
nbEnabledWeeklyBC++;
break;
default:
break;
}
}

Expand All @@ -105,7 +107,7 @@ void StudyInfoCollector::enabledBindingConstraintsCountToFileContent(FileContent
void StudyInfoCollector::unitCommitmentModeToFileContent(FileContent& file_content)
{
const char* unitCommitment
= UnitCommitmentModeToCString(study_.parameters.unitCommitment.ucMode);
= UnitCommitmentModeToCString(study_.parameters.unitCommitment.ucMode);
file_content.addItemToSection("study", "unit commitment", unitCommitment);
}

Expand All @@ -118,7 +120,7 @@ void StudyInfoCollector::solverVersionToFileContent(FileContent& file_content)
{
// Example : 8.3.0 -> 830
const unsigned int version
= 100 * ANTARES_VERSION_HI + 10 * ANTARES_VERSION_LO + ANTARES_VERSION_BUILD;
= 100 * ANTARES_VERSION_HI + 10 * ANTARES_VERSION_LO + ANTARES_VERSION_BUILD;

file_content.addItemToSection("study", "antares version", version);
}
Expand Down Expand Up @@ -147,27 +149,7 @@ void SimulationInfoCollector::toFileContent(FileContent& file_content)
file_content.addItemToSection("optimization problem", "variables", opt_info_.nbVariables);
file_content.addItemToSection("optimization problem", "constraints", opt_info_.nbConstraints);
file_content.addItemToSection(
"optimization problem", "non-zero coefficients", opt_info_.nbNonZeroCoeffs);
}

// Collecting durations from simulation
// -------------------------------------
void DurationCollector::toFileContent(FileContent& file_content)
{
for (const auto& element : duration_items_)
{
const std::string& name = element.first;
const auto& durations = element.second;
const int64_t duration_sum = accumulate(durations.begin(), durations.end(), (int64_t)0);

file_content.addDurationItem(name, (unsigned int)duration_sum, (int)durations.size());
}
}

void DurationCollector::addDuration(const std::string& name, int64_t duration)
{
const std::lock_guard<std::mutex> lock(mutex_);
duration_items_[name].push_back(duration);
"optimization problem", "non-zero coefficients", opt_info_.nbNonZeroCoeffs);
}

} // namespace Benchmarking
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
#pragma once

#include <vector>
#include <map>
#include <string>
#include <mutex>
//
// Created by marechaljas on 22/08/23.
//

#include "file_content.h"
#include <antares/study/study.h>
#pragma once

namespace Benchmarking
{
struct OptimizationInfo
{
unsigned int nbVariables = 0;
unsigned int nbConstraints = 0;
unsigned int nbNonZeroCoeffs = 0;
};
#include "antares/study/study.h"

/*
=== Info collectors ===
*/
namespace Benchmarking {
class FileContent;

class StudyInfoCollector
{
Expand Down Expand Up @@ -47,46 +35,22 @@ class StudyInfoCollector
const Antares::Data::Study& study_;
};

class SimulationInfoCollector
{
public:
SimulationInfoCollector(const OptimizationInfo& optInfo) : opt_info_(optInfo){};

void toFileContent(FileContent& file_content);

private:
const OptimizationInfo& opt_info_;
};

class IDurationCollector
{
public:
virtual void addDuration(const std::string& name, int64_t duration) = 0;
};

class NullDurationCollector : public IDurationCollector
struct OptimizationInfo
{
public:
NullDurationCollector() = default;
void addDuration(const std::string& /* name */, int64_t /* duration */) override
{ /* Do nothing */
}
unsigned int nbVariables = 0;
unsigned int nbConstraints = 0;
unsigned int nbNonZeroCoeffs = 0;
};

class DurationCollector : public IDurationCollector
class SimulationInfoCollector
{
public:
DurationCollector() = default;
SimulationInfoCollector(const OptimizationInfo& optInfo) : opt_info_(optInfo){};

void toFileContent(FileContent& file_content);
void addDuration(const std::string& name, int64_t duration) override;

private:
std::map<std::string, std::vector<int64_t>> duration_items_;

// Durations can be added in a context of multi-threading, so we need to protect
// these additions from thread concurrency
std::mutex mutex_;
const OptimizationInfo& opt_info_;
};

} // namespace Benchmarking
}
2 changes: 1 addition & 1 deletion src/libs/antares/array/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
set(SRC_MATRIX
antares/array/matrix.h
antares/array/array1d.h
antares/array/matrix.hxx
matrix.cpp
)
source_group("array" FILES ${SRC_MATRIX})

add_library(array ${SRC_MATRIX})
add_library(Antares::array ALIAS array)

target_link_libraries(array
PRIVATE
Expand Down
Loading

0 comments on commit 81850af

Please sign in to comment.