From ff83a73ecaf62406b5072f5f8539ee263b7c08ad Mon Sep 17 00:00:00 2001
From: Pantelis Sopasakis
Date: Fri, 16 Apr 2021 22:30:02 +0100
Subject: [PATCH 01/11] removed redundant #[no_mangle]'s
---
open-codegen/opengen/templates/c/optimizer_cinterface.rs | 3 ---
1 file changed, 3 deletions(-)
diff --git a/open-codegen/opengen/templates/c/optimizer_cinterface.rs b/open-codegen/opengen/templates/c/optimizer_cinterface.rs
index 8992610a..1b606a38 100644
--- a/open-codegen/opengen/templates/c/optimizer_cinterface.rs
+++ b/open-codegen/opengen/templates/c/optimizer_cinterface.rs
@@ -4,7 +4,6 @@
/// Solver cache (structure `{{meta.optimizer_name}}Cache`)
///
#[allow(non_camel_case_types)]
-#[no_mangle]
pub struct {{meta.optimizer_name}}Cache {
cache: AlmCache,
}
@@ -19,7 +18,6 @@ impl {{meta.optimizer_name}}Cache {
/// Structure: `{{meta.optimizer_name}}ExitStatus`
#[allow(non_camel_case_types)]
#[repr(C)]
-#[no_mangle]
pub enum {{meta.optimizer_name}}ExitStatus {
/// The algorithm has converged
///
@@ -40,7 +38,6 @@ pub enum {{meta.optimizer_name}}ExitStatus {
/// Structure: `{{meta.optimizer_name}}SolverStatus`
///
#[repr(C)]
-#[no_mangle]
pub struct {{meta.optimizer_name}}SolverStatus {
/// Exit status
exit_status: {{meta.optimizer_name}}ExitStatus,
From d8aee75704141ca64577a5fd89c8d136ee860b23 Mon Sep 17 00:00:00 2001
From: Pantelis Sopasakis
Date: Fri, 16 Apr 2021 23:42:34 +0100
Subject: [PATCH 02/11] add #safety section in unsafe docs
---
.../opengen/templates/c/optimizer_cinterface.rs | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/open-codegen/opengen/templates/c/optimizer_cinterface.rs b/open-codegen/opengen/templates/c/optimizer_cinterface.rs
index 1b606a38..5de1c422 100644
--- a/open-codegen/opengen/templates/c/optimizer_cinterface.rs
+++ b/open-codegen/opengen/templates/c/optimizer_cinterface.rs
@@ -77,7 +77,7 @@ pub extern "C" fn {{meta.optimizer_name|lower}}_new() -> *mut {{meta.optimizer_n
/// Solve the parametric optimization problem for a given parameter
/// .
/// .
-/// Arguments:
+/// # Arguments:
/// - `instance`: re-useable instance of AlmCache, which should be created using
/// `{{meta.optimizer_name|lower}}_new` (and should be destroyed once it is not
/// needed using `{{meta.optimizer_name|lower}}_free`
@@ -91,10 +91,15 @@ pub extern "C" fn {{meta.optimizer_name|lower}}_new() -> *mut {{meta.optimizer_n
/// penalty parameter
/// .
/// .
-/// Returns:
+/// # Returns:
/// Instance of `{{meta.optimizer_name}}SolverStatus`, with the solver status
/// (e.g., number of inner/outer iterations, measures of accuracy, solver time,
/// and the array of Lagrange multipliers at the solution).
+/// .
+/// .
+/// .
+/// # Safety
+/// All arguments must have been properly initialised
#[no_mangle]
pub unsafe extern "C" fn {{meta.optimizer_name|lower}}_solve(
instance: *mut {{meta.optimizer_name}}Cache,
@@ -194,6 +199,10 @@ pub unsafe extern "C" fn {{meta.optimizer_name|lower}}_solve(
/// Deallocate the solver's memory, which has been previously allocated
/// using `{{meta.optimizer_name|lower}}_new`
+///
+///
+/// # Safety
+/// All arguments must have been properly initialised
#[no_mangle]
pub unsafe extern "C" fn {{meta.optimizer_name|lower}}_free(instance: *mut {{meta.optimizer_name}}Cache) {
// Add impl
From 38efa13520a73400fd86c7c066b388e355c5e195 Mon Sep 17 00:00:00 2001
From: Pantelis Sopasakis
Date: Fri, 16 Apr 2021 23:47:04 +0100
Subject: [PATCH 03/11] update CHANGELOG
---
open-codegen/CHANGELOG.md | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/open-codegen/CHANGELOG.md b/open-codegen/CHANGELOG.md
index 5d5d04d6..b5751faa 100644
--- a/open-codegen/CHANGELOG.md
+++ b/open-codegen/CHANGELOG.md
@@ -7,7 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
Note: This is the Changelog file of `opengen` - the Python interface of OpEn
-## [0.6.5] - 2020-10-21
+## [Unreleased]
+
+### Added
+
+* `# Safety` section in unsafe auto-generated Rust code
+
+
+
+
+## [0.6.5] - 2020-04-16
### Changed
@@ -99,6 +108,7 @@ Note: This is the Changelog file of `opengen` - the Python interface of OpEn
* Project-specific `tcp_iface` TCP interface
* Fixed `lbfgs` typo
+[Unreleased]: https://github.com/alphaville/optimization-engine/compare/master...opengen-0.6.5
[0.6.5]: https://github.com/alphaville/optimization-engine/compare/opengen-0.6.4...opengen-0.6.5
[0.6.4]: https://github.com/alphaville/optimization-engine/compare/opengen-0.6.3...opengen-0.6.4
[0.6.3]: https://github.com/alphaville/optimization-engine/compare/opengen-0.6.2...opengen-0.6.3
From ecab489b037ae828cc33d92f7e14a94a135d6ab2 Mon Sep 17 00:00:00 2001
From: Pantelis Sopasakis
Date: Fri, 16 Apr 2021 23:53:33 +0100
Subject: [PATCH 04/11] update CHANGELOG
---
open-codegen/CHANGELOG.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/open-codegen/CHANGELOG.md b/open-codegen/CHANGELOG.md
index b5751faa..aa60edd6 100644
--- a/open-codegen/CHANGELOG.md
+++ b/open-codegen/CHANGELOG.md
@@ -13,7 +13,9 @@ Note: This is the Changelog file of `opengen` - the Python interface of OpEn
* `# Safety` section in unsafe auto-generated Rust code
+### Removed
+* Unnecessary `#[no_mangle]`s in auto-generated Rust code
## [0.6.5] - 2020-04-16
@@ -23,7 +25,6 @@ Note: This is the Changelog file of `opengen` - the Python interface of OpEn
* Include `VERSION` file in `MANIFEST.in` (included in Python package)
-
## [0.6.4] - 2020-10-21
### Added
@@ -33,6 +34,7 @@ Note: This is the Changelog file of `opengen` - the Python interface of OpEn
### Fixed
* List of authors in `Cargo.toml` is generated properly
+* Fixed bug when curvature is zero
### Changed
From efe006933bd04a9a7481f809004a44571a2b9e87 Mon Sep 17 00:00:00 2001
From: Pantelis Sopasakis
Date: Sat, 23 Oct 2021 01:22:20 +0100
Subject: [PATCH 05/11] fixing clippy issues
---
src/alm/alm_factory.rs | 14 +++++++-------
src/alm/alm_optimizer.rs | 13 ++++++-------
src/alm/alm_optimizer_status.rs | 2 +-
src/constraints/finite.rs | 2 +-
src/core/fbs/fbs_optimizer.rs | 2 +-
src/core/panoc/panoc_engine.rs | 2 +-
src/core/panoc/panoc_optimizer.rs | 2 +-
src/lipschitz_estimator.rs | 2 +-
8 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/src/alm/alm_factory.rs b/src/alm/alm_factory.rs
index dd34d267..5afdafd7 100644
--- a/src/alm/alm_factory.rs
+++ b/src/alm/alm_factory.rs
@@ -233,7 +233,7 @@ where
if let Some(f2) = &self.mapping_f2 {
let c = xi[0];
let mut z = vec![0.0; self.n2];
- f2(&u, &mut z)?;
+ f2(u, &mut z)?;
*cost += 0.5 * c * matrix_operations::norm2_squared(&z);
}
Ok(())
@@ -281,8 +281,8 @@ where
let mut s_aux_var = vec![0.0; ny]; // auxiliary variable `s`
let y_lagrange_mult = &xi[1..];
let mut jac_prod = vec![0.0; nu];
- mapping_f1(&u, &mut f1_u_plus_y_over_c)?; // f1_u_plus_y_over_c = F1(u)
- // f1_u_plus_y_over_c = F1(u) + y/c
+ mapping_f1(u, &mut f1_u_plus_y_over_c)?; // f1_u_plus_y_over_c = F1(u)
+ // f1_u_plus_y_over_c = F1(u) + y/c
f1_u_plus_y_over_c
.iter_mut()
.zip(y_lagrange_mult.iter())
@@ -296,7 +296,7 @@ where
.zip(s_aux_var.iter())
.for_each(|(ti, si)| *ti -= si);
- jf1t(&u, &f1_u_plus_y_over_c, &mut jac_prod)?;
+ jf1t(u, &f1_u_plus_y_over_c, &mut jac_prod)?;
// grad += c*t
grad.iter_mut()
@@ -309,9 +309,9 @@ where
let c = xi[0];
let mut f2u_aux = vec![0.0; self.n2];
let mut jf2u_times_f2u_aux = vec![0.0; self.n2];
- f2(&u, &mut f2u_aux)?; // f2u_aux = F2(u)
- jf2(&u, &f2u_aux, &mut jf2u_times_f2u_aux)?; // jf2u_times_f2u_aux = JF2(u)'*f2u_aux
- // = JF2(u)'*F2(u)
+ f2(u, &mut f2u_aux)?; // f2u_aux = F2(u)
+ jf2(u, &f2u_aux, &mut jf2u_times_f2u_aux)?; // jf2u_times_f2u_aux = JF2(u)'*f2u_aux
+ // = JF2(u)'*F2(u)
// grad += c * jf2u_times_f2u_aux
grad.iter_mut()
diff --git a/src/alm/alm_optimizer.rs b/src/alm/alm_optimizer.rs
index 6581da34..15b38b76 100644
--- a/src/alm/alm_optimizer.rs
+++ b/src/alm/alm_optimizer.rs
@@ -589,7 +589,7 @@ where
let alm_cache = &mut self.alm_cache; // ALM cache
if let (Some(y_plus), Some(xi)) = (&alm_cache.y_plus, &alm_cache.xi) {
// compute ||y_plus - y||
- let norm_diff_squared = matrix_operations::norm2_squared_diff(&y_plus, &xi[1..]);
+ let norm_diff_squared = matrix_operations::norm2_squared_diff(y_plus, &xi[1..]);
alm_cache.delta_y_norm_plus = norm_diff_squared.sqrt();
}
Ok(())
@@ -714,11 +714,11 @@ where
// psi(u) = psi(u; xi) and psi_grad(u) = phi_grad(u; xi)
// psi: R^nu --> R
let psi = |u: &[f64], psi_val: &mut f64| -> FunctionCallResult {
- (alm_problem.parametric_cost)(u, &xi, psi_val)
+ (alm_problem.parametric_cost)(u, xi, psi_val)
};
// psi_grad: R^nu --> R^nu
let psi_grad = |u: &[f64], psi_grad: &mut [f64]| -> FunctionCallResult {
- (alm_problem.parametric_gradient)(u, &xi, psi_grad)
+ (alm_problem.parametric_gradient)(u, xi, psi_grad)
};
// define the inner problem
let inner_problem = Problem::new(&self.alm_problem.constraints, psi_grad, psi);
@@ -732,7 +732,7 @@ where
.with_max_duration(
alm_cache
.available_time
- .unwrap_or(std::time::Duration::from_secs(std::u64::MAX)),
+ .unwrap_or_else(|| std::time::Duration::from_secs(std::u64::MAX)),
)
// Set the maximum number of inner iterations
.with_max_iter(self.max_inner_iterations);
@@ -817,7 +817,7 @@ where
cache.delta_y_norm = cache.delta_y_norm_plus;
cache.f2_norm = cache.f2_norm_plus;
if let (Some(xi), Some(y_plus)) = (&mut cache.xi, &cache.y_plus) {
- xi[1..].copy_from_slice(&y_plus);
+ xi[1..].copy_from_slice(y_plus);
}
cache.panoc_cache.reset();
}
@@ -979,8 +979,7 @@ where
.with_cost(cost);
if self.alm_problem.n1 > 0 {
let status = status.with_lagrange_multipliers(
- &self
- .alm_cache
+ self.alm_cache
.y_plus
.as_ref()
.expect("Although n1 > 0, there is no vector y (Lagrange multipliers)"),
diff --git a/src/alm/alm_optimizer_status.rs b/src/alm/alm_optimizer_status.rs
index e4037d06..54016245 100644
--- a/src/alm/alm_optimizer_status.rs
+++ b/src/alm/alm_optimizer_status.rs
@@ -132,7 +132,7 @@ impl AlmOptimizerStatus {
pub(crate) fn with_lagrange_multipliers(mut self, lagrange_multipliers: &[f64]) -> Self {
self.lagrange_multipliers = Some(vec![]);
if let Some(y) = &mut self.lagrange_multipliers {
- y.extend_from_slice(&lagrange_multipliers);
+ y.extend_from_slice(lagrange_multipliers);
}
self
}
diff --git a/src/constraints/finite.rs b/src/constraints/finite.rs
index cbf979b7..ca36f431 100644
--- a/src/constraints/finite.rs
+++ b/src/constraints/finite.rs
@@ -94,7 +94,7 @@ impl<'a> Constraint for FiniteSet<'a> {
best_distance = dist;
}
}
- x.copy_from_slice(&self.data[idx]);
+ x.copy_from_slice(self.data[idx]);
}
fn is_convex(&self) -> bool {
diff --git a/src/core/fbs/fbs_optimizer.rs b/src/core/fbs/fbs_optimizer.rs
index eb9e9e81..1f9d0540 100644
--- a/src/core/fbs/fbs_optimizer.rs
+++ b/src/core/fbs/fbs_optimizer.rs
@@ -123,7 +123,7 @@ where
let mut cost_value: f64 = 0.0;
(self.fbs_engine.problem.cost)(u, &mut cost_value)?;
- if !matrix_operations::is_finite(&u) || !cost_value.is_finite() {
+ if !matrix_operations::is_finite(u) || !cost_value.is_finite() {
return Err(SolverError::NotFiniteComputation);
}
diff --git a/src/core/panoc/panoc_engine.rs b/src/core/panoc/panoc_engine.rs
index 564430ca..ff76ec71 100644
--- a/src/core/panoc/panoc_engine.rs
+++ b/src/core/panoc/panoc_engine.rs
@@ -237,7 +237,7 @@ where
let gamma = self.cache.gamma;
// u_plus ← u - (1-tau)*gamma_fpr + tau*direction
- self.compute_u_plus(&u);
+ self.compute_u_plus(u);
// Note: Here `cache.cost_value` and `cache.gradient_u` are overwritten
// with the values of the cost and its gradient at the next (candidate)
diff --git a/src/core/panoc/panoc_optimizer.rs b/src/core/panoc/panoc_optimizer.rs
index 7fa76fa0..2928280f 100644
--- a/src/core/panoc/panoc_optimizer.rs
+++ b/src/core/panoc/panoc_optimizer.rs
@@ -153,7 +153,7 @@ where
}
// check for possible NaN/inf
- if !matrix_operations::is_finite(&u) {
+ if !matrix_operations::is_finite(u) {
return Err(SolverError::NotFiniteComputation);
}
diff --git a/src/lipschitz_estimator.rs b/src/lipschitz_estimator.rs
index fdeb574b..8bed754b 100644
--- a/src/lipschitz_estimator.rs
+++ b/src/lipschitz_estimator.rs
@@ -144,7 +144,7 @@ where
/// If `estimate_local_lipschitz` has not been computed, the result
/// will point to a zero vector.
pub fn get_function_value(&self) -> &[f64] {
- &self.function_value_at_u
+ self.function_value_at_u
}
///
From 38c272f5e553f9d769a31e4c5aca15ea60b8e1a0 Mon Sep 17 00:00:00 2001
From: Pantelis Sopasakis
Date: Sat, 23 Oct 2021 23:37:10 +0100
Subject: [PATCH 06/11] [ci skip] updated CHANGELOG ready to merge
---
CHANGELOG.md | 8 +++++++-
open-codegen/CHANGELOG.md | 6 +++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ef5141bf..5d14e5b1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,12 @@ Note: This is the main Changelog file for the Rust solver. The Changelog file fo
+## [Unreleased]
+
+### Changed
+
+* Removed unnecessary #[no_mangle] annotations
+* Took care of additional clippy warnings
-[Unreleased]: https://github.com/alphaville/optimization-engine/compare/v0.7.1...master
+[Unreleased]: https://github.com/alphaville/optimization-engine/compare/opengen-0.6.5...master
[v0.7.1]: https://github.com/alphaville/optimization-engine/compare/v0.7.0...v0.7.1
[v0.7.0]: https://github.com/alphaville/optimization-engine/compare/v0.6.2...v0.7.0
[v0.6.2]: https://github.com/alphaville/optimization-engine/compare/v0.6.1-alpha.2...v0.6.2
diff --git a/open-codegen/CHANGELOG.md b/open-codegen/CHANGELOG.md
index 5b04ecef..4d3da201 100644
--- a/open-codegen/CHANGELOG.md
+++ b/open-codegen/CHANGELOG.md
@@ -19,6 +19,10 @@ Note: This is the Changelog file of `opengen` - the Python interface of OpEn
* Unnecessary `#[no_mangle]`s in auto-generated Rust code
+### Changed
+
+* Took care of most clippy warnings
+
## [0.6.5] - 2021-04-16
@@ -110,7 +114,7 @@ Note: This is the Changelog file of `opengen` - the Python interface of OpEn
* Project-specific `tcp_iface` TCP interface
* Fixed `lbfgs` typo
-[Unreleased]: https://github.com/alphaville/optimization-engine/compare/master...opengen-0.6.5
+[Unreleased]: https://github.com/alphaville/optimization-engine/compare/opengen-0.6.5...master
[0.6.5]: https://github.com/alphaville/optimization-engine/compare/opengen-0.6.4...opengen-0.6.5
[0.6.4]: https://github.com/alphaville/optimization-engine/compare/opengen-0.6.3...opengen-0.6.4
[0.6.3]: https://github.com/alphaville/optimization-engine/compare/opengen-0.6.2...opengen-0.6.3
From 1f4603ae8579db389308519241efea3d15d47681 Mon Sep 17 00:00:00 2001
From: Pantelis Sopasakis
Date: Sun, 24 Oct 2021 00:56:03 +0100
Subject: [PATCH 07/11] further clippy issues in jinja templates
---
.../opengen/templates/c/optimizer_cinterface.rs | 2 +-
open-codegen/opengen/templates/optimizer.rs | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/open-codegen/opengen/templates/c/optimizer_cinterface.rs b/open-codegen/opengen/templates/c/optimizer_cinterface.rs
index 5de1c422..59c51a7b 100644
--- a/open-codegen/opengen/templates/c/optimizer_cinterface.rs
+++ b/open-codegen/opengen/templates/c/optimizer_cinterface.rs
@@ -162,7 +162,7 @@ pub unsafe extern "C" fn {{meta.optimizer_name|lower}}_solve(
Some({% if problem.dim_constraints_aug_lagrangian() == 0 %}_{% endif %}y) => {
{%- if problem.dim_constraints_aug_lagrangian() > 0 %}
let mut y_array : [f64; {{meta.optimizer_name|upper}}_N1] = [0.0; {{meta.optimizer_name|upper}}_N1];
- y_array.copy_from_slice(&y);
+ y_array.copy_from_slice(y);
y_array
{% else %}
std::ptr::null::()
diff --git a/open-codegen/opengen/templates/optimizer.rs b/open-codegen/opengen/templates/optimizer.rs
index 74750d83..0ed09240 100644
--- a/open-codegen/opengen/templates/optimizer.rs
+++ b/open-codegen/opengen/templates/optimizer.rs
@@ -149,7 +149,7 @@ fn make_constraints() -> impl Constraint {
// - Halfspace:
let offset: f64 = {{problem.constraints.offset}};
let normal_vector: &[f64] = &[{{problem.constraints.normal_vector | join(', ')}}];
- Halfspace::new(&normal_vector, offset)
+ Halfspace::new(normal_vector, offset)
{% elif 'NoConstraints' == problem.constraints.__class__.__name__ -%}
// - No constraints (whole Rn):
NoConstraints::new()
@@ -302,20 +302,20 @@ pub fn solve(
assert_eq!(u.len(), {{meta.optimizer_name|upper}}_NUM_DECISION_VARIABLES, "Wrong number of decision variables (u)");
let psi = |u: &[f64], xi: &[f64], cost: &mut f64| -> Result<(), SolverError> {
- icasadi_{{meta.optimizer_name}}::cost(&u, &xi, &p, cost);
+ icasadi_{{meta.optimizer_name}}::cost(u, xi, p, cost);
Ok(())
};
let grad_psi = |u: &[f64], xi: &[f64], grad: &mut [f64]| -> Result<(), SolverError> {
- icasadi_{{meta.optimizer_name}}::grad(&u, &xi, &p, grad);
+ icasadi_{{meta.optimizer_name}}::grad(u, xi, p, grad);
Ok(())
};
{% if problem.dim_constraints_aug_lagrangian() > 0 %}
let f1 = |u: &[f64], res: &mut [f64]| -> Result<(), SolverError> {
- icasadi_{{meta.optimizer_name}}::mapping_f1(&u, &p, res);
+ icasadi_{{meta.optimizer_name}}::mapping_f1(u, p, res);
Ok(())
};{% endif %}
{% if problem.dim_constraints_penalty() %}let f2 = |u: &[f64], res: &mut [f64]| -> Result<(), SolverError> {
- icasadi_{{meta.optimizer_name}}::mapping_f2(&u, &p, res);
+ icasadi_{{meta.optimizer_name}}::mapping_f2(u, p, res);
Ok(())
};{% endif -%}
let bounds = make_constraints();
@@ -353,7 +353,7 @@ pub fn solve(
// initial vector of Lagrange multipliers, if provided;
// returns the problem status (instance of `AlmOptimizerStatus`)
if let Some(y0_) = y0 {
- let mut alm_optimizer = alm_optimizer.with_initial_lagrange_multipliers(&y0_);
+ let mut alm_optimizer = alm_optimizer.with_initial_lagrange_multipliers(y0_);
alm_optimizer.solve(u)
} else {
alm_optimizer.solve(u)
From 87c46e1b03c8089fbd4b7986c71fb15045cc310c Mon Sep 17 00:00:00 2001
From: Pantelis Sopasakis
Date: Sun, 24 Oct 2021 01:10:00 +0100
Subject: [PATCH 08/11] more clippy issues fixed (templates)
---
open-codegen/CHANGELOG.md | 2 +-
open-codegen/opengen/icasadi/build.rs | 1 -
open-codegen/opengen/templates/tcp/tcp_server.rs | 6 +++---
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/open-codegen/CHANGELOG.md b/open-codegen/CHANGELOG.md
index 4d3da201..563ddd65 100644
--- a/open-codegen/CHANGELOG.md
+++ b/open-codegen/CHANGELOG.md
@@ -21,7 +21,7 @@ Note: This is the Changelog file of `opengen` - the Python interface of OpEn
### Changed
-* Took care of most clippy warnings
+* Took care of most clippy warnings in Rust and auto-generated Rust code
## [0.6.5] - 2021-04-16
diff --git a/open-codegen/opengen/icasadi/build.rs b/open-codegen/opengen/icasadi/build.rs
index aa831a64..87e6c871 100644
--- a/open-codegen/opengen/icasadi/build.rs
+++ b/open-codegen/opengen/icasadi/build.rs
@@ -1,4 +1,3 @@
-use cc;
use std::path::Path;
fn main() {
diff --git a/open-codegen/opengen/templates/tcp/tcp_server.rs b/open-codegen/opengen/templates/tcp/tcp_server.rs
index 6bb06db7..37c64019 100644
--- a/open-codegen/opengen/templates/tcp/tcp_server.rs
+++ b/open-codegen/opengen/templates/tcp/tcp_server.rs
@@ -154,7 +154,7 @@ fn execution_handler(
write_error_message(stream, 1600, "Initial guess has incompatible dimensions");
return;
}
- u.copy_from_slice(&u0);
+ u.copy_from_slice(u0);
}
}
@@ -176,8 +176,8 @@ fn execution_handler(
write_error_message(stream, 3003, "wrong number of parameters");
return;
}
- p.copy_from_slice(¶meter);
- let status = solve(&p,
+ p.copy_from_slice(parameter);
+ let status = solve(p,
cache,
u,
&execution_parameter.initial_lagrange_multipliers,
From fdcfb00dfdb0f34d2d288ff733f254e88199a559 Mon Sep 17 00:00:00 2001
From: Pantelis Sopasakis
Date: Sun, 24 Oct 2021 01:24:55 +0100
Subject: [PATCH 09/11] more clippy's in CI script
---
ci/script.sh | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/ci/script.sh b/ci/script.sh
index 7b011e80..c4b118f7 100755
--- a/ci/script.sh
+++ b/ci/script.sh
@@ -36,12 +36,47 @@ regular_test() {
# Run Clippy for generated optimizers
# ------------------------------------
- cd .python_test_build/only_f1/tcp_iface_only_f1
+
+ #TODO: Make a function...
+
+ # CLIPPY @only_f1
+ # ...............
+ # Test auto-generated code (main)
+ cd .python_test_build/only_f1
+ cargo clippy --all-targets --all-features
+ # Test auto-generated TCP interface
+ cd ./tcp_iface_only_f1
+ cargo clippy --all-targets --all-features
+ # Test auto-generated CasADi interface
+ cd ../icasadi_only_f1/
cargo clippy --all-targets --all-features
- cd ../../only_f2/tcp_iface_only_f2
+
+ # CLIPPY @only_f2
+ # ...............
+ cd ../../only_f2
cargo clippy --all-targets --all-features
+ cd ./tcp_iface_only_f2
+ cargo clippy --all-targets --all-features
+ cd ../icasadi_only_f2
+ cargo clippy --all-targets --all-features
+
+ # CLIPPY @rosenbrock_ros
+ # ...............
cd ../../rosenbrock_ros
cargo clippy --all-targets --all-features
+ cd ./icasadi_rosenbrock_ros
+ cargo clippy --all-targets --all-features
+
+
+ # CLIPPY @halfspace_optimizer
+ # ...............
+ cd ../../halfspace_optimizer
+ cargo clippy --all-targets --all-features
+ cd ./icasadi_halfspace_optimizer
+ cargo clippy --all-targets --all-features
+ cd ../tcp_iface_halfspace_optimizer/
+ cargo clippy --all-targets --all-features
+
}
test_docker() {
From 2c54700e31216ab650dea781cfd5133203dd67b4 Mon Sep 17 00:00:00 2001
From: Pantelis Sopasakis
Date: Sun, 24 Oct 2021 03:24:14 +0100
Subject: [PATCH 10/11] refactor CI script
---
ci/script.sh | 73 +++++++++++++++++++++++-----------------------------
1 file changed, 32 insertions(+), 41 deletions(-)
diff --git a/ci/script.sh b/ci/script.sh
index c4b118f7..c4082db2 100755
--- a/ci/script.sh
+++ b/ci/script.sh
@@ -1,25 +1,45 @@
#!/bin/bash
set -euxo pipefail
+function run_clippy_test() {
+ cd $1
+ cargo clippy --all-targets --all-features
+ if [ -d "./tcp_iface_$1" ]
+ then
+ # Test auto-generated TCP interface
+ cd ./tcp_iface_$1
+ cargo clippy --all-targets --all-features
+ cd ..
+ fi
+ if [ -d "./tcp_iface_$1" ]
+ then
+ # Test auto-generated CasADi interface
+ cd icasadi_$1
+ cargo clippy --all-targets --all-features
+ cd ..
+ fi
+ cd ..
+}
+
regular_test() {
# Run Python tests
# ------------------------------------
# --- create virtual environment
cd open-codegen
- export PYTHONPATH=.
+ # export PYTHONPATH=.
# --- install virtualenv
- pip install virtualenv
+ # pip install virtualenv
# --- create virtualenv
- virtualenv -p python3.8 venv
+ # virtualenv -p python3.8 venv
# --- activate venv
source venv/bin/activate
# --- upgrade pip within venv
- pip install --upgrade pip
+ # pip install --upgrade pip
# --- install opengen
pip install .
@@ -39,44 +59,15 @@ regular_test() {
#TODO: Make a function...
- # CLIPPY @only_f1
- # ...............
- # Test auto-generated code (main)
- cd .python_test_build/only_f1
- cargo clippy --all-targets --all-features
- # Test auto-generated TCP interface
- cd ./tcp_iface_only_f1
- cargo clippy --all-targets --all-features
- # Test auto-generated CasADi interface
- cd ../icasadi_only_f1/
- cargo clippy --all-targets --all-features
+ cd .python_test_build
+ run_clippy_test "only_f1"
+ run_clippy_test "only_f2"
+ run_clippy_test "halfspace_optimizer"
+ run_clippy_test "parametric_f2"
+ run_clippy_test "plain"
+ run_clippy_test "python_bindings"
+ run_clippy_test "rosenbrock_ros"
- # CLIPPY @only_f2
- # ...............
- cd ../../only_f2
- cargo clippy --all-targets --all-features
- cd ./tcp_iface_only_f2
- cargo clippy --all-targets --all-features
- cd ../icasadi_only_f2
- cargo clippy --all-targets --all-features
-
- # CLIPPY @rosenbrock_ros
- # ...............
- cd ../../rosenbrock_ros
- cargo clippy --all-targets --all-features
- cd ./icasadi_rosenbrock_ros
- cargo clippy --all-targets --all-features
-
-
- # CLIPPY @halfspace_optimizer
- # ...............
- cd ../../halfspace_optimizer
- cargo clippy --all-targets --all-features
- cd ./icasadi_halfspace_optimizer
- cargo clippy --all-targets --all-features
- cd ../tcp_iface_halfspace_optimizer/
- cargo clippy --all-targets --all-features
-
}
test_docker() {
From 46e013a56b7324a5175087f8805bfc38583004ab Mon Sep 17 00:00:00 2001
From: Pantelis Sopasakis
Date: Sun, 24 Oct 2021 03:27:42 +0100
Subject: [PATCH 11/11] fix issues in script.sh
---
ci/script.sh | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/ci/script.sh b/ci/script.sh
index c4082db2..313662f7 100755
--- a/ci/script.sh
+++ b/ci/script.sh
@@ -27,19 +27,19 @@ regular_test() {
# --- create virtual environment
cd open-codegen
- # export PYTHONPATH=.
+ export PYTHONPATH=.
# --- install virtualenv
- # pip install virtualenv
+ pip install virtualenv
# --- create virtualenv
- # virtualenv -p python3.8 venv
+ virtualenv -p python3.8 venv
# --- activate venv
source venv/bin/activate
# --- upgrade pip within venv
- # pip install --upgrade pip
+ pip install --upgrade pip
# --- install opengen
pip install .
@@ -57,8 +57,6 @@ regular_test() {
# Run Clippy for generated optimizers
# ------------------------------------
- #TODO: Make a function...
-
cd .python_test_build
run_clippy_test "only_f1"
run_clippy_test "only_f2"